-
Notifications
You must be signed in to change notification settings - Fork 8
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
Have AlchemiscaleClient
automatically pull settings from the environment
#355
Comments
Is your proposal that
Would just work if those environment variables exist? |
Thanks @jthorton! I've added this to the 0.6.1 milestone! |
Hi! Wanted to clarify something before I address this issue: AFAIC when both an environment variable and an explicit argument are provided, the argument should take precedence. In such cases, we should issue warnings to notify the user of stale environment variable. import os
from alchemiscale import AlchemiscaleClient
client = AlchemiscaleClient(api_url="someurl", key="somekey", identifier="someid")
# stderr
.../client.py:69: UserWarning: Environment variable ALCHEMISCALE_URL is set to "someotherurl", but an explicit URL ("someurl") was provided. Using the explicit URL.
.../client.py: UserWarning: Environment variable ALCHEMISCALE_KEY is set, but an explicit key argument was provided. Using the explicit key.
.../client.py: UserWarning: Environment variable ALCHEMISCALE_ID is set to "someotherid", but an explicit identifier ("someid") was provided. Using the explicit identifier. What do you think? |
The commit adds support for initializing AlchemiscaleClient with environment variables, allowing configuration via ALCHEMISCALE_URL, ALCHEMISCALE_ID, and ALCHEMISCALE_KEY Adds test for this behavior Closes OpenFreeEnergy#355
The commit adds support for initializing AlchemiscaleClient with environment variables, allowing configuration via ALCHEMISCALE_URL, ALCHEMISCALE_ID, and ALCHEMISCALE_KEY Adds test for this behavior Closes OpenFreeEnergy#355
I currently store my alchemiscale key, identifier and url in environment variables and find that I often have to write the same bit of code to get them from the environment and create the client object like so
however it would be great if we could have the client do this automatically if the variables are present. We currently do this in asap-alchemy which helps when building a CLI which interacts with alchemiscale. Porting this to alchemiscale would be great and save packages from reimplementing this.
In broad terms, what are you trying to do?
Briefly detail what you have already tried
Describe the new feature(s) that would help you to achieve this
The text was updated successfully, but these errors were encountered: