# DataRobotのMLflow連携

> DataRobotのMLflow連携 -
> MLflowからモデルをエクスポートしてDataRobotモデルレジストリにインポートし」、MLflowモデルのトレーニングパラメーター、指標、タグ、アーティファクトからキー値を作成します。

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-07-15T05:55:44.601135+00:00` (UTC).

## Primary page

- [DataRobotのMLflow連携](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [MLflow連携の前提条件](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#prerequisites-for-the-mlflow-integration): In-page section heading.
- [DataRobotのMLflow連携をインストールする](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#install-the-mlflow-integration-for-datarobot): In-page section heading.
- [コマンドラインオプションの設定](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#configure-command-line-options): In-page section heading.
- [環境変数の設定](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#set-environment-variables): In-page section heading.
- [同期アクションを実行して、MLflowからDataRobotにモデルをインポートする](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#run-the-sync-action-to-import-a-model-from-mlflow-into-datarobot): In-page section heading.
- [Azure ADサービスプリンシパルの資格情報のトラブルシューティング](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#troubleshoot-azure-ad-service-principal-credentials): In-page section heading.

## Documentation content

> [!NOTE] 本機能の提供について
> DataRobotでのMLflowとの連携はプレビュー機能です。 この機能を有効にする方法については、DataRobotの担当者または管理者にお問い合わせください。

DataRobotのMLflow連携により、MLflowからモデルをエクスポートしてDataRobot [モデルレジストリ](https://docs.datarobot.com/ja/docs/classic-ui/mlops/deployment/registry/index.html.md) にインポートし、MLflowモデルのトレーニングパラメーター、指標、タグ、アーティファクトから [キー値](https://docs.datarobot.com/ja/docs/classic-ui/mlops/deployment/registry/reg-key-values.html.md) を作成します。

## MLflow連携の前提条件

DataRobotのMLflow連携には、以下が必要です。

- Python >= 3.9
- DataRobot >= 9.0

この統合ライブラリは、プレビュー版のAPIエンドポイントを使用します。APIトークンに関連付けられたDataRobotユーザーは、DataRobotのモデルパッケージに対して オーナー または ユーザー の権限を持っている必要があります。

## DataRobotのMLflow連携をインストールする

`datarobot-mlfow` 連携は `pip` でインストールできます。

```
# pip installation
pip install datarobot-mlflow 
```

Azureで連携を実行している場合は、次のコマンドを使用します。

```
# Azure pip installation
pip install "datarobot-mlflow[azure]" 
```

## コマンドラインオプションの設定

`drflow_cli` では、次のコマンドライン操作を使用できます。

| オプション | 説明 |
| --- | --- |
| --mlflow-url | MLflow追跡URLを定義します。（例：ローカルMLflow："file:///Users/me/mlflow/examples/mlruns"Azure Databricks MLflow："azureml://region.api.azureml.ms/mlflow/v1.0/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.MachineLearningServices/workspaces/azure-ml-workspace-name" |
| --mlflow-model | MLflowモデル名を定義します（"cost-model"など）。 |
| --mlflow-model-version | MLflowモデルバージョンを定義します（"2"など）。 |
| --dr-url | DataRobotインスタンスのメインURLを提供します（https://app.datarobot.comなど）。 |
| --dr-model | キー値アップロードでの登録済みモデルのIDを定義します（64227b4bf82db411c90c3209など）。 |
| --prefix | DataRobotにインポートされたすべてのキー値の名前の前に追加する文字列を指定します。 デフォルト値は空です。 |
| --debug | Pythonログレベルをlogging.DEBUGに設定します。 デフォルトのレベルはlogging.WARNINGです。 |
| --verbose | 以下のプロセス中に情報を標準出力に出力します。MLflowからモデルを取得：モデル情報を出力します。DataRobotでモデルデータを設定：DataRobotに追加された各キー値を出力します。 |
| --with-artifacts | MLflowモデルアーティファクトを/tmp/modelにダウンロードします。 |
| --service-provider-type | validate-authのサービスプロバイダーを定義します。 AzureのDatabricks MLflowでサポートされている値はazure-databricksです。 |
| --auth-type | validate-authの認証タイプを定義します。 Azureサービスプリンシパルでサポートされている値はazure-service-principalです。 |
| --action | DataRobotでMLflow連携を実行する操作を定義します。 |

`--action` オプションでは、次のコマンドライン操作を使用できます。

| アクション | 説明 |
| --- | --- |
| sync | パラメーター、タグ、指標、アーティファクトを、MLflowモデルからキー値としてDataRobotモデルパッケージにインポートします。 このアクションには--mlflow-url、--mlflow-model、--mlflow-model-version、--dr-urlおよび--dr-modelが必要です。 |
| list-mlflow-keys | MLflowモデルのパラメーター、タグ、指標、アーティファクトを一覧表示します。 このアクションには--mlflow-url、--mlflow-modelおよび--mlflow-model-versionが必要です。 |
| validate-auth | トラブルシューティングのために、Azure ADサービスプリンシパルの資格情報を検証します。 このアクションには--auth-typeと--service-provider-typeが必要です。 |

## 環境変数の設定

上記のコマンドラインオプションに加えて、ユースケースに必要な環境変数も指定する必要があります。

| 環境変数 | 説明 |
| --- | --- |
| MLOPS_API_TOKEN | DataRobot APIキー（DataRobot APIのキーとツールにあります）。 |
| AZURE_TENANT_ID | Azure PortalにあるAzure Databricks MLflowインスタンスのAzureテナントID。 |
| AZURE_CLIENT_ID | Azure PortalにあるAzure Databricks MLflowインスタンスのAzureクライアントID。 |
| AZURE_CLIENT_SECRET | Azure PortalにあるAzure Databricks MLflowインスタンスのAzureクライアントシークレット。 |

`export` を使用して、ユースケースに必要な情報をこれらの環境変数に定義できます。

```
export MLOPS_API_TOKEN="<dr-api-key>"
export AZURE_TENANT_ID="<tenant-id>"
export AZURE_CLIENT_ID="<client-id>"
export AZURE_CLIENT_SECRET="<secret>" 
```

## 同期アクションを実行して、MLflowからDataRobotにモデルをインポートする

上で定義したコマンドラインオプションとアクションを使用して、MLflowからMLflowモデル情報をエクスポートし、DataRobotのモデルレジストリにインポートできます。

```
# Import from MLflow
DR_MODEL_ID="<MODEL_PACKAGE_ID>"

env PYTHONPATH=./ \
python datarobot_mlflow/drflow_cli.py \
  --mlflow-url http://localhost:8080 \
  --mlflow-model cost-model  \
  --mlflow-model-version 2 \
  --dr-model $DR_MODEL_ID \
  --dr-url https://app.datarobot.com \
  --with-artifacts \
  --verbose \
  --action sync 
```

このコマンドが正常に実行されると、登録されているモデルバージョンの キー値 タブにMLflow情報が表示されます。

さらに、 キー値 タブの アクティビティログ では、キー値作成イベントのレコードを表示できます。

## Azure ADサービスプリンシパルの資格情報のトラブルシューティング

トラブルシューティングのためにAzure ADサービスプリンシパルの資格情報を検証するには、以下のコマンドライン例を利用できます。

```
# Validate Azure AD Service Principal credentials
export MLOPS_API_TOKEN="n/a"  # not used for Azure auth check, but the environment variable must be present

env PYTHONPATH=./ \
python datarobot_mlflow/drflow_cli.py \
  --verbose \
  --auth-type azure-service-principal \
  --service-provider-type azure-databricks \
  --action validate-auth 
```

[必要な環境変数を設定](https://docs.datarobot.com/ja/docs/api/code-first-tools/mlflow-integration.html.md#environment-variables) していない場合、このコマンドで次の出力を生成する必要があります。

```
# Example output: missing environment variables
Required environment variable is not defined: AZURE_TENANT_ID
Required environment variable is not defined: AZURE_CLIENT_ID
Required environment variable is not defined: AZURE_CLIENT_SECRET
Azure AD Service Principal credentials are not valid; check environment variables 
```

このエラーが表示された場合は、必要なAzure ADサービスプリンシパルの資格情報を環境変数として指定します。

```
# Provide Azure AD Service Principal credentials
export AZURE_TENANT_ID="<tenant-id>"
export AZURE_CLIENT_ID="<client-id>"
export AZURE_CLIENT_SECRET="<secret>" 
```

Azure ADサービスプリンシパルの資格情報の環境変数が定義されると、以下の出力が表示されます。

```
# Example output: successful authentication
Azure AD Service Principal credentials are valid for obtaining access token 
```
