Skip to content

Commit

Permalink
fix race condition in bucket creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrede committed Sep 13, 2024
1 parent 3178f5b commit 76a8f19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fedn/network/combiner/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
network_id = get_network_config()

statestore = MongoStateStore(network_id, statestore_config["mongo_config"])
repository = Repository(modelstorage_config["storage_config"])
repository = Repository(modelstorage_config["storage_config"], init_buckets=False)

modelservice = ModelService()
9 changes: 5 additions & 4 deletions fedn/network/storage/s3/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Repository:
"""Interface for storing model objects and compute packages in S3 compatible storage."""

def __init__(self, config):
def __init__(self, config, init_buckets=True):
self.model_bucket = config["storage_bucket"]
self.context_bucket = config["context_bucket"]
try:
Expand All @@ -19,9 +19,10 @@ def __init__(self, config):
# TODO: Make a plug-in solution
self.client = MINIORepository(config)

self.client.create_bucket(self.context_bucket)
self.client.create_bucket(self.model_bucket)
self.client.create_bucket(self.inference_bucket)
if init_buckets:
self.client.create_bucket(self.context_bucket)
self.client.create_bucket(self.model_bucket)
self.client.create_bucket(self.inference_bucket)

def get_model(self, model_id):
"""Retrieve a model with id model_id.
Expand Down

0 comments on commit 76a8f19

Please sign in to comment.