Skip to content

Conversation

aslonnie
Copy link
Collaborator

out of util.py. also adding its own py_library

@aslonnie aslonnie requested a review from a team as a code owner October 13, 2025 16:02
@aslonnie aslonnie force-pushed the lonnie-251013-winfix9 branch from ff1b565 to 51474ad Compare October 13, 2025 16:03
cursor[bot]

This comment was marked as outdated.

@aslonnie aslonnie added the go add ONLY when ready to merge, run all tests label Oct 13, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the codebase by moving Azure-related utility functions from util.py into a new, dedicated cloud_util.py module. This is a good improvement for code organization and modularity. The corresponding BUILD.bazel files and tests are updated accordingly. My review includes a couple of suggestions to improve consistency in URL handling for Azure and to ensure temporary files are properly cleaned up.

Comment on lines +63 to +69
archived_file_path = archive_directory(working_dir)
archived_filename = os.path.basename(archived_file_path)
azure_file_path = f"{azure_directory_uri}/{archived_filename}"
upload_file_to_azure(
local_file_path=archived_file_path, azure_file_path=azure_file_path
)
return azure_file_path
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The upload_working_dir_to_azure function calls archive_directory to create a temporary zip file, but this file is not deleted after being uploaded to Azure. This will leave temporary files in the execution environment. It's a good practice to ensure temporary resources are cleaned up. You can use a try...finally block to ensure the file is removed even if the upload fails.

    archived_file_path = archive_directory(working_dir)
    try:
        archived_filename = os.path.basename(archived_file_path)
        azure_file_path = f"{azure_directory_uri}/{archived_filename}"
        upload_file_to_azure(
            local_file_path=archived_file_path, azure_file_path=azure_file_path
        )
        return azure_file_path
    finally:
        if os.path.exists(archived_file_path):
            os.remove(archived_file_path)

Comment on lines +96 to +102
def convert_abfss_uri_to_https(uri: str) -> str:
"""Convert ABFSS URI to HTTPS URI.
ABFSS URI format: abfss://[email protected]/path
Returns: HTTPS URI format: https://account.dfs.core.windows.net/container/path
"""
account, container, path = _parse_abfss_uri(uri)
return f"https://{account}.dfs.core.windows.net/{container}/{path}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The function convert_abfss_uri_to_https returns a URL with dfs.core.windows.net, while upload_file_to_azure in the same file uses blob.core.windows.net when creating a BlobServiceClient. This inconsistency can be confusing and lead to potential issues. For better maintainability and clarity, it's recommended to consistently use the blob storage endpoint (blob.core.windows.net) throughout, especially since you are using azure.storage.blob.BlobServiceClient.

def convert_abfss_uri_to_https(uri: str) -> str:
    """Convert ABFSS URI to HTTPS URI.
    ABFSS URI format: abfss://[email protected]/path
    Returns: HTTPS URI format: https://account.blob.core.windows.net/container/path
    """
    account, container, path = _parse_abfss_uri(uri)
    return f"https://{account}.blob.core.windows.net/{container}/{path}"

@aslonnie aslonnie force-pushed the lonnie-251013-winfix9 branch from 51474ad to 927a938 Compare October 13, 2025 16:07
out of `util.py`. also adding its own `py_library`

Signed-off-by: Lonnie Liu <[email protected]>
@aslonnie aslonnie force-pushed the lonnie-251013-winfix9 branch from 927a938 to 12abb3a Compare October 13, 2025 16:42
@aslonnie aslonnie merged commit 5e8da1a into master Oct 13, 2025
6 checks passed
@aslonnie aslonnie deleted the lonnie-251013-winfix9 branch October 13, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant