Can't convert Estimator params to runconfig yaml for use in a PythonScriptStep
Original Problem
We had a PythonScript step in our pipeline that was taking over an hour. It was a huge pain point for development and releases given that we are using our DevOps build agent to synchronously validate successful PipelineRuns.
My issue comes down to a fundamental knowledge gap about the relationship between Estimators and ScriptRunConfigs
Actions Taken so far
- ported the code to pyspark and got it to run as a one-off Estimator run using an mmlspark Docker image
- I spent 10 hours yesterday trying to port the code to a
PythonScriptStepusing a runconfig built from a YML.
Trying to use a Docker cluster provisioned with a mmlspark as a compute for a PythonScriptStep as such:
roll_step=PythonScriptStep(
name='roll',
script_name='roll.py',
arguments=['--input_dir', joined_data,
'--output_dir', rolled_data,
'--script_dir', "",
'--min_date', '2015-06-30'],
compute_target=compute_target_spark,
inputs=[joined_data],
outputs=[rolled_data],
runconfig=aml_compute_spark,
source_directory=os.path.join(os.getcwd(), 'compute'),
allow_reuse=pipeline_reuse
)
and am getting the error below:
run_id=40fb44e6-c37c-4548-8209-ebaffe06bdd3
Traceback (most recent call last):
File "azureml-setup/start_standalone_spark.py", line 41, in <module>
get_master_ip(), "--webui-port", "8080"])
File "/mnt/batch/tasks/shared/LS_root/jobs/avadevitsmlsvc/azureml/40fb44e6-c37c-4548-8209-ebaffe06bdd3/mounts/azureml_project_share/azureml/40fb44e6-c37c-4548-8209-ebaffe06bdd3/azureml-setup/standalone_spark_utilities.py", line 13, in get_master_ip
raise ValueError('Failed to get azure batch cluster master node IP address from BatchAI.')
ValueError: Failed to get azure batch cluster master node IP address from BatchAI.
What is challenging to me is that I can get it running with an Estimator, but not as a PythonScriptStep, or even a ScriptRunConfig.
est_config_roll_test = Estimator(
source_directory = "./compute",
entry_script= "roll_spark.py",
script_params = {
'--input_dir': input_blob,
'--output_dir': input_blob,
'--script_dir': "."
},
compute_target=compute_target,
node_count=2,
process_count_per_node=1,
distributed_backend='mpi',
use_gpu=True,
pip_packages=['pyspark','pandas', 'numpy'],
custom_docker_base_image='microsoft/mmlspark:gpu-0.12',
)
Here's my runconfig yml
Can you use an EstimatorStep? This should allow you to run your Estimator as a Step in a Pipeline.
Since you already have Estimator working, you can try EstimatorStep: Docs for Estimator: https://docs.microsoft.com/en-us/python/api/azureml-pipeline-steps/azureml.pipeline.steps.estimator_step.estimatorstep?view=azure-ml-py Sample notebook: https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-estimatorstep.ipynb
Hi @elihop22 and @sonnypark, I really appreciate the help, I've been drive half insane trying to make this work.
I can get the Estimator to work consistently a one-off run.
However, if I do the simple wrapping of creating a 1 step pipeline with EstimatorStep, I'm getting a image build failed at step 13/15. with `unresolved dependency.
Here's a gist with the log file and an ipynb of the one-step test pipeline. Thanks in advance!
Estimator
code
roll_estimator = Estimator(
source_directory = "./compute",
entry_script= "roll.py",
script_params = {
'--input_dir': input_blob,
'--output_dir': output_spot,
'--script_dir': "."},
compute_target=compute_target_spark2,
node_count=2,
process_count_per_node=1,
distributed_backend='mpi',
use_gpu=True,
pip_packages=['pyspark','pandas', 'numpy'],
custom_docker_base_image='microsoft/mmlspark:gpu-0.12'
)
run = exp.submit(est_config_roll_test, show_output=True)
RunDetails(run).show()
working as expected (twice)
run_id=attrition-compute_test_1559261824_955229c2
run_id=attrition-compute_test_1559264250_ff72a029

EstimatorStep
run_id=dfa63991-96e7-455f-8029-2323f93827ed
ds_pipeline = Datastore.get(ws, datastore_name='attrition_pipeline_blob')
joined_data=PipelineData('joined_data', datastore=ds_pipeline)
roll_step = EstimatorStep(
name="rolling features",
estimator=roll_estimator,
estimator_entry_script_arguments=[
'--input_dir', input_blob,
'--output_dir', joined_data,
'--script_dir', ".",
'--min_date', '2015-06-30'
],
runconfig_pipeline_params=None,
inputs=[input_blob],
outputs=[joined_data],
compute_target=compute_target_spark2,
allow_reuse=pipeline_reuse
)
pipeline=Pipeline(workspace=ws, steps=[roll_step])
pipeline_run=(Experiment(ws, project_name).submit(pipeline)
RunDetails(pipeline_run).show()
Excerpt of 20_image_build_log.txt
run_id=dfa63991-96e7-455f-8029-2323f93827ed
Step 13/15 : RUN if [ $SPARK_HOME ]; then /bin/bash -c '$SPARK_HOME/bin/spark-submit "--repositories" "['https://mmlspark.azureedge.net/maven']" "--packages" "com.microsoft.ml.spark:mmlspark_2.11:0.12" /azureml-setup/spark_cache.py'; fi
---> Running in 28b277c09808
[91m[https://mmlspark.azureedge.net/maven] added as a remote repository with the name: repo-1
[0m[91mIvy Default Cache set to: /root/.ivy2/cache
The jars for the packages stored in: /root/.ivy2/jars
[0m[91m:: loading settings :: url = jar:file:/home/mmlspark/lib/spark/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[0m[91mcom.microsoft.ml.spark#mmlspark_2.11 added as a dependency
[0m[91m:: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0
confs: [default]
[0m[91m:: resolution report :: resolve 663ms :: artifacts dl 0ms[0m[91m
[0m[91m :: modules in use:[0m[91m
[0m[91m ---------------------------------------------------------------------[0m[91m
[0m[91m | | modules || artifacts |[0m[91m
[0m[91m | conf | number| search|dwnlded|evicted|| number|dwnlded|[0m[91m
[0m[91m ---------------------------------------------------------------------[0m[91m
[0m[91m | default | 1 | 0 | 0 | 0 || 0 | 0 |[0m[91m
[0m[91m ---------------------------------------------------------------------[0m[91m
[0m[91m
[0m[91m:: problems summary ::[0m[91m
[0m[91m:::: WARNINGS[0m[91m
[0m[91m ::::::::::::::::::::::::::::::::::::::::::::::
[0m[91m
[0m[91m :: UNRESOLVED DEPENDENCIES ::
[0m[91m
[0m[91m ::::::::::::::::::::::::::::::::::::::::::::::
[0m[91m
[0m[91m :: com.microsoft.ml.spark#mmlspark_2.11;0.12: repo-1: unable to get resource for com/microsoft/ml/spark#mmlspark_2.11;0.12: res=[https://mmlspark.azureedge.net/maven]/com/microsoft/ml/spark/mmlspark_2.11/0.12/mmlspark_2.11-0.12.pom: java.net.MalformedURLException: no protocol: [https://mmlspark.azureedge.net/maven]/com/microsoft/ml/spark/mmlspark_2.11/0.12/mmlspark_2.11-0.12.pom
[0m[91m
[0m[91m ::::::::::::::::::::::::::::::::::::::::::::::
[0m[91m
[0m[91m
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS[0m[91m
[0m[91mException in thread "main" [0m[91mjava.lang.RuntimeException: [unresolved dependency: com.microsoft.ml.spark#mmlspark_2.11;0.12: repo-1: unable to get resource for com/microsoft/ml/spark#mmlspark_2.11;0.12: res=[https://mmlspark.azureedge.net/maven]/com/microsoft/ml/spark/mmlspark_2.11/0.12/mmlspark_2.11-0.12.pom: java.net.MalformedURLException: no protocol: [https://mmlspark.azureedge.net/maven]/com/microsoft/ml/spark/mmlspark_2.11/0.12/mmlspark_2.11-0.12.pom][0m[91m
[0m[91m at org.apache.spark.deploy.SparkSubmitUtils$.resolveMavenCoordinates(SparkSubmit.scala:1197)[0m[91m
[0m[91m at org.apache.spark.deploy.SparkSubmit$.prepareSubmitEnvironment(SparkSubmit.scala:304)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:153)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:119)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
[0mThe command '/bin/sh -c if [ $SPARK_HOME ]; then /bin/bash -c '$SPARK_HOME/bin/spark-submit "--repositories" "['https://mmlspark.azureedge.net/maven']" "--packages" "com.microsoft.ml.spark:mmlspark_2.11:0.12" /azureml-setup/spark_cache.py'; fi' returned a non-zero code: 1
2019/05/31 01:19:17 Container failed during run: acb_step_0. No retries remaining.
failed to run step ID: acb_step_0: exit status 1
Run ID: cc4k failed after 3m5s. Error: failed during run, err: exit status 1
@sonnypark @elihop22 I've got a great reproducible example.
- Run the
aml-pipelines-getting-startednotebook to upload the20news.pklfile (not really needed but minimizing the amount of code that needs to be changed) - Run the
aml-pipelines-how-to-use-estimatorstepnotebook but instead ofconda_packages=['scikit-learn'], providepip_packages=['pyspark', 'pandas', 'scikit-learn'] - They very same image build failure as above.
Hey @swanderz,
We tried your repro steps and didn't end up with image build failure. Can you please upgrade your sdk and try again? I noticed that you are running a few month old version of azureml-sdk. In your screenshot you are passing custom_docker_base_image as a parameter. That got changed to custom_docker_image around mid Feb.
@swanderz I realize you have been using .10 for a while. Do you think you can upgrade now? We can help sort out issues if there are any.
Thanks for all the help everyone. I'm on 1.0.41 now finding and even more troubling issue.
I can successfully submit a PipelineRun that completes using standalone_pipeline.ipynb but not our whole pipeline up to and including the EstimatorStep with pipeline41.py.
I feel like a crazy person, I'm sure it's a typo on my end.... right?
pipeline41.py fails at the EstimatorStep definition -- here's the traceback.
Here's a link to the gist with both.
Azure ML SDK Version: 1.0.41
Found workspace avadevitsmlsvc at location westus2
Experiment: attrition-compute_test
Found existing cluster,attrition-comput,use it.
Found existing cluster,holy-roller,use it.
WARNING - 'distributed_backend' parameter will be deprecated. Please use 'distributed_training' instead.
Traceback (most recent call last):
File "pipeline41.py", line 282, in <module>
custom_docker_image='microsoft/mmlspark:gpu-0.12'
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\site-packages\azureml\core\_experiment_method.py", line 93, in wrapper
return init_func(self, *args, **kwargs)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\site-packages\azureml\train\estimator.py", line 865, in __init__
max_run_duration_seconds=max_run_duration_seconds)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\site-packages\azureml\train\_estimator_helper.py", line 93, in _init_run_config
arguments = _get_arguments(script_params)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\site-packages\azureml\train\_estimator_helper.py", line 352, in _get_arguments
script_params_copy = copy.deepcopy(script_params)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 150, in deepcopy
y = copier(x, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 150, in deepcopy
y = copier(x, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 150, in deepcopy
y = copier(x, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copy.py", line 274, in _reconstruct
y = func(*args)
File "C:\Users\anders.swanson\AppData\Local\Continuum\miniconda3\lib\copyreg.py", line 88, in __newobj__
return cls.__new__(cls, *args)
TypeError: __new__() missing 2 required positional arguments: 'workspace' and 'name'
Thanks for hitting this bug :).
Can you please omit supplying the script_params to Estimator and only supply them using estimator_entry_script_arguments to the EstimatorStep?
Also, i noticed that you are using an mpi backend. You can use the MpiStep which would forego the need to instantiate an Estimator.
Woof. My weekend will be considerably more enjoyable now that:
- the week-long bug is squashed, and
- our longest running pipeline step now runs 22X faster.
The key was:
- bite the bullet and upgrade to
1.0.41(btw @j-martens no.41release notes yet, only.39) - workaround on the
EstimatorStep'sentry_script_paramsnot overwritingEstimator'sscript_params
Can't say thanks enough for the consistent help & support. Kudos to @hchandola @elihop22 @sonnypark @sanpil @mahder and everyone else on the AML team! p.s. I'm wearing my AML t-shirt today.
Ugh. Hate to do this, but I'm finding that the run isn't failing like it should. I forgot the add findspark to the dependencies. Which was logged in the azureml.log at 23:08 and yet the execution_log is still reporting: "Running"
[2019-05-31 23:19:43Z] Job is running, job runstatus is Running
As it is a StepRun I cannot cancel the run through the portal.
run_id=64f04c6c-8001-478f-b0f9-b3015d09df68
.

I broke out the new, separate issues into new ones, #407 and #408, because this particular issue was resolved. @sanpil perhaps this issue stays open until the bug that @hchandola flagged gets released?
@hchandola @sanpil has this bug been addressed?
Yes, the bug has been fixed in the latest pypi.