Skip to content

アプリケーション内で をクリックすると、お使いのDataRobotバージョンに関する全プラットフォームドキュメントにアクセスできます。

管理エージェントのインストールと設定

MLOpsエージェントの.tarファイルには、管理エージェントの実行に必要なすべてのアーティファクトが含まれています。 管理エージェントは、次の設定のいずれかで実行できます。

  • コンテナ内。
  • ホストマシン上で、スタンドアロンプロセスとして。
  1. 管理エージェントコンテナをビルドしてインストールするには、次のコマンドを実行してtarballを適切な場所に解凍し、コンテナイメージをビルドします。

    tar -zxf datarobot_mlops_package-*.tar.gz
    cd datarobot_mlops_package-*/
    cd tools/bosun_docker/
    make build 
    

    これにより、管理エージェントイメージに適切なversionタグとlatestタグが付けられます。

  2. 管理エージェントのイメージをビルドし、コマンドラインから管理エージェントを設定できるようにコンテナを実行するには、次のコマンドを実行します。

    tar -zxf datarobot_mlops_package-*.tar.gz
    cd datarobot_mlops_package-*/
    cd tools/bosun_docker/
    make run 
    
  3. mlopsUrlapiToken、および監視する予測環境のIDを入力します。

    Generate MLOps Management-Agent configuration file.
    Enter DataRobot App URL (e.g. https://app.datarobot.com): <https://<MLOPS_HOST>>
    Enter DataRobot API Token: <MLOPS_API_TOKEN>
    Enter DataRobot Prediction Environment ID: <MLOPS_PREDICTION_ENVIRONMENT_ID> 
    

    デフォルトでは、管理エージェントはファイルシステムプラグインを使用します。 別のプラグインを使用する場合は、管理エージェントの設定ファイルでそのプラグインを使用するように設定してから、コンテナにマッビングできます。

    たとえば、次のコマンドを使用すると、Kubernetesプラグインで管理エージェントを実行できます。

    cd datarobot_mlops_package-*/
    docker run -it \
    -v conf/mlops.bosun.conf.yaml:/opt/datarobot/mlops/bosun/conf/mlops.bosun.conf.yaml \
    -v conf/plugin.k8s.conf.yaml:/opt/datarobot/mlops/bosun/conf/plugin.k8s.conf.yaml \
    datarobot/mlops-management-agent 
    
  1. 管理エージェントをホストマシンにインストールして実行するには、Python 3.7以降およびJava 11がシステムにインストールされている必要があります。 次に、Python仮想環境を作成して、管理エージェントプラグインをインストールできます。

    mkdir /opt/management-agent-demo
    cd /opt/management-agent-demo
    python3 -m venv .venv
    source .venv/bin/activate
    tar -zxf datarobot_mlops_package-*.tar.gz
    cd datarobot_mlops_package-*/
    pip install lib/datarobot_mlops-*-py2.py3-none-any.whl
    pip install lib/datarobot_mlops_connected_client-*-py3-none-any.whl
    pip install lib/datarobot_bosun-*-py3-none-any.whl 
    
  2. 設定ファイルを変更して、管理エージェントを設定します。

    <your-chosen-editor> ./conf/mlops.bosun.conf.yaml 
    
  3. 管理エージェントを開始します。

    ./bin/start-bosun.sh 
    
  4. ホストマシンで管理エージェントを設定するには、管理エージェントの設定ファイルconf/mlops.bosun.conf.yamlを編集します。

    • mlopsUrlapiTokenの値を更新します。

    • <BOSUN_VENV_PATH>がインストール中に作成された仮想環境を指していることを確認します(例:/opt/management-agent-demo/bin)。

    • <MLOPS_PREDICTION_ENVIRONMENT_ID>で予測環境IDを指定します。

    • 適切なプラグインを使用するには、predictionEnvironmentsセクションの適切なcommand:行のコメントを解除します。 未使用のプラグインについては、必ずcommand:行をコメントアウトしてください。

    • (オプション)使用しているプラグインの設定ファイルを設定する必要があります。 詳細については、 管理エージェントプラグインの設定を参照してください。

    mlops.bosun.conf.yaml
    # This file contains configuration for the Management Agent
    # Items marked "Required" must be set. Other settings can use the defaults set below.
    
    # Required. URL to the DataRobot MLOps service.
    mlopsUrl: "https://<MLOPS_HOST>"
    
    # Required. DataRobot API token.
    apiToken: "<MLOPS_API_TOKEN>"
    
    # When true, verify SSL certificates when connecting to DR app. When false, SSL verification will not be
    # performed. It is highly recommended to keep this config variable as true.
    verifySSL: true
    
    # Whether to run management agent as the workload coordinator. The default value is true.
    isCoordinator: true
    
    # Whether to run management agent as worker. The default value is true.
    isWorker: true
    
    # When true, start a REST server. This will provide several API endpoints (worker health check enables)
    serverMode: false
    
    # The port to use for the above REST server
    serverPort: "12345"
    
    # The url where to reach REST server, will be use by external configuration services
    serverAddress: "http://localhost"
    
    # Specify the configuration service. This is 'internal' by default and the
    # workload coordinator and worker are expected to run in the same JVM.
    # When run in high availability mode, the configuration needs to be provided by
    # a service such as Consul.
    configurationService:
      tag: "tag"
      type: "internal"
      connectionDetail: ""
    
    # Path to write Bosun stats
    statsPath: "/tmp/management-agent-stats.json"
    
    # HTTP client timeout in milliseconds (30sec timeout).
    httpTimeout: 30000
    
    # Number of times the agent will retry sending a request to the MLOps service after it receives a failure.
    httpRetry: 3
    
    # Number of active workers to process management agent commands
    numActionWorkers: 2
    
    # Timeout in seconds processing active commands, eg. launch, stop, replaceModel
    actionWorkerTimeoutSec: 300
    
    # Timeout in seconds for requesting status of PE and the deployment
    statusWorkerTimeoutSec: 300
    
    # How often (in seconds) status worker should update DR MLOps about the status of PE and deployments
    statusUpdateIntervalSec: 120
    
    # How often (in seconds) to poll MLOps service for new deployment / PE Actions
    mlopsPollIntervalSec: 60
    # Optional: Plugins directory in which all required plugin jars can be found.
    # If you are only using external commands to run plugin actions then there is
    # no need to use this option.
    # pluginsDir: "../plugins/"
    
    # Model Connector configuration
    modelConnector:
      type: "native"
      # Scratch place to work on, default "/tmp"
      scratchDir: "/tmp"
      # Config file for private / secret configuration, management agent will not read this file, just
      # forward the filename in configuration, optional
      secretsConfigFile: "/tmp/secrets.conf"
      # Python command that implements model connector.
      # mcrunner is installed as part the bosun python package. You should either
      # set your PATH to include the location of mcrunner, or provide the full path.
      command: "<BOSUN_VENV_PATH>/bin/mcrunner"
    
    # prediction environments this service will monitor
    predictionEnvironments:
    # This Prediction Environment ID matches the one in DR MLOps service
    - id: "<MLOPS_PREDICTION_ENVIRONMENT_ID>"
        type: "ExternalCommand"
        platform: "os"
        # Enable monitoring for this plugin, so that the MLOps information
        # (viz, url and token) can be forwarded to plugin, default: False
        #
        enableMonitoring: true
    
        # Provide the command to run the plugin:
    
        # You can either fix PATH to point to where bosun-plugin-runner is located, or
        # you can provide the full path below.
        # The filesystem plugin used in the example below if one of the built in plugins provided
        # by the bosun-plugin-runner
        command: "<BOSUN_VENV_PATH>/bin/bosun-plugin-runner --plugin filesystem --private-config <CONF_PATH>/plugin.filesystem.conf.yaml"
    
        # The following example will run the docker plugin
        # (one of the built in plugins provided by bosun-plugin runner)
        # command: "<BOSUN_VENV_PATH>/bin/bosun-plugin-runner --plugin docker --private-config <CONF_PATH>/plugin.docker.conf.yaml"
    
        # The following example will run the kubernetes plugin
        # (one of the built in plugins provided by bosun-plugin runner)
        # WARNING: this plugin is currently considered ALPHA maturity; please consult your account representative if you
        # are interested in trying it.
        # command: "<BOSUN_VENV_PATH>/bin/bosun-plugin-runner --plugin k8s --private-config <CONF_PATH>/plugin.k8s.conf.yaml"
    
        # If your plugin was installed as a python module (using pip), you can provide the name
        # of the module that contains the plugin class. For example --plugin sample_plugin.my_plugin
        # command: "<BOSUN_VENV_PATH>/bin/bosun-plugin-runner --plugin sample_plugin.my_plugin --private-config <CONF_PATH>/my_config.yaml"
    
        # If your plugin is in a directory, you can provide the name of the plugin as the path to the
        # file that contains your plugin. For example:  --plugin sample_plugin/my_plugin.py
        # command: "<BOSUN_VENV_PATH>/bin/bosun-plugin-runner  --plugin sample_plugin/my_plugin.py --private-config <CONF_PATH>/my_config.yaml"
    
        # Note: you can control the plugin logging via the --log-config option of bosun-plugin-runner 
    
  1. 管理エージェントをDockerでネイティブに実行するには、まずMLOpsエージェントのtarballからdatarobot/mlops-management-agentのイメージをビルドします。

    make build -C tools/bosun_docker 
    
  2. デフォルトディレクトリまたはカスタムロケーションにマウントされた監視エージェントをDockerで設定します。

    • ファイルシステムプラグインを使用し、設定をデフォルトディレクトリにマウントして管理エージェントを実行するには、次の手順を実行します。

      docker run \
          -v /path/to/mlops.bosun.conf.yaml:/opt/datarobot/mlops/bosun/conf/mlops.bosun.conf.yaml \
          -v /path/to/plugin.filesystem.conf.yaml:/opt/datarobot/mlops/bosun/conf/plugin.filesystem.conf.yaml \
          datarobot/mlops-management-agent 
      
    • ファイルシステムプラグインを使用し、エージェント設定をカスタムロケーションにマウントして管理エージェントを実行するには、次の手順を実行します。

      docker run \
          -v /path/to/mlops.bosun.conf.yaml:/var/tmp/mlops.bosun.conf.yaml \
          -v /path/to/plugin.filesystem.conf.yaml:/opt/datarobot/mlops/bosun/conf/plugin.filesystem.conf.yaml \
          -e MLOPS_AGENT_CONFIG_YAML=/var/tmp/mlops.bosun.conf.yaml \
          datarobot/mlops-management-agent 
      
    • 管理エージェントをDockerコンテナで実行しながら、Dockerベースのプラグインを使用するには、いくつかの追加オプションを含める必要があります。また、変更するファイルが複数あるため、configディレクトリ全体にマウントする必要があります。

      $ docker run \
          -v ${PWD}/conf/:/opt/datarobot/mlops/bosun/conf/ \
          -v /tmp:/tmp \
          -v /var/run/docker.sock:/var/run/docker.sock \
          --user root \
          --network bosun \
          datarobot/mlops-management-agent:latest 
      

更新しました March 3, 2024