Setting Scheduled Training and Deployment
We'll need schedule-based automation if we want to retrain an ML model and deploy the new version periodically.
When does it make sense to use the scheduled-based automation?
It won't help you refresh the model if you retrain it using the same 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 Qwak Feature Store, check the Getting Started guide.
In this tutorial, we show how to configure the scheduled automation.
Requirements
Before starting, you have to store the model code in a git repository. We will need the repository URL and the access token later.
Configuration
First, we create an empty Python script and define the import the dependencies:
After that, we create an instance of the Automation class and configure it:
from qwak.automations import Automation, ScheduledTrigger, \
QwakBuildDeploy,BuildSpecifications, BuildMetric, \
ThresholdDirection, DeploymentSpecifications
test_automation = Automation(
name="automation_name",
model_id="model_to_be_deployed",
trigger=ScheduledTrigger(cron="0 0 * * 0"),
action=QwakBuildDeploy(
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 Automation documentation.
Deployment
Finally, we can use the Qwak CLI to deploy the automation:
qwak automations register --environment environment_name -p .
In the command above, we specified the name of the Qwak environment (--environment) and the directory containing the automation definitions (-p). In this case, the current working directory.
Updated about 1 month ago