-
Notifications
You must be signed in to change notification settings - Fork 114
Fix missing kwargs injection on put calls #456
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
Fix missing kwargs injection on put calls #456
Conversation
|
@TomAugspurger would you mind to consider merging this one for some of the next releases? Without it, if someone wants to use put and, for instance, set tags and content-type for the blob, the user would have to issue two additional requests ( If the change is too small or you need anything else, please let me know. |
|
This would be really great for me as well. I'd love to be able to put objects with tags. s3fs does something like this and also provides a distinct interface for getting and setting tags on objects. Is there any interest in getting this PR merged? How can we move this forward? |
|
It also feels like there is some precedent with #392 getting merged. Why can we set tags using |
|
@kyleknap , ok with you? I think the point of maybe implementing the attr methods is also fair, although I don't know if you can simply change the metadata in azure (I assume you can). |
|
@martindurant I'm ok with the change of proxying the kwargs to the fs.upload_file(
'local-file',
'blob-name',
upload_blob_kwargs={
"tags": {
"tag1": "val1"
}
}this would ensure that if we want to add any future keyword arguments that we expose won't collide with any Azure SDK keyword arguments, but it does make it more verbose. That being said, given
Yeah tags can be set through separate API calls with the Azure SDK. I'm open to exposing it given Otherwise, for this PR, it would be great if we could get a test added for both |
|
Sure. Today is kinda busy, but I can get it done by the weekend. |
|
@kyleknap Today wasn't that busy after all =] Azurite still doesn't fully support tags, so I had to mock the call to |
|
@rodrigoberriel thanks! That's a bummer on the tag support. Does azurite support the content settings/content type? I'm also fine with not including tags as part of the test case and we can just assert the content type matches what we uploaded. If so, that can help us avoid needing to use mocks/patching and simplify the test case a bit more. I don't have a strong preference on this. So, let us know. Otherwise, I plan to pull down the PR today to try it out and get a full review in. |
|
@kyleknap it does support it. I've updated the test. |
kyleknap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigoberriel This looks good to me! I also confirmed that it was working correctly with tags when trying it out. A couple of updates we probably should add as well before merging:
- Let's rebase the PR off of main (or merging main into this branch works too). Mainly in order to get the tests to pass using the latest version of the Azure SDK there's a fix we made to the CI earlier this year that we'll want to pull in.
- Once updated with main, let's add a changelog entry for it in this section. I think we can keep it to a sentence to call out that we proxy these keyword arguments now to the Azure Blob SDK client to support content settings, tags, etc.
Afterwords @martindurant I think we should be set to enable CI for the pull request to make sure CI passes and get the PR merged assuming you are good with the change too!
|
I enabled CI now, and can do again following changes. |
16417c6 to
2ee1015
Compare
|
Rebased, squashed, and updated the changelog. |
adlfs/tests/test_spec.py
Outdated
| assert all( | ||
| (k in blob_info["content_settings"] and blob_info["content_settings"][k] == v) | ||
| for k, v in content_settings.items() | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fixing the CI failures, we can go ahead and simplify the assertions to just:
assert blob_info["content_settings"]["content_type"] == "application/json"
assert blob_info["content_settings"]["content_encoding"] == "UTF-8"It looks like for older versions of the Azure Blob SDK it does not handle in well for content_settings
2ee1015 to
d42a634
Compare
d42a634 to
80b589a
Compare
kyleknap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! @martindurant we should be good to re-enable CI and get it merged.
While #392 was supposed to fix #294, it did not. When uploading a file using
fs.put,kwargsis still not being forwarded, because these calls are passed to_put_filewhich does not rely on_pipe, unlikewrite_*calls.This PR is very simple: also injects kwargs on
bc.upload_blobfor the_put_filecalls.