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

Added an environment variable flag to recreate the AMLS Environment #230

Merged
merged 8 commits into from
Mar 16, 2020

Conversation

celaus
Copy link
Contributor

@celaus celaus commented Mar 11, 2020

Fixes #229 by allowing the AML Environment to be recreated instead of reused.

Copy link
Member

@dtzar dtzar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please add AML_REBUILD_ENVIRONMENT to the .env.example and variables.yml (commented out) with a comment explaining what it does.

@@ -46,6 +46,8 @@ def __init__(self):
self._allow_run_cancel = os.environ.get(
"ALLOW_RUN_CANCEL", "true")
self._aml_env_name = os.environ.get("AML_ENV_NAME")
self._rebuild_env = os.environ.get("AML_REBUILD_ENVIRONMENT", "true").lower().strip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set to false by default

@@ -31,7 +31,7 @@ def main():
# Make sure to include `r-essentials'
# in diabetes_regression/conda_dependencies.yml
environment = get_environment(
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501
aml_workspace, e.aml_env_name, create_new=e.rebuild_env == "true") # NOQA: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the == "true" so it can just be whatever the actual value is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't understand: the environment variables are not well-typed (i.e. they are strings). In that case the flag would evaluate to true all the time (as a non-empty string). Just like here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have to check with an actual run or dig into the SDK, but I'm betting the create_new=False will be ok with False as a string (it's not checking it as a boolean).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the variable should be boolean, (see here) and Python will convert any type to boolean, but with unexpected results :)

so the check for the "true" string is vital here for this to work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative solution could be to use a library like https://pypi.org/project/environs/ to type the environment variables properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environs looks cool, but I don't really want to introduce a new dependency right now. @sudivate thoughts?

Copy link
Contributor

@sudivate sudivate Mar 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, for the scope of this PR lets typecast the string to bool in env_variables.py

@@ -33,8 +33,7 @@ def main():

# Create a reusable Azure ML environment
environment = get_environment(
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501

aml_workspace, e.aml_env_name, create_new=e.rebuild_env == "true") #
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the == "true" so it can just be whatever the actual value is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't understand: the environment variables are not well-typed (i.e. they are strings). In that case the flag would evaluate to true all the time (as a non-empty string). Just like here

(same as above)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. It's confusing in Python. I would update env_variables.py to return a boolean (not string) value. E.g. return self._rebuild_env == "true"

@dtzar dtzar merged commit 1d2d773 into microsoft:master Mar 16, 2020
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 this pull request may close these issues.

Environment does not update on change
4 participants