Skip to content

create_job

create_job(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    job_name: Optional[JobName] = None,
    role_arn: Optional[RoleArn] = None,
    job_category: Optional[JobCategory] = None,
    job_config_schema_version: Optional[JobSchemaVersion] = None,
    job_config_document: Optional[JobConfigDocument] = None,
    tags: Optional[TagList] = None,
) -> CreateJobResponse

Creates a model customization job in Amazon SageMaker. A job runs a workload based on the job category and configuration you provide. You specify the job category, a schema-versioned configuration document, and an IAM role that grants Amazon SageMaker permission to access resources on your behalf.

Use the AgentRFT category to fine-tune a model using multi-turn reinforcement learning with reward signals. Use the AgentRFTEvaluation category to evaluate a fine-tuned or base model by running multi-turn rollouts against a held-out prompt dataset and computing metrics such as pass@k and mean reward.

Before creating a job, call ListJobSchemaVersions and DescribeJobSchemaVersion to retrieve the configuration schema for your job category. The JobConfigDocument must conform to the schema specified by JobConfigSchemaVersion.

The following operations are related to CreateJob:

  • DescribeJob

  • ListJobs

  • StopJob

  • DeleteJob

  • ListJobSchemaVersions

  • DescribeJobSchemaVersion

Parameters:

  • job_name (Optional[JobName], default: None ) –

    The name of the job. The name must be unique within your account and Amazon Web Services Region.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker assumes to perform the job. The role must have the necessary permissions to access the resources required by the job configuration.

  • job_category (Optional[JobCategory], default: None ) –

    The category of the job. The category determines the type of workload that the job runs.

  • job_config_schema_version (Optional[JobSchemaVersion], default: None ) –

    The version of the configuration schema to use for the job configuration document. Use ListJobSchemaVersions to get available schema versions for a job category.

  • job_config_document (Optional[JobConfigDocument], default: None ) –

    The JSON configuration document for the job. The document must conform to the schema specified by JobConfigSchemaVersion. Use DescribeJobSchemaVersion to retrieve the schema for validation.

  • tags (Optional[TagList], default: None ) –

    An array of key-value pairs to apply to the job as tags. For more information, see Tagging Amazon Web Services Resources.

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def create_job(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    job_name: Optional["capo_sagemaker.types.job_name.JobName"] = None,
    role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
    job_category: Optional["capo_sagemaker.types.job_category.JobCategory"] = None,
    job_config_schema_version: Optional[
        "capo_sagemaker.types.job_schema_version.JobSchemaVersion"
    ] = None,
    job_config_document: Optional[
        "capo_sagemaker.types.job_config_document.JobConfigDocument"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_job_response.CreateJobResponse":
    """<p>Creates a model customization job in Amazon SageMaker. A job runs a workload based on the job category and configuration you provide. You specify the job category, a schema-versioned configuration document, and an IAM role that grants Amazon SageMaker permission to access resources on your behalf.</p> <p>Use the <code>AgentRFT</code> category to fine-tune a model using multi-turn reinforcement learning with reward signals. Use the <code>AgentRFTEvaluation</code> category to evaluate a fine-tuned or base model by running multi-turn rollouts against a held-out prompt dataset and computing metrics such as pass@k and mean reward.</p> <p>Before creating a job, call <code>ListJobSchemaVersions</code> and <code>DescribeJobSchemaVersion</code> to retrieve the configuration schema for your job category. The <code>JobConfigDocument</code> must conform to the schema specified by <code>JobConfigSchemaVersion</code>.</p> <p>The following operations are related to <code>CreateJob</code>:</p> <ul> <li> <p> <code>DescribeJob</code> </p> </li> <li> <p> <code>ListJobs</code> </p> </li> <li> <p> <code>StopJob</code> </p> </li> <li> <p> <code>DeleteJob</code> </p> </li> <li> <p> <code>ListJobSchemaVersions</code> </p> </li> <li> <p> <code>DescribeJobSchemaVersion</code> </p> </li> </ul>

    Args:
        job_name: <p>The name of the job. The name must be unique within your account and Amazon Web Services Region.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker assumes to perform the job. The role must have the necessary permissions to access the resources required by the job configuration.</p>
        job_category: <p>The category of the job. The category determines the type of workload that the job runs.</p>
        job_config_schema_version: <p>The version of the configuration schema to use for the job configuration document. Use <code>ListJobSchemaVersions</code> to get available schema versions for a job category.</p>
        job_config_document: <p>The JSON configuration document for the job. The document must conform to the schema specified by <code>JobConfigSchemaVersion</code>. Use <code>DescribeJobSchemaVersion</code> to retrieve the schema for validation.</p>
        tags: <p>An array of key-value pairs to apply to the job as tags. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a>.</p>

    Raises:
        capo_sagemaker.errors.resource_in_use.ResourceInUse: <p>Resource being accessed is in use.</p>
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        capo_sagemaker.errors.resource_not_found.ResourceNotFound: <p>Resource being access is not found.</p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.create_job_request.CreateJobRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.create_job_response.CreateJobResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.create_job

        output, http_response = (
            capo_sagemaker._operations.sage_maker.create_job.create_job(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateJob")
    )
    input_: capo_sagemaker.types.create_job_request.CreateJobRequest = {}
    if job_name is not None:
        input_["job_name"] = job_name
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if job_category is not None:
        input_["job_category"] = job_category
    if job_config_schema_version is not None:
        input_["job_config_schema_version"] = job_config_schema_version
    if job_config_document is not None:
        input_["job_config_document"] = job_config_document
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output