If you are trying to register and fit the best model from all child jobs in SDK v2, You can refer below code.
It fetches the run id of best child job with "automl_best_child_run" then download the artifacts and register the mlflow model from the artifacts.
# Get the best model's child run
best_child_run_id = mlflow_parent_run.data.tags["automl_best_child_run_id"]
print(f"Found best child run id: {best_child_run_id}")
best_run = mlflow_client.get_run(best_child_run_id)
print("Best child run: ")
print(best_run)
# Create local folder
local_dir = "./artifact_downloads"
if not os.path.exists(local_dir):
os.mkdir(local_dir)
# Download run's artifacts/outputs
local_path = mlflow_client.download_artifacts(
best_run.info.run_id, "outputs", local_dir
)
print(f"Artifacts downloaded in: {local_path}")
print(f"Artifacts: {os.listdir(local_path)}")
#registers model from job artifacts
model_name = "od-fridge-items-mlflow-model"
model = Model(
path=f"azureml://jobs/{best_run.info.run_id}/outputs/artifacts/outputs/mlflow-model/",
name=model_name,
description="my sample object detection model",
type=AssetTypes.MLFLOW_MODEL,
)
# for downloaded file
# model = Model(
# path=mlflow_model_dir,
# name=model_name,
# description="my sample object detection model",
# type=AssetTypes.MLFLOW_MODEL,
# )
registered_model = ml_client.models.create_or_update(model)
Reference used -
I think we can change the tag to tag of other child job to download respective model artifact. From UI, we can download all models from models and Job tab of parent job
Trying to repro and update you. Please allow us some time.
Thank you.