I am running the pipeline.submit()
in AzureML, which has a PythonScriptStep
.
Inside this step, I download a model from tensorflow-hub, retrain it and save it as a .zip
, and finally, I would like to register it in the Azure ML.
But as inside the script I do not have a workspace, Model.register()
is not the case.
So I am trying to use Run.register_model()
method as below:
os.replace(os.path.join('.', archive_name + '.zip'),
os.path.join('.', 'outputs', archive_name + '.zip'))
print(os.listdir('./outputs'))
print('========================')
run_context = Run.get_context()
finetuning_model = run_context.register_model(model_name='finetuning_similarity_model',
model_path=os.path.join(archive_name+'.zip'),
tags={},
description="Finetuning Similarity model")
But then I have got an error:
ErrorResponse { "error": { "message": "Could not locate the provided model_path retrained.zip in the set of files uploaded to the run:
despite I have the retrained .zip
in the ./outputs
dir as we can see from the log:
['retrained.zip']
========================
I guess that I am doing something wrong?
A PythonScriptStep is a basic, built-in step to run a Python Script on a compute target. It takes a script name and other optional parameters like arguments for the script, compute target, inputs and outputs. If no compute target is specified, the default compute target for the workspace is used.
Create an Azure Machine Learning workspace and cloud resources that can be used to train machine learning models.
I was able to fix the same issue (ModelPathNotFoundException
) by explicitly uploading the model into the run history record before trying to register the model:
run.upload_file("outputs/my_model.pickle", "outputs/my_model.pickle")
Which I found surprising because this wasn't mentioned in many of the official examples and according to the upload_file()
documentation:
Runs automatically capture file in the specified output directory, which defaults to "./outputs" for most run types. Use upload_file only when additional files need to be uploaded or an output directory is not specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With