2

I was trying to register a model using the Run Class like this:

model = run.register_model(
    model_name=model_name,
    model_path=model_path)

Errors with message: Could not locate the provided model_path ... in the set of files uploaded to the run...

nferreira78
  • 1,013
  • 4
  • 17

2 Answers2

1

The only way I found to fix the issue was to use the Model Class instead:

        model = Model.register(
            workspace=ws,
            model_name=model_name,
            model_path=model_path,
            model_framework=Model.Framework.SCIKITLEARN,
            model_framework_version=sklearn.__version__,
            description='Model Deescription',
            tags={'Name' : 'ModelName', 'Type' : 'Production'},
            model_framework=Model.Framework.SCIKITLEARN,
            model_framework_version='1.0'
            )
nferreira78
  • 1,013
  • 4
  • 17
1

I think the problem is that you rely on AML background process to automatically upload content under ./outputs to AML workspace. But when the upload is not complete and we immediately call run.register_model which takes the content from AML workspace then the error will happen. To avoid that situation, you can do it like this:

  • Persist model (joblib.dump) to a custom folder other than outputs
  • Manually run upload_file to upload the model AML workspace. Name the destination same name with your model file.
  • Then run run.register_model.
Ram
  • 2,459
  • 1
  • 7
  • 14
  • actually I was uploading the file using `run.upload_file(model_name, model_path, datastore_name=None)` before using the `run.register_model()` method. So, I wasn't relying on AML background to automatically upload the ./outputs content. But, what is different in my case is that I am persisting the model directly to `./outputs` folder. I can test it saving it to another custom folder as you suggest. Also, why is it crucial to name the destination (you mean the model right?) same as the model file? Thanks – nferreira78 Feb 01 '22 at 15:39