Skip to content

Commit

Permalink
feat: support overwiting when uploading to cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
tzole1155 committed Mar 19, 2024
1 parent 4a1309a commit d25c114
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion moai/conf/engine/serve/handlers/output/azure/blob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ connection_string: StorageAccessToken # ${env:AZURE_STORAGE_CONNECTION_STRING} #
container_name: StorageContainer # ${env:AZURE_STORAGE_CONTAINER_NAME}
blob_paths: ???
working_dir: ???
alias: ???
alias: ???
overwrite: true
5 changes: 4 additions & 1 deletion moai/serve/handlers/azure/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(
blob_paths: typing.List[str], # keys to extract resources from json
working_dir: str, # path to working dir
alias: typing.List[str], # names of files to be uploaded
overwrite: bool = True, # overwrite existing files
):
"""
Responsible for uploading data to Azure Blob Storage.
Expand All @@ -86,6 +87,7 @@ def __init__(
blob_paths (typing.List[str]): Keys to extract resources from json.
working_dir (str): Path to working dir.
alias (typing.List[str]): Names of files to be uploaded.
overwrite (bool, optional): Overwrite existing files. Defaults to True.
"""
# connect_str = os.environ[connection_string]
Expand All @@ -98,6 +100,7 @@ def __init__(
self.blob_acecessors = [_create_accessor(bl_path) for bl_path in blob_paths]
self.working_dir = working_dir
self.alias = alias
self.overwrite = overwrite
log.info(
"Azure Blob Upload Storage connection established to container: %s",
container_name,
Expand Down Expand Up @@ -126,7 +129,7 @@ def __call__(
)
# Upload the created file
with open(file=local_file, mode="rb") as data:
blob_client.upload_blob(data)
blob_client.upload_blob(data, overwrite=self.overwrite)

log.debug(f"Upload file {al} to {upload_file_path}")

Expand Down

0 comments on commit d25c114

Please sign in to comment.