Scheduled Training and Deployment

JFrog ML Documentation

Products
JFrog ML
Content Type
User Guide

To retrain an ML model and deploy the new version periodically, we'll need a schedule-based automation. 

In this tutorial, we show how to configure the scheduled automation.

When does it make sense to use the scheduled-based automation?

It won't help to retrain the model when using the same training data every time. 

Because of that, the model's build function should retrieve the up-to-date training data from the Feature Store.

If you aren't familiar with the JFrog ML Feature Store, check out our QuickStart guide.

Pre-requisites

Make sure you store the model code in a Git. We will need the repository URL and the access token later on.

Configuration

First, we create an empty Python script and define the import the dependencies and create an instance of the Automation class and configure it:

from frogml.core.automations  import Automation, ScheduledTrigger, \
      FrogmlBuildDeploy,BuildSpecifications, BuildMetric, \
        ThresholdDirection, DeploymentSpecifications

test_automation = Automation(
    name="automation_name",
    model_id="model_to_be_deployed",
    trigger=ScheduledTrigger(cron="0 0 * * 0"),
    action=FrogmlBuildDeploy(
        build_spec=BuildSpecifications(git_uri="https://github.com/org_id/repository_name.git#directory/another_directory",
                                       git_access_token_secret="secret_name",
                                       git_branch="main",
                                       main_dir="main",
                                       tags=["prod"],
                                       env_vars=["key1=val1","key2=val2","key3=val3"]),
        deployment_condition=BuildMetric(metric_name="f1_score",
                                         direction=ThresholdDirection.ABOVE,
                                         threshold="0.65"),
        deployment_spec=DeploymentSpecifications(number_of_pods=1,
                                                 cpu_fraction=2.0,
                                                 memory="2Gi",
                                                 variation_name="B",
                                                 environments=["env1","env2"])
    )
)

We have described the configuration parameters in our Automating Build and Deploy page.

Publishing the Automation

Finally, we can use the JFrog ML CLI to publish the automation. We specify the name of the JFrog ML environment --environment and the directory containing the automation definitions-p,  In this case, the current working directory.

frogml automations register --environment environment_name -p .