Skip to content

Support Folders in GCS buckets#96

Open
Greeshma-03 wants to merge 13 commits intomainfrom
FolderSupport
Open

Support Folders in GCS buckets#96
Greeshma-03 wants to merge 13 commits intomainfrom
FolderSupport

Conversation

@Greeshma-03
Copy link
Copy Markdown
Collaborator

No description provided.

upload_status = prepare_gcs_bucket(gcs_bucket, file_path, filename)
upload_status = prepare_gcs_bucket(gcs_bucket, folder_name, file_path, filename)
if not upload_status:
logger.error(f"Failed to prepare GCS bucket '{gcs_bucket}' for file '{filename}'. Skipping import.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets log folder_name as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

bucket_file_map[b].append(f)
bucket = buckets[0]
if len(buckets) > 1:
logger.warning(f"Multiple buckets provided; using '{bucket}' with folder-based uploads.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So from now on we will use only a single bucket no matter how many buckets the user has provided?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the customers whoever is using this PR. We don't merge the PR though.

logger.warning(f"Multiple buckets provided; using '{bucket}' with folder-based uploads.")

folder_names = [f"{MIGRATION_FOLDER_PREFIX}{idx+1}" for idx in range(len(files))]
if not ensure_folders_exist(bucket, folder_names):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure_folder_exists actually creates the folders idempotently, we should rename is to create_folders

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

logger.debug(f"Uploaded {file_path} -> gs://{bucket_name}/{destination_blob_name}")
return True
except Exception as error:
logger.error("Failed to upload '%s' to bucket '%s' with error '%s'", file_path, bucket_name, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets log destination_blob_name as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we have the destination blob name log in generated logs file, do we need it in main logs (Directly displayed to user while script is running) also?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants