Skip to main content

mb.add_job(training_function, deployment_name=, ...)

Creates or updates a training job associated with a deployment. Learn more about training jobs.


  • training_function: Callable The function used to define the job. It should return a trained model object, or similar.
  • deployment_name: str The training job will be added to the deployment identified by this name. If the deployment does not exist it will be created.
  • name: Optional[str]: The name of the training job. If no name is supplied the name of training_function will be used.
  • store_result_as: Optional[str]: Training jobs store their results in files in the deployment's data/ directory for later access. If omitted, the name of the training job will be used.
  • default_arguments: Optional[List[Any]]: If the training_function expect arguments, supply them with default_arguments. The arguments sent when running the job can be overridden when calling mb.run_job. Arguments should be numbers or strings.
  • save_on_success: Optional[bool]: Determines whether to re-deploy the associated deployment upon successful execution of the job. Defaults to True.
  • email_on_failure: Optional[str]: An email address to notify upon unsuccessful execution of the job.
  • schedule: Optional[str]: The recurring schedule to run the job. Can be hourly|weekly|daily|monthly or a valid cron-formatted string. Defaults to None.
  • refresh_datasets: Optional[List[str]]: The list of dataset names to refresh before executing the job.
  • size: Optional[str]: The size of the job runner for executing the job. Can be small|medium|large|xlarge|2xlarge|4xlarge|gpu_small|gpu_medium|gpu_large. Defaults to small.
  • timeout_minutes: Optional[int]: The number of minutes to allow the job to run. Jobs exceeding this runtime will be terminated. Can be 5-1440 minutes. Defaults to 1 day (1440).
  • python_version: See mb.deploy.
  • python_packages: See mb.deploy.
  • system_packages: See mb.deploy.
  • extra_files: See mb.deploy.


The call to mb.add_job is typically done in an interactive environment, like a Python notebook. The command will print out status, and then show link to open the job in Modelbit.


Adding a job to a deployment

mb.add_job(train_model, deployment_name="example_deployment")

Specifying datasets to refresh

mb.add_job(train_model, deployment_name="example_deployment", refresh_datasets=["leads"])

Specifying a larger job runner

mb.add_job(train_model, deployment_name="example_deployment", size=["xlarge"])

See also