1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Copy a ML Model from one Azure Databricks workspace to another Databricks Workspace

Discussão em 'Python' iniciado por Stack, Outubro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I ran the below code to export the ML Model in Azure Databricks based mlflow but I seem to be getting this error "MLflow host or token is not configured correctly".

    I'm unable to figure out what the issue is. The URL for the workspace is correct along with the PAT Token.

    The export_import tools is very buggy. It expects mlfow library but what comes with Databricks ML Runtime is mlflow-skinny.

    import mlflow
    import os
    from mlflow_export_import.model.export_model import ModelExporter
    from mlflow.tracking import MlflowClient

    # Set the Databricks MLflow tracking URI with the workspace URL
    mlflow.set_tracking_uri("https://adb-xxxyyymmmnnnyyy.1.azuredatabricks.net/")

    # Set both tokens for compatibility
    os.environ["DATABRICKS_TOKEN"] = "mnop6672ec8e20c7d219eb2A-3"
    os.environ["MLFLOW_TRACKING_TOKEN"] = "mnop6672ec8e20c7d219eb2A-3"

    # Initialize the MLflow client (no need to pass tracking URI as it's set globally)
    mlflow_client = MlflowClient()

    # Initialize the ModelExporter with the MLflow client
    exporter = ModelExporter(mlflow_client)

    # Export the model
    exporter.export_model(
    model_name="Signature_Test",
    output_dir="/tmp/mlflow_export/model",
    stages=None, # Use "None" to export all stages, or specify "Staging" or "Production"
    export_metadata_tags=True
    )

    Continue reading...

Compartilhe esta Página