Skip to content

Commit

Permalink
fix: comms
Browse files Browse the repository at this point in the history
  • Loading branch information
distributedstatemachine committed Dec 30, 2024
1 parent 248f7c4 commit 01d4e24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
7 changes: 6 additions & 1 deletion docker/compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
node:
image: ghcr.io/tplr-ai/templar:v0.0.2
image: ghcr.io/tplr-ai/templar:v0.0.4
container_name: templar-${NODE_TYPE:-miner}-${WALLET_HOTKEY}
restart: unless-stopped
volumes:
Expand All @@ -15,6 +15,11 @@ services:
- DEBUG=${DEBUG:-false}
- WANDB_API_KEY=${WANDB_API_KEY}
- HOST_CUDA_VERSION=12.6
- R2_ACCOUNT_ID=${R2_ACCOUNT_ID}
- R2_READ_ACCESS_KEY_ID=${R2_READ_ACCESS_KEY_ID}
- R2_READ_SECRET_ACCESS_KEY=${R2_READ_SECRET_ACCESS_KEY}
- R2_WRITE_ACCESS_KEY_ID=${R2_WRITE_ACCESS_KEY_ID}
- R2_WRITE_SECRET_ACCESS_KEY=${R2_WRITE_SECRET_ACCESS_KEY}
deploy:
resources:
reservations:
Expand Down
37 changes: 13 additions & 24 deletions src/tplr/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,25 @@ def __init__(
self.bucket_secrets = BUCKET_SECRETS

def get_own_bucket(self) -> Bucket:
"""Parses the credentials from .env.yaml to create a Bucket object."""
env_file = ".env.yaml"
if not os.path.isfile(env_file):
logger.error(f"The {env_file} file was not found.")
raise FileNotFoundError(f"The {env_file} file was not found.")

try:
with open(env_file, "r") as file:
credentials = yaml.safe_load(file)
except yaml.YAMLError as e:
logger.error(f"Error parsing {env_file}: {e}")
raise e

"""Gets bucket configuration from environment variables via config.BUCKET_SECRETS."""
try:
account_id = credentials["account_id"]
read_access_key_id = credentials["read"]["access_key_id"]
read_secret_access_key = credentials["read"]["secret_access_key"]

# Create a Bucket object
# Create a Bucket object using write credentials from BUCKET_SECRETS
bucket = Bucket(
name=account_id,
account_id=account_id,
access_key_id=read_access_key_id,
secret_access_key=read_secret_access_key,
name=BUCKET_SECRETS["account_id"],
account_id=BUCKET_SECRETS["account_id"],
access_key_id=BUCKET_SECRETS["write"]["access_key_id"],
secret_access_key=BUCKET_SECRETS["write"]["secret_access_key"],
)
logger.debug(f"Parsed bucket from {env_file}: {bucket}")
logger.debug(f"Created bucket from environment: {bucket}")
return bucket

except KeyError as e:
logger.error(f"Missing key in {env_file}: {e}")
raise e
logger.error(f"Missing required R2 configuration: {e}")
raise
except Exception as e:
logger.error(f"Error creating bucket: {e}")
raise

async def put(
self,
Expand Down

0 comments on commit 01d4e24

Please sign in to comment.