Skip to content

Rapidata job manager

RapidataJobManager #

RapidataJobManager(openapi_service: OpenAPIService)

A rapidata manager for job definitions. Used to create and retrieve job definitions.

Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def __init__(self, openapi_service: OpenAPIService):
    self._openapi_service = openapi_service
    self.__context_manager = ContextManager(openapi_service)

    self.__priority: int | None = None
    logger.debug("JobManager initialized")

create_classification_job_definition #

create_classification_job_definition(
    name: str,
    instruction: str,
    answer_options: list[str],
    datapoints: list[str],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    confidence_threshold: float | None = None,
    quorum_threshold: int | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a classification job definition.

With this order you can have a datapoint (image, text, video, audio) be classified into one of the answer options. Each response will be exactly one of the answer options.

Parameters:

Name Type Description Default
name str

The name of the job. (Will not be shown to the labeler)

required
instruction str

The instruction for how the data should be classified.

required
answer_options list[str]

The list of options for the classification.

required
datapoints list[str]

The list of datapoints for the classification - each datapoint will be labeled.

required
data_type str

The data type of the datapoints. Defaults to "media" (any form of image, video or audio).

Other option: "text".

'media'
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
contexts list[str]

The list of contexts for the classification. Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction and options. (Therefore will be different for each datapoint) Will be match up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the classification (each inner list is the images shown for that datapoint). Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction and options. (Therefore will be different for each datapoint) Use a single-element inner list for one image per datapoint, or multiple entries to display several images.

None
confidence_threshold float

The probability threshold for the classification. Defaults to None.

If provided, the classification datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.

None
quorum_threshold int

The number of matching responses required to reach quorum. Defaults to None.

If provided, the classification datapoint will stop after the quorum is reached or at the number of responses, whatever happens first. Cannot be used together with confidence_threshold.

None
settings Sequence[RapidataSetting]

The list of settings for the classification. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None. If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_classification_job_definition(
    self,
    name: str,
    instruction: str,
    answer_options: list[str],
    datapoints: list[str],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    confidence_threshold: float | None = None,
    quorum_threshold: int | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a classification job definition.

    With this order you can have a datapoint (image, text, video, audio) be classified into one of the answer options.
    Each response will be exactly one of the answer options.

    Args:
        name (str): The name of the job. (Will not be shown to the labeler)
        instruction (str): The instruction for how the data should be classified.
        answer_options (list[str]): The list of options for the classification.
        datapoints (list[str]): The list of datapoints for the classification - each datapoint will be labeled.
        data_type (str, optional): The data type of the datapoints. Defaults to "media" (any form of image, video or audio). \n
            Other option: "text".
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        contexts (list[str], optional): The list of contexts for the classification. Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction and options. (Therefore will be different for each datapoint)
            Will be match up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the classification (each inner list is the images shown for that datapoint). Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction and options. (Therefore will be different for each datapoint)
            Use a single-element inner list for one image per datapoint, or multiple entries to display several images.
        confidence_threshold (float, optional): The probability threshold for the classification. Defaults to None.\n
            If provided, the classification datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.
        quorum_threshold (int, optional): The number of matching responses required to reach quorum. Defaults to None.\n
            If provided, the classification datapoint will stop after the quorum is reached or at the number of responses, whatever happens first.
            Cannot be used together with confidence_threshold.
        settings (Sequence[RapidataSetting], optional): The list of settings for the classification. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_classification_job"):
        if not isinstance(datapoints, list) or not all(
            isinstance(datapoint, str) for datapoint in datapoints
        ):
            raise ValueError("Datapoints must be a list of strings")

        from rapidata.rapidata_client.workflow import ClassifyWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            contexts=contexts,
            media_contexts=media_contexts,
            private_metadata=private_metadata,
            data_type=data_type,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=ClassifyWorkflow(
                instruction=instruction, answer_options=answer_options
            ),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            confidence_threshold=confidence_threshold,
            quorum_threshold=quorum_threshold,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_compare_job_definition #

create_compare_job_definition(
    name: str,
    instruction: str,
    datapoints: list[list[str]],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    a_b_names: list[str] | None = None,
    confidence_threshold: float | None = None,
    quorum_threshold: int | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a compare job definition.

With this order you compare two datapoints (image, text, video, audio) and the annotators will choose one of the two based on the instruction.

Parameters:

Name Type Description Default
name str

The name of the job. (Will not be shown to the labeler)

required
instruction str

The instruction for the comparison. Will be shown along side each datapoint.

required
datapoints list[list[str]]

Outher list is the datapoints, inner list is the options for the comparison - each datapoint will be labeled.

required
data_type str

The data type of the datapoints. Defaults to "media" (any form of image, video or audio).

Other option: "text".

'media'
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
contexts list[str]

The list of contexts for the comparison. Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be matched up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the comparison (each inner list is the images shown for that datapoint). Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be matched up with the datapoints using the list index. Use a single-element inner list for one image per datapoint, or multiple entries to display several images.

None
a_b_names list[str]

Custom naming for the two opposing models defined by the index in the datapoints list. Defaults to None.

If provided has to be a list of exactly two strings. example:

datapoints = [["path_to_image_A", "path_to_image_B"], ["path_to_text_A", "path_to_text_B"]]
a_b_naming = ["Model A", "Model B"]
The results will then correctly show "Model A" and "Model B". If not provided, the results will be shown as "A" and "B".

None
confidence_threshold float

The probability threshold for the comparison. Defaults to None.

If provided, the comparison datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.

None
quorum_threshold int

The number of matching responses required to reach quorum. Defaults to None.

If provided, the comparison datapoint will stop after the quorum is reached or at the number of responses, whatever happens first. Cannot be used together with confidence_threshold.

None
settings Sequence[RapidataSetting]

The list of settings for the comparison. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None.

If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_compare_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[list[str]],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    a_b_names: list[str] | None = None,
    confidence_threshold: float | None = None,
    quorum_threshold: int | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a compare job definition.

    With this order you compare two datapoints (image, text, video, audio) and the annotators will choose one of the two based on the instruction.

    Args:
        name (str): The name of the job. (Will not be shown to the labeler)
        instruction (str): The instruction for the comparison. Will be shown along side each datapoint.
        datapoints (list[list[str]]): Outher list is the datapoints, inner list is the options for the comparison - each datapoint will be labeled.
        data_type (str, optional): The data type of the datapoints. Defaults to "media" (any form of image, video or audio). \n
            Other option: "text".
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        contexts (list[str], optional): The list of contexts for the comparison. Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be matched up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the comparison (each inner list is the images shown for that datapoint). Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be matched up with the datapoints using the list index.
            Use a single-element inner list for one image per datapoint, or multiple entries to display several images.
        a_b_names (list[str], optional): Custom naming for the two opposing models defined by the index in the datapoints list. Defaults to None.\n
            If provided has to be a list of exactly two strings.
            example:
            ```python
            datapoints = [["path_to_image_A", "path_to_image_B"], ["path_to_text_A", "path_to_text_B"]]
            a_b_naming = ["Model A", "Model B"]
            ```
            The results will then correctly show "Model A" and "Model B".
            If not provided, the results will be shown as "A" and "B".
        confidence_threshold (float, optional): The probability threshold for the comparison. Defaults to None.\n
            If provided, the comparison datapoint will stop after the threshold is reached or at the number of responses, whatever happens first.
        quorum_threshold (int, optional): The number of matching responses required to reach quorum. Defaults to None.\n
            If provided, the comparison datapoint will stop after the quorum is reached or at the number of responses, whatever happens first.
            Cannot be used together with confidence_threshold.
        settings (Sequence[RapidataSetting], optional): The list of settings for the comparison. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.\n
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_compare_job"):
        if any(not isinstance(datapoint, list) for datapoint in datapoints):
            raise ValueError("Each datapoint must be a list of 2 paths/texts")

        if any(len(set(datapoint)) != 2 for datapoint in datapoints):
            raise ValueError(
                "Each datapoint must contain exactly two unique options"
            )

        if a_b_names is not None and len(a_b_names) != 2:
            raise ValueError(
                "A_B_naming must be a list of exactly two strings or None"
            )

        from rapidata.rapidata_client.workflow import CompareWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            contexts=contexts,
            media_contexts=media_contexts,
            private_metadata=private_metadata,
            data_type=data_type,
            multi_asset=True,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=CompareWorkflow(instruction=instruction, a_b_names=a_b_names),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            confidence_threshold=confidence_threshold,
            quorum_threshold=quorum_threshold,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_ranking_job_definition #

create_ranking_job_definition(
    name: str,
    instruction: str,
    datapoints: list[list[str]],
    comparison_budget_per_ranking: int,
    responses_per_comparison: int = 1,
    data_type: Literal["media", "text"] = "media",
    random_comparisons_ratio: float = 0.5,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
) -> RapidataJobDefinition

Create a ranking job definition.

With this order you can have a multiple lists of datapoints (image, text, video, audio) be ranked based on the instruction. Each list will be ranked independently, based on comparison matchups.

Parameters:

Name Type Description Default
name str

The name of the job.

required
instruction str

The instruction for the ranking. Will be shown with each matchup.

required
datapoints list[list[str]]

The outer list is determines the independent rankings, the inner list is the datapoints for each ranking.

required
comparison_budget_per_ranking int

The number of comparisons that will be collected per ranking (outer list of datapoints).

Rankings with more than 10 datapoints are matched adaptively (Elo-style) within this budget. Rankings with 10 or fewer datapoints compare every unique pair, spreading the budget evenly across the pairs — the total is rounded down to a multiple of the number of pairs, and is at least one comparison per pair.

required
responses_per_comparison int

The number of responses that will be collected per comparison. Defaults to 1.

1
data_type str

The data type of the datapoints. Defaults to "media" (any form of image, video or audio).

Other option: "text".

'media'
random_comparisons_ratio float

The ratio of random comparisons to the total number of comparisons. Defaults to 0.5.

Only applies to rankings with more than 10 datapoints; smaller rankings compare every unique pair.

0.5
contexts list[str]

The list of contexts for the ranking. Defaults to None.

If provided has to be the same length as the outer list of datapoints and will be shown in addition to the instruction. (Therefore will be different for each ranking) Will be matched up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the ranking (each inner list is the images shown for that ranking). Defaults to None.

If provided has to be the same length as the outer list of datapoints and will be shown in addition to the instruction. (Therefore will be different for each ranking) Will be matched up with the datapoints using the list index. Use a single-element inner list for one image per ranking, or multiple entries to display several images.

None
settings Sequence[RapidataSetting]

The list of settings for the ranking. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_ranking_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[list[str]],
    comparison_budget_per_ranking: int,
    responses_per_comparison: int = 1,
    data_type: Literal["media", "text"] = "media",
    random_comparisons_ratio: float = 0.5,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
) -> RapidataJobDefinition:
    """
    Create a ranking job definition.

    With this order you can have a multiple lists of datapoints (image, text, video, audio) be ranked based on the instruction.
    Each list will be ranked independently, based on comparison matchups.

    Args:
        name (str): The name of the job.
        instruction (str): The instruction for the ranking. Will be shown with each matchup.
        datapoints (list[list[str]]): The outer list is determines the independent rankings, the inner list is the datapoints for each ranking.
        comparison_budget_per_ranking (int): The number of comparisons that will be collected per ranking (outer list of datapoints).\n
            Rankings with more than 10 datapoints are matched adaptively (Elo-style) within this budget.
            Rankings with 10 or fewer datapoints compare every unique pair, spreading the budget evenly across the pairs —
            the total is rounded down to a multiple of the number of pairs, and is at least one comparison per pair.
        responses_per_comparison (int, optional): The number of responses that will be collected per comparison. Defaults to 1.
        data_type (str, optional): The data type of the datapoints. Defaults to "media" (any form of image, video or audio). \n
            Other option: "text".
        random_comparisons_ratio (float, optional): The ratio of random comparisons to the total number of comparisons. Defaults to 0.5.\n
            Only applies to rankings with more than 10 datapoints; smaller rankings compare every unique pair.
        contexts (list[str], optional): The list of contexts for the ranking. Defaults to None.\n
            If provided has to be the same length as the outer list of datapoints and will be shown in addition to the instruction. (Therefore will be different for each ranking)
            Will be matched up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the ranking (each inner list is the images shown for that ranking). Defaults to None.\n
            If provided has to be the same length as the outer list of datapoints and will be shown in addition to the instruction. (Therefore will be different for each ranking)
            Will be matched up with the datapoints using the list index.
            Use a single-element inner list for one image per ranking, or multiple entries to display several images.
        settings (Sequence[RapidataSetting], optional): The list of settings for the ranking. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
    """
    with tracer.start_as_current_span("JobManager.create_ranking_job"):
        if contexts and len(contexts) != len(datapoints):
            raise ValueError(
                "Number of contexts must match the number of sets that will be ranked"
            )
        if media_contexts and len(media_contexts) != len(datapoints):
            raise ValueError(
                "Number of media contexts must match the number of sets that will be ranked"
            )
        if not isinstance(datapoints, list) or not all(
            isinstance(dp, list) for dp in datapoints
        ):
            raise ValueError(
                "Datapoints must be a list of lists. Outer list is the independent rankings, inner list is the datapoints for each ranking."
            )
        if not all(len(set(dp)) == len(dp) for dp in datapoints):
            raise ValueError("Each inner list must contain unique datapoints.")

        if not all(len(inner_list) >= 2 for inner_list in datapoints):
            raise ValueError(
                "Each ranking must contain at least two unique datapoints."
            )

        from rapidata.rapidata_client.workflow import MultiRankingWorkflow

        datapoints_instances = []
        for i, datapoint in enumerate(datapoints):
            for d in datapoint:
                datapoints_instances.append(
                    Datapoint(
                        asset=d,
                        data_type=data_type,
                        context=contexts[i] if contexts else None,
                        media_context=media_contexts[i] if media_contexts else None,
                        group=str(i),
                    )
                )

        workflow = MultiRankingWorkflow(
            instruction=instruction,
            comparison_budget_per_ranking=comparison_budget_per_ranking,
            random_comparisons_ratio=random_comparisons_ratio,
            max_group_size=max(len(group) for group in datapoints),
            responses_per_comparison=responses_per_comparison,
        )

        return self._create_general_job_definition(
            name=name,
            workflow=workflow,
            datapoints=datapoints_instances,
            responses_per_datapoint=workflow.responses_per_datapoint,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_free_text_job_definition #

create_free_text_job_definition(
    name: str,
    instruction: str,
    datapoints: list[str],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a free text job definition.

With this order you can have a datapoint (image, text, video, audio) be labeled with free text. The annotators will be shown a datapoint and will be asked to answer a question with free text.

Parameters:

Name Type Description Default
name str

The name of the job.

required
instruction str

The instruction to answer with free text. Will be shown along side each datapoint.

required
datapoints list[str]

The list of datapoints for the free text - each datapoint will be labeled.

required
data_type str

The data type of the datapoints. Defaults to "media" (any form of image, video or audio).

Other option: "text".

'media'
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
contexts list[str]

The list of contexts for the free text. Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be matched up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the free text (each inner list is the images shown for that datapoint). Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be matched up with the datapoints using the list index. Use a single-element inner list for one image per datapoint, or multiple entries to display several images.

None
settings Sequence[RapidataSetting]

The list of settings for the free text. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None.

If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_free_text_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[str],
    data_type: Literal["media", "text"] = "media",
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a free text job definition.

    With this order you can have a datapoint (image, text, video, audio) be labeled with free text.
    The annotators will be shown a datapoint and will be asked to answer a question with free text.

    Args:
        name (str): The name of the job.
        instruction (str): The instruction to answer with free text. Will be shown along side each datapoint.
        datapoints (list[str]): The list of datapoints for the free text - each datapoint will be labeled.
        data_type (str, optional): The data type of the datapoints. Defaults to "media" (any form of image, video or audio). \n
            Other option: "text".
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        contexts (list[str], optional): The list of contexts for the free text. Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be matched up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the free text (each inner list is the images shown for that datapoint). Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be matched up with the datapoints using the list index.
            Use a single-element inner list for one image per datapoint, or multiple entries to display several images.
        settings (Sequence[RapidataSetting], optional): The list of settings for the free text. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.\n
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_free_text_job"):
        from rapidata.rapidata_client.workflow import FreeTextWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            contexts=contexts,
            media_contexts=media_contexts,
            private_metadata=private_metadata,
            data_type=data_type,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=FreeTextWorkflow(instruction=instruction),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_select_words_job_definition #

create_select_words_job_definition(
    name: str,
    instruction: str,
    datapoints: list[str],
    sentences: list[str],
    responses_per_datapoint: int = 10,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a select words job definition.

With this order you can have a datapoint (image, text, video, audio) be labeled with a list of words. The annotators will be shown a datapoint as well as a list of sentences split up by spaces. They will then select specific words based on the instruction.

Parameters:

Name Type Description Default
name str

The name of the job.

required
instruction str

The instruction for how the words should be selected. Will be shown along side each datapoint.

required
datapoints list[str]

The list of datapoints for the select words - each datapoint will be labeled.

required
sentences list[str]

The list of sentences for the select words - Will be split up by spaces and shown along side each datapoint.

Must be the same length as datapoints.

required
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
settings Sequence[RapidataSetting]

The list of settings for the select words. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None.

If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_select_words_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[str],
    sentences: list[str],
    responses_per_datapoint: int = 10,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a select words job definition.

    With this order you can have a datapoint (image, text, video, audio) be labeled with a list of words.
    The annotators will be shown a datapoint as well as a list of sentences split up by spaces.
    They will then select specific words based on the instruction.

    Args:
        name (str): The name of the job.
        instruction (str): The instruction for how the words should be selected. Will be shown along side each datapoint.
        datapoints (list[str]): The list of datapoints for the select words - each datapoint will be labeled.
        sentences (list[str]): The list of sentences for the select words - Will be split up by spaces and shown along side each datapoint.\n
            Must be the same length as datapoints.
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        settings (Sequence[RapidataSetting], optional): The list of settings for the select words. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.\n
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_select_words_job"):
        from rapidata.rapidata_client.workflow import SelectWordsWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            sentences=sentences,
            private_metadata=private_metadata,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=SelectWordsWorkflow(
                instruction=instruction,
            ),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_locate_job_definition #

create_locate_job_definition(
    name: str,
    instruction: str,
    datapoints: list[str],
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a locate job definition.

With this order you can have people locate specific objects in a datapoint (image, text, video, audio). The annotators will be shown a datapoint and will be asked to select locations based on the instruction.

Parameters:

Name Type Description Default
name str

The name of the job. (Will not be shown to the labeler)

required
instruction str

The instruction what should be located. Will be shown along side each datapoint.

required
datapoints list[str]

The list of datapoints for the locate - each datapoint will be labeled.

required
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
contexts list[str]

The list of contexts for the locate. Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be match up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the locate (each inner list is the images shown for that datapoint). Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Use a single-element inner list for one image per datapoint, or multiple entries to display several images.

None
settings Sequence[RapidataSetting]

The list of settings for the locate. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None.

If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_locate_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[str],
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a locate job definition.

    With this order you can have people locate specific objects in a datapoint (image, text, video, audio).
    The annotators will be shown a datapoint and will be asked to select locations based on the instruction.

    Args:
        name (str): The name of the job. (Will not be shown to the labeler)
        instruction (str): The instruction what should be located. Will be shown along side each datapoint.
        datapoints (list[str]): The list of datapoints for the locate - each datapoint will be labeled.
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        contexts (list[str], optional): The list of contexts for the locate. Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be match up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the locate (each inner list is the images shown for that datapoint). Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Use a single-element inner list for one image per datapoint, or multiple entries to display several images.
        settings (Sequence[RapidataSetting], optional): The list of settings for the locate. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.\n
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_locate_job"):
        from rapidata.rapidata_client.workflow import LocateWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            contexts=contexts,
            media_contexts=media_contexts,
            private_metadata=private_metadata,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=LocateWorkflow(target=instruction),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

create_draw_job_definition #

create_draw_job_definition(
    name: str,
    instruction: str,
    datapoints: list[str],
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition

Create a draw job definition.

With this order you can have people draw lines on a datapoint (image, text, video, audio). The annotators will be shown a datapoint and will be asked to draw lines based on the instruction.

Parameters:

Name Type Description Default
name str

The name of the job. (Will not be shown to the labeler)

required
instruction str

The instruction for how the lines should be drawn. Will be shown along side each datapoint.

required
datapoints list[str]

The list of datapoints for the draw lines - each datapoint will be labeled.

required
responses_per_datapoint int

The number of responses that will be collected per datapoint. Defaults to 10.

10
contexts list[str]

The list of contexts for the comparison. Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Will be match up with the datapoints using the list index.

None
media_contexts list[list[str]]

The list of image URLs / paths shown for the draw lines (each inner list is the images shown for that datapoint). Defaults to None.

If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint) Use a single-element inner list for one image per datapoint, or multiple entries to display several images.

None
settings Sequence[RapidataSetting]

The list of settings for the draw lines. Defaults to []. Decides how the tasks should be shown.

None
failure_tolerance float

The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict). 0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.

None
private_metadata list[dict[str, str]]

Key-value string pairs for each datapoint. Defaults to None.

If provided has to be the same length as datapoints.

This will NOT be shown to the labelers but will be included in the result purely for your own reference.

None
Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def create_draw_job_definition(
    self,
    name: str,
    instruction: str,
    datapoints: list[str],
    responses_per_datapoint: int = 10,
    contexts: list[str] | None = None,
    media_contexts: list[list[str]] | None = None,
    settings: Sequence[RapidataSetting] | None = None,
    failure_tolerance: float | None = None,
    private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition:
    """Create a draw job definition.

    With this order you can have people draw lines on a datapoint (image, text, video, audio).
    The annotators will be shown a datapoint and will be asked to draw lines based on the instruction.

    Args:
        name (str): The name of the job. (Will not be shown to the labeler)
        instruction (str): The instruction for how the lines should be drawn. Will be shown along side each datapoint.
        datapoints (list[str]): The list of datapoints for the draw lines - each datapoint will be labeled.
        responses_per_datapoint (int, optional): The number of responses that will be collected per datapoint. Defaults to 10.
        contexts (list[str], optional): The list of contexts for the comparison. Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Will be match up with the datapoints using the list index.
        media_contexts (list[list[str]], optional): The list of image URLs / paths shown for the draw lines (each inner list is the images shown for that datapoint). Defaults to None.\n
            If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
            Use a single-element inner list for one image per datapoint, or multiple entries to display several images.
        settings (Sequence[RapidataSetting], optional): The list of settings for the draw lines. Defaults to []. Decides how the tasks should be shown.
        failure_tolerance (float, optional): The fraction of datapoints allowed to fail while still creating the job definition (0.0-1.0). Defaults to None, which uses rapidata_config.upload.failureTolerance (default 0.0 = strict).\n                0.0 means any failed upload aborts creation so no incomplete definition is left behind; the failed datapoints can then be retried into the same dataset via the raised FailedUploadException.retry(). 1.0 creates the definition regardless of failures, as long as at least one datapoint uploads successfully.
        private_metadata (list[dict[str, str]], optional): Key-value string pairs for each datapoint. Defaults to None.\n
            If provided has to be the same length as datapoints.\n
            This will NOT be shown to the labelers but will be included in the result purely for your own reference.
    """
    with tracer.start_as_current_span("JobManager.create_draw_job"):
        from rapidata.rapidata_client.workflow import DrawWorkflow

        datapoints_instances = DatapointsValidator.map_datapoints(
            datapoints=datapoints,
            contexts=contexts,
            media_contexts=media_contexts,
            private_metadata=private_metadata,
        )
        return self._create_general_job_definition(
            name=name,
            workflow=DrawWorkflow(target=instruction),
            datapoints=datapoints_instances,
            responses_per_datapoint=responses_per_datapoint,
            settings=settings,
            failure_tolerance=failure_tolerance,
        )

get_job_definition_by_id #

get_job_definition_by_id(
    job_definition_id: str,
) -> RapidataJobDefinition

Get a job definition by ID.

Parameters:

Name Type Description Default
job_definition_id str

The ID of the job definition.

required

Returns:

Name Type Description
JobDefinition RapidataJobDefinition

The JobDefinition instance.

Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def get_job_definition_by_id(self, job_definition_id: str) -> RapidataJobDefinition:
    """Get a job definition by ID.

    Args:
        job_definition_id (str): The ID of the job definition.

    Returns:
        JobDefinition: The JobDefinition instance.
    """
    with tracer.start_as_current_span("JobManager.get_job_definition_by_id"):

        job_definition = (
            self._openapi_service.order.job_api.job_definition_definition_id_get(
                definition_id=job_definition_id,
            )
        )

        return RapidataJobDefinition(
            id=job_definition.definition_id,
            name=job_definition.name,
            openapi_service=self._openapi_service,
        )

find_job_definitions #

find_job_definitions(
    name: str = "", amount: int = 10, page: int = 1
) -> list[RapidataJobDefinition]

Find your recent jobs given criteria. If nothing is provided, it will return the most recent job definitions.

Parameters:

Name Type Description Default
name str

The name of the job definition - matching job definition will contain the name. Defaults to "" for any job definition.

''
amount int

The amount of job definitions to return. Defaults to 10.

10
page int

The page of job definitions to return. Defaults to 1.

1

Returns:

Type Description
list[RapidataJobDefinition]

list[JobDefinition]: A list of JobDefinition instances.

Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def find_job_definitions(
    self, name: str = "", amount: int = 10, page: int = 1
) -> list[RapidataJobDefinition]:
    """Find your recent jobs given criteria. If nothing is provided, it will return the most recent job definitions.

    Args:
        name (str, optional): The name of the job definition - matching job definition will contain the name. Defaults to "" for any job definition.
        amount (int, optional): The amount of job definitions to return. Defaults to 10.
        page (int, optional): The page of job definitions to return. Defaults to 1.

    Returns:
        list[JobDefinition]: A list of JobDefinition instances.
    """
    with tracer.start_as_current_span("JobManager.find_job_definitions"):
        from rapidata.api_client.models.audience_audience_id_jobs_get_job_id_parameter import (
            AudienceAudienceIdJobsGetJobIdParameter,
        )

        job_definition_page_result = (
            self._openapi_service.order.job_api.job_definitions_get(
                page=page,
                page_size=amount,
                name=AudienceAudienceIdJobsGetJobIdParameter(contains=name),
                sort=["-created_at"],
            )
        )

        jobs = [
            RapidataJobDefinition(
                id=job_def.definition_id,
                name=job_def.name,
                openapi_service=self._openapi_service,
            )
            for job_def in job_definition_page_result.items
        ]
        return jobs

get_job_by_id #

get_job_by_id(job_id: str) -> RapidataJob

Get a job by ID.

Parameters:

Name Type Description Default
job_id str

The ID of the job.

required

Returns:

Name Type Description
RapidataJob RapidataJob

The Job instance.

Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def get_job_by_id(self, job_id: str) -> RapidataJob:
    """Get a job by ID.

    Args:
        job_id (str): The ID of the job.

    Returns:
        RapidataJob: The Job instance.
    """
    with tracer.start_as_current_span("JobManager.get_job_by_id"):
        from rapidata.rapidata_client.job.rapidata_job import RapidataJob

        job_response = self._openapi_service.order.job_api.job_job_id_get(
            job_id=job_id,
        )
        return RapidataJob(
            job_id=job_response.job_id,
            name=job_response.name,
            audience_id=job_response.audience_id,
            created_at=job_response.created_at,
            definition_id=job_response.definition_id,
            openapi_service=self._openapi_service,
            pipeline_id=job_response.pipeline_id,
        )

find_jobs #

find_jobs(
    name: str = "", amount: int = 10, page: int = 1
) -> list[RapidataJob]

Find your recent jobs given criteria. If nothing is provided, it will return the most recent jobs.

Parameters:

Name Type Description Default
name str

The name of the job - matching job will contain the name. Defaults to "" for any job.

''
amount int

The amount of jobs to return. Defaults to 10.

10
page int

The page of jobs to return. Defaults to 1.

1

Returns:

Type Description
list[RapidataJob]

list[RapidataJob]: A list of RapidataJob instances.

Source code in src/rapidata/rapidata_client/job/rapidata_job_manager.py
def find_jobs(
    self, name: str = "", amount: int = 10, page: int = 1
) -> list[RapidataJob]:
    """Find your recent jobs given criteria. If nothing is provided, it will return the most recent jobs.

    Args:
        name (str, optional): The name of the job - matching job will contain the name. Defaults to "" for any job.
        amount (int, optional): The amount of jobs to return. Defaults to 10.
        page (int, optional): The page of jobs to return. Defaults to 1.

    Returns:
        list[RapidataJob]: A list of RapidataJob instances.
    """
    with tracer.start_as_current_span("JobManager.find_jobs"):
        from rapidata.api_client.models.audience_audience_id_jobs_get_job_id_parameter import (
            AudienceAudienceIdJobsGetJobIdParameter,
        )
        from rapidata.rapidata_client.job.rapidata_job import RapidataJob

        response = self._openapi_service.order.job_api.jobs_get(
            page=page,
            page_size=amount,
            name=AudienceAudienceIdJobsGetJobIdParameter(contains=name),
            sort=["-created_at"],
        )
        jobs = [
            RapidataJob(
                job_id=job.job_id,
                name=job.name,
                audience_id=job.audience_id,
                created_at=job.created_at,
                definition_id=job.job_definition_id,
                openapi_service=self._openapi_service,
                pipeline_id=job.pipeline_id,
            )
            for job in response.items
        ]
        return jobs