mlflow / mlflow-export-import

Apache License 2.0
131 stars 77 forks source link

importing a specific model version is not preserving the model versions #183

Open paravatha opened 3 months ago

paravatha commented 3 months ago

while trying to export and import a specific model (version 2), the model version is being imported as (version 1) version.json image

Code to import

        model_name = model_metadata["model_name"]
        import_model_version(
            model_name=model_name,
            experiment_name=model_metadata["experiment_name"],
            create_model=True,
            import_source_tags=True,
            import_metadata=True,
            import_stages_and_aliases=True,
            input_dir=f"{input_dir_prefix}/{model_name}",
        )

I believe this code snippet is creating a model with version 1


    # NOTE: MLflow UC bug:
    # The client's tracking_uri is not honored. Instead MlflowClient.create_model_version()
    # seems to use mlflow.tracking_uri internally to download run artifacts for UC models.
    with MlflowTrackingUriTweak(mlflow_client):
        dst_vr = mlflow_client.create_model_version(
            name = model_name,
            source = dst_source,
            run_id = dst_run_id,
            description = src_vr.get("description"),
            tags = tags
        )
paravatha commented 3 months ago

@amesar referring to this comment https://github.com/mlflow/mlflow-export-import/issues/50#issuecomment-1331606294 Is this still the case? I am wondering if there a way around to preserve model version number as we export and import model versions

However, if the source server has model versions 1,2,3 and 4, and you export 2 and 4, your imported destination versions will be 1 and 2.