Skip to content

Commit

Permalink
Improve getting environment in helper script. (#2560)
Browse files Browse the repository at this point in the history
* Fix environment

* Fix regression-explanation-featurization

* Fix loading of environments

* Fix linting
  • Loading branch information
nick863 authored Aug 16, 2023
1 parent 276eb40 commit 4e27231
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import pandas as pd
from azureml.core import Environment, ScriptRunConfig
from azureml.core.run import Run
Expand All @@ -13,7 +14,16 @@ def run_inference(
model_name,
):

inference_env = train_run.get_environment()
try:
inference_env = train_run.get_environment()
except BaseException:
run_details = train_run.get_details()
run_def = run_details.get("runDefinition")
env = run_def.get("environment")
if env is None:
raise
json.dump(env, open("azureml_environment.json", "w"))
inference_env = Environment.load_from_directory(".")

est = ScriptRunConfig(
source_directory=script_folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,10 @@
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Environment\n",
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import json\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
Expand All @@ -513,7 +515,16 @@
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"# specify CondaDependencies obj\n",
"conda_run_config.environment = automl_run.get_environment()"
"try:\n",
" conda_run_config.environment = automl_run.get_environment()\n",
"except BaseException:\n",
" run_details = automl_run.get_details()\n",
" run_def = run_details.get(\"runDefinition\")\n",
" env = run_def.get(\"environment\")\n",
" if env is None:\n",
" raise\n",
" json.dump(env, open(\"azureml_environment.json\", \"w\"))\n",
" conda_run_config.environment = Environment.load_from_directory(\".\")"
]
},
{
Expand Down Expand Up @@ -909,7 +920,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.8.7"
},
"tags": [
"featurization",
Expand Down

0 comments on commit 4e27231

Please sign in to comment.