Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying metadata for azure uploads #701

Closed
3 tasks done
ddelange opened this issue Jun 22, 2022 · 0 comments · Fixed by #702
Closed
3 tasks done

Allow specifying metadata for azure uploads #701

ddelange opened this issue Jun 22, 2022 · 0 comments · Fixed by #702

Comments

@ddelange
Copy link
Contributor

ddelange commented Jun 22, 2022

Problem description

I would like to upload an Azure blob with metadata. This is currently possible with s3 and gcs:

metadata = {"name": "bla"}
bucket = "test"
key = "test"
open(
    f"s3://{bucket}/{key}",
    "wb",
    transport_params={
        "client_kwargs": {"S3.Client.create_multipart_upload": {"Metadata": metadata},
    },
)
open(
    f"gs://{bucket}/{key}",
    "wb",
    transport_params={
        "blob_properties": {"metadata": metadata},
    },
)

For Azure, smart_open only has the possibility of passing a custom BlobClient but it looks like metadata needs to be explicitly passed to BlobClient.commit_block_list.

I suggest introducing blob_kwargs:

open(
    f"azure://{container}/{path}",
    "wb",
    transport_params={
        "blob_kwargs": {"metadata": metadata},
    },
)

Steps/code to reproduce the problem

N/A

Versions

Please provide the output of:

>>> import platform, sys, smart_open
>>> print(platform.platform())
>>> print("Python", sys.version)
>>> print("smart_open", smart_open.__version__)
macOS-10.15.7-x86_64-i386-64bit
Python 3.8.10 (default, Sep  1 2021, 10:14:33)
[Clang 12.0.0 (clang-1200.0.32.29)]
smart_open 6.0.0

Checklist

Before you create the issue, please make sure you have:

  • Described the problem clearly
  • Provided a minimal reproducible example, including any required data
  • Provided the version numbers of the relevant software
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 a pull request may close this issue.

1 participant