Skip to content

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

Merged
David Tesar (dtzar) merged 8 commits into
microsoft:masterfrom
celaus:cm/rebuild-environment-flag
Mar 16, 2020
Merged

Added an environment variable flag to recreate the AMLS Environment#230
David Tesar (dtzar) merged 8 commits into
microsoft:masterfrom
celaus:cm/rebuild-environment-flag

Conversation

@celaus

Copy link
Copy Markdown
Contributor

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

@dtzar David Tesar (dtzar) left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread ml_service/util/env_variables.py Outdated
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
Copy Markdown
Contributor

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

# 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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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. Sushant Divate (@sudivate) thoughts?

@sudivate Sushant Divate (sudivate) Mar 13, 2020

Copy link
Copy Markdown
Contributor

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

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
David Tesar (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