-
Notifications
You must be signed in to change notification settings - Fork 64
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
Instantiate default client lazily #428
Comments
Seems reasonable, thanks for the issue. Happy to take a PR or tackle this sometime in the near future. Implementation is probably pretty straightforward and looks like:
Here's the relevant block in cloudpathlib/cloudpathlib/cloudpath.py Lines 225 to 237 in fabb0e4
|
@iamhatesz This is realeased now in v0.19.0 if you want to upgrade and test your use case. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I've refactored my code and moved from s3path to
cloudpathlib
to support S3 and GCS backends. Everything works great except that clients are created in constructors, possibly when credentials are not yet available.Here's an example:
If I call
load_dotenv
before definingUPLOADS_PATH
it works, but that's not a good practice.I worked around this by making them functions:
but it is an extra boilerplate and also requires changes to the code.
Would it be possible to delay the instantiation of the client class, e.g. to the moment of the first call that actually requires it? I think this is the way it works in
s3path
since it worked for me for a very long time.The text was updated successfully, but these errors were encountered: