Skip to content

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

GitHub Actions for custom models

本機能の提供について

Integration with the Custom Models GitHub Action is off by default. この機能を有効にする方法については、DataRobotの担当者または管理者にお問い合わせください。

機能フラグ:**カスタムモデルのGitHub CI/CDを有効にする

The custom models action manages custom inference models and their associated deployments in DataRobot via GitHub CI/CD workflows. These workflows allow you to create or delete models and deployments and modify settings. Metadata defined in YAML files enables the custom model action's control over models and deployments. Most YAML files for this action can reside in any folder within your custom model's repository. The YAML is searched, collected, and tested against a schema to determine if it contains the entities used in these workflows. 詳細については、custom-models-actionリポジトリを参照してください

GitHub Actions quickstart

This quickstart example uses a Python Scikit-Learn model template from the datarobot-user-model repository. To set up a custom models action that will create a custom inference model and deployment in DataRobot from a custom model repository in GitHub, take the following steps:

  1. In the .github/workflows directory of your custom model repository, create a YAML file (with any filename) containing the following:

    ``` yaml linenums="1" hl_lines="5 7 29 30 31" name: Workflow CI/CD

    on: pull_request: branches: [ master ] push: branches: [ master ]

    # Allows you to run this workflow manually from the Actions tab workflow_dispatch:

    jobs: datarobot-custom-models: # Run this job on any action of a PR, but skip the job upon merging to the main branch. This # will be taken care of by the push event. if: ${{ github.event.pull_request.merged != true }}

    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
    
      - name: DataRobot Custom Models Step
        id: datarobot-custom-models-step
        uses: datarobot-oss/custom-models-action@v1.1.4
        with:
          api-token: ${{ secrets.DATAROBOT_API_TOKEN }}
          webserver: https://app.datarobot.com/
          branch: master
          allow-model-deletion: true
          allow-deployment-deletion: true
    

    ```

    Configure the following fields:

    • branches: Provide the name of your repository's main branch (usually either master or main) for pull_request and push. If you created your repository in GitHub, you likely need to update these fields to main. While master and main are the most common branch names, you can target any branch; for example, you could run the workflow on a release branch or a test branch.

    • api-token: Provide a value for the DATAROBOT_API_TOKEN variable by creating an encrypted secret for GitHub Actions containing your DataRobot API key. Alternatively, you can set the token string directly to this field; however, this method is highly discouraged because your API key is extremely sensitive data. If you use this method, anyone who has access to your repository can access your API key.

    • webserver: Provide your DataRobot webserver value here if it isn't the default DataRobot US server (https://app.datarobot.com/).

    • branch: Provide the name of your repository's main branch (usually either master or main). If you created your repository in GitHub, you likely need to update this field to main. While master and main are the most common branch names, you can target any branch; for example, you could run the workflow on a release branch or a test branch.

  2. Commit the workflow YAML file and push it to the remote. After you complete this step, any push to the remote (or merged pull request) triggers the action.

  3. In the folder for your DataRobot custom model, add a model definition YAML file (e.g., model.yaml) containing the following YAML and update the field values according to your model's characteristics:

    user_provided_model_id: model-unique-id-1
    target_type: Regression
    settings:
      name: My Awesome GitHub Model 1 [GitHub CI/CD]
      target_name: Grade 2014
    
    version:
      # Make sure this is the environment ID is in your system.
      # This one is the '[DataRobot] Python 3 Scikit-Learn Drop-In' environment
      model_environment_id: 5e8c889607389fe0f466c72d 
    

    Configure the following fields:

    • user_provided_model_id: Provide any descriptive and unique string value.

    • target_type: Provide the correct target type for your custom model.

    • target_name: Provide the correct target name for your custom model.

    • model_environment_id: Provide the DataRobot execution environment required for your custom model. You can find these environments in the DataRobot application under Model Registry > Custom Model Workshop > Environments.

  4. In any directory in your repository, add a deployment definition YAML file (with any filename) containing the following YAML:

    user_provided_deployment_id: my-awesome-deployment-id
    user_provided_model_id: model-unique-id-1 
    

    Configure the following fields:

    • user_provided_deployment_id: Provide any descriptive and unique string value.

    • user_provided_model_id: Provide the exact user_provided_model_id you set in the model definition YAML file.

  5. Commit these changes and push to the remote, then:

    • Navigate to your custom model repository in GitHub and click the Actions tab. You'll notice that the action is being executed.

    • Navigate to the DataRobot application. You'll notice that a new custom model was created along with an associated deployment. This action can take a few minutes.

注意

Creating two commits (or merging two pull requests) in quick succession can result in a ResourceNotFoundError. For example, you add a model definition with a training dataset, make a commit, and push to the remote. Then, you immediately delete the model definition, make a commit, and push to the remote. The training data upload action may begin after model deletion, resulting in an error. To avoid this scenario, wait for an action's execution to complete before pushing new commits or merging new pull requests to the remote repository.

Access commit information in DataRobot

After your workflow creates a model and a deployment in DataRobot, you can access the commit information from the model's version info and the deployment's overview:

  1. モデルレジストリをクリックしてから、カスタムモデルワークショップをクリックします。

  2. On the Models tab, click a GitHub-sourced model from the list and then click the Versions tab.

  3. Under Manage Versions, click the version you want to view the commit for.

  4. Under Version Info, find the Git Commit Reference and then click the commit hash (or commit ID) to open the commit that created the current version.

  1. モデルレジストリをクリックしてから、モデルパッケージをクリックします。

  2. On the Model Packages tab, click a GitHub-sourced model package from the list.

  3. Under Package Info, review the model information provided by your workflow, find the Git Commit Reference, and then click the commit hash (or commit ID) to open the commit that created the current model package.

  1. In the Deployments inventory, click a GitHub-sourced deployment from the list.

  2. On the deployment's Overview tab, review the model and deployment information provided by your workflow.

  3. In the Content group box, find the Git Commit Reference and click the commit hash (or commit ID) to open the commit that created the deployment.


更新しました February 12, 2023
Back to top