-
Notifications
You must be signed in to change notification settings - Fork 274
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 credentials in client kwargs #308
allow credentials in client kwargs #308
Conversation
Sorry if I am being dense, but what's the purpose of passing the credentials kwargs in client_kwargs rather than the current mechanism? |
Although it is always possible to use the native arguments, I think it would be good to allow this alternative usage pattern as well. |
OK, you make a good argument. |
It would be good to add wording to the docstring abut the parameter priority. |
Hmmm I didn't touch test_s3_glob at all though. I'll just add
If you would like me to explicitly raise a more descriptive error, please advise on what error to raise and what the message should be. |
There was a bug in the version checking logic. So tests weren't skipping for py35. Fixed it. |
I think that's good now, thanks! |
Since 0.4.1 I am unable to provide credentials via the client_kwargs argument.
This was caused by the following change in s3fs.core (lines 292-293):
My PR would allow the use of either using the arguments (
key
,secret
,token
) or theclient_kwargs
.It would also allow a combination of both. E.g. key + client_kwargs['aws_secret_access_key']
I do allow repeating the same argument in both (e.g. key + aws_access_key_id) as long as they have the same value, but would raise exception if they have conflicting values (will raise same TypeError: multiple values for kwarg). I also added tests to check this behaviour.
There were other options to choose from so please advise if you prefer one of the following:
key
,secret
,token
) overclient_kwargs
client_kwargs
over init argsIf choosing between 2 or 3, I would favour 2 since those are more explicit, as client_kwargs could be some defaults loaded from some file. However 3 is more consistent with
S3FileSystem._prepare_config_kwargs
.Ultimately I prefer my current solution to let it fail, so it would help the user debug if unintentional, while users can handle their own defaulting logic if needed.
Since use_ssl defaults to True, it is impossible to tell if the user explicitly sets it as True or it is defaulted to True. So I give priority to
client_kwargs
(as perS3FileSystem._prepare_config_kwargs
). i.e. S3FileSystem(use_ssl=True, client_kwargs={'use_ssl': False}) would setuse_ssl
toFalse
.I also ensured that if anon==True, it would disregard the credentials in client_kwargs as is currently the case with
key
,secret
&token
.I also cleared up some unused/unnecessary line of code (s3fs.core: 275)
I hope you accept this PR because the change in 0.4.1 was breaking some other 3rd party library that was relying on passing credentials via client_kwargs.