cradle.sdk.types.task

  1from __future__ import annotations
  2
  3from abc import ABC
  4from typing import Any, TypeAlias
  5
  6from pydantic import BaseModel, Field
  7
  8from .common import (
  9    ArchivableResourceMixin,
 10    BaseListResponse,
 11    ContextProject,
 12    ContextRound,
 13    ContextWorkspace,
 14    ErrorResponseMixin,
 15    ResourceResponse,
 16)
 17from .tasks import v1, v2
 18from .tasks.common import TaskState
 19
 20
 21class ListTaskResponse(BaseListResponse):
 22    items: list[TaskResponse]
 23
 24
 25class TaskUpdateBase(BaseModel, ABC):
 26    display_name: str | None = Field(
 27        default=None,
 28        description="Optional display name for the task. This name is mutable.",
 29        min_length=1,
 30        max_length=64,
 31    )
 32    description: str | None = Field(
 33        default=None,
 34        description="Optional description to provide additional notes about the executed task.",
 35        min_length=1,
 36        max_length=1024,
 37    )
 38
 39
 40class TaskResponse(ResourceResponse, ArchivableResourceMixin, ErrorResponseMixin):
 41    type: str
 42    context: ContextWorkspace | ContextProject | ContextRound = Field(
 43        description="The context in which this task runs. Tasks started in a project or round context will only 'see' table data that belongs to the associated project.",
 44        discriminator="kind",
 45    )
 46    name: str | None = Field(description="An optional name of the task.", deprecated="Use display_name instead.")
 47    display_name: str | None = Field(default=None, description="An optional display name of the task.")
 48    idempotency_key: str | None = Field(
 49        default=None,
 50        description="An optional idempotency key of the task. It must be unique within the task's context.",
 51    )
 52    description: str | None = Field(description="A description of the task.")
 53    data_version_id: int | None = Field(
 54        description="The data version at which table inputs are observed.",
 55        deprecated="Use data snapshots instead. Snapshots for the task input tables are available in the `data_snapshots` field.",
 56    )
 57    data_load_id: int | None = Field(description="ID of the data load for the task's results.")
 58    data_snapshots: dict[str, int] = Field(
 59        description="Mapping of input keys of type TableSource* to IDs of data snapshots reused or created for the task's inputs."
 60    )
 61    parameters: (
 62        v1.AnalyzeDataParameters
 63        | v1.AnalyzeDiversifyParameters
 64        | v1.AnalyzeEngineerParameters
 65        | v1.AnalyzeTrainParameters
 66        | v1.DiversifyParameters
 67        | v1.EngineerParameters
 68        | v1.SearchParameters
 69        | v1.SelectParameters
 70        | v1.TrainParameters
 71        | v2.AnalyzeDataParameters
 72        | v2.DiversifyParameters
 73        | v2.EngineerParameters
 74        | v2.SelectParameters
 75        | v2.SearchParameters
 76        | v2.TrainParameters
 77        | v2.SamplerConditioningParameters
 78        | v2.SamplerInferenceParameters
 79        | v2.ScorerInferenceParameters
 80        | v2.TrainBaseModelParameters
 81        | v2.TrainScorerParameters
 82    ) = Field(description="The parameters of the task.")
 83    result: (
 84        v1.AnalyzeResult
 85        | v1.DiversifyResult
 86        | v1.EngineerResult
 87        | v1.SearchResult
 88        | v1.SelectResults
 89        | v1.TrainResult
 90        | v2.AnalyzeDataResult
 91        | v2.DiversifyResult
 92        | v2.EngineerResult
 93        | v2.SelectResult
 94        | v2.SearchResult
 95        | v2.TrainResult
 96        | v2.SamplerConditioningResult
 97        | v2.SamplerInferenceResult
 98        | v2.ScorerInferenceResult
 99        | v2.TrainBaseModelResult
100        | v2.TrainScorerResult
101        | None
102    ) = Field(description="The result of the completed task.")
103    state: TaskState = Field(description="The current state of the task's execution.")
104    status_details: dict[str, Any] | None = Field(
105        default=None,
106        description="Progress report for executing tasks None for tasks that don't emit progress, or when no progress has been reported.",
107    )
108
109
110class TaskCreate(TaskUpdateBase):
111    parameters: (
112        v1.AnalyzeDataParameters
113        | v1.AnalyzeDiversifyParameters
114        | v1.AnalyzeEngineerParameters
115        | v1.AnalyzeTrainParameters
116        | v1.DiversifyParameters
117        | v1.EngineerParameters
118        | v1.SearchParameters
119        | v1.SelectParameters
120        | v1.TrainParameters
121        | v2.AnalyzeDataParameters
122        | v2.DiversifyParameters
123        | v2.EngineerParameters
124        | v2.SelectParameters
125        | v2.SearchParameters
126        | v2.TrainParameters
127        | v2.SamplerConditioningParameters
128        | v2.SamplerInferenceParameters
129        | v2.ScorerInferenceParameters
130        | v2.TrainBaseModelParameters
131        | v2.TrainScorerParameters
132    ) = Field(description="The parameters for the task.")
133    context: ContextWorkspace | ContextProject | ContextRound = Field(
134        description="The context in which the task is executed.", discriminator="kind"
135    )
136    data_version_id: int | None = Field(
137        default=None,
138        description="For tasks that have parameters referencing data tables, this specifies the version of the table data to use. If no version is specified, it defaults to the most recent data version. Deprecated: Use TableSourceSnapshot instead.",
139        deprecated="Use data snapshots instead. `TableSourceSnapshot` allows to use a snapshot as a task input.",
140    )
141    name: str | None = Field(
142        default=None,
143        description="Optional name for the task. If provided it will ensure that only one task with that name exists within the task's context. This field is deprecated in favor of display_name + idempotency_key.",
144        min_length=1,
145        max_length=64,
146    )
147    idempotency_key: str | None = Field(
148        default=None,
149        description="Optional idempotency key to ensure only one task with this key exists within its context. If provided and a task with this key already exists, the request will be rejected with a 409 Conflict.",
150        min_length=1,
151        max_length=256,
152    )
153
154
155class TaskUpdate(TaskUpdateBase):
156    pass
157
158
159TaskParameters: TypeAlias = (
160    v1.AnalyzeDataParameters
161    | v1.AnalyzeDiversifyParameters
162    | v1.AnalyzeEngineerParameters
163    | v1.AnalyzeTrainParameters
164    | v1.DiversifyParameters
165    | v1.EngineerParameters
166    | v1.SearchParameters
167    | v1.SelectParameters
168    | v1.TrainParameters
169    | v2.AnalyzeDataParameters
170    | v2.DiversifyParameters
171    | v2.EngineerParameters
172    | v2.SelectParameters
173    | v2.SearchParameters
174    | v2.TrainParameters
175    | v2.SamplerConditioningParameters
176    | v2.SamplerInferenceParameters
177    | v2.ScorerInferenceParameters
178    | v2.TrainBaseModelParameters
179    | v2.TrainScorerParameters
180)
181TaskResults: TypeAlias = (
182    v1.AnalyzeResult
183    | v1.DiversifyResult
184    | v1.EngineerResult
185    | v1.SearchResult
186    | v1.SelectResults
187    | v1.TrainResult
188    | v2.AnalyzeDataResult
189    | v2.DiversifyResult
190    | v2.EngineerResult
191    | v2.SelectResult
192    | v2.SearchResult
193    | v2.TrainResult
194    | v2.SamplerConditioningResult
195    | v2.SamplerInferenceResult
196    | v2.ScorerInferenceResult
197    | v2.TrainBaseModelResult
198    | v2.TrainScorerResult
199)
class ListTaskResponse(cradle.sdk.types.common.BaseListResponse):
22class ListTaskResponse(BaseListResponse):
23    items: list[TaskResponse]
items: list[TaskResponse] = PydanticUndefined
class TaskUpdateBase(pydantic.main.BaseModel, abc.ABC):
26class TaskUpdateBase(BaseModel, ABC):
27    display_name: str | None = Field(
28        default=None,
29        description="Optional display name for the task. This name is mutable.",
30        min_length=1,
31        max_length=64,
32    )
33    description: str | None = Field(
34        default=None,
35        description="Optional description to provide additional notes about the executed task.",
36        min_length=1,
37        max_length=1024,
38    )
display_name: str | None = None

Optional display name for the task. This name is mutable.

description: str | None = None

Optional description to provide additional notes about the executed task.

 41class TaskResponse(ResourceResponse, ArchivableResourceMixin, ErrorResponseMixin):
 42    type: str
 43    context: ContextWorkspace | ContextProject | ContextRound = Field(
 44        description="The context in which this task runs. Tasks started in a project or round context will only 'see' table data that belongs to the associated project.",
 45        discriminator="kind",
 46    )
 47    name: str | None = Field(description="An optional name of the task.", deprecated="Use display_name instead.")
 48    display_name: str | None = Field(default=None, description="An optional display name of the task.")
 49    idempotency_key: str | None = Field(
 50        default=None,
 51        description="An optional idempotency key of the task. It must be unique within the task's context.",
 52    )
 53    description: str | None = Field(description="A description of the task.")
 54    data_version_id: int | None = Field(
 55        description="The data version at which table inputs are observed.",
 56        deprecated="Use data snapshots instead. Snapshots for the task input tables are available in the `data_snapshots` field.",
 57    )
 58    data_load_id: int | None = Field(description="ID of the data load for the task's results.")
 59    data_snapshots: dict[str, int] = Field(
 60        description="Mapping of input keys of type TableSource* to IDs of data snapshots reused or created for the task's inputs."
 61    )
 62    parameters: (
 63        v1.AnalyzeDataParameters
 64        | v1.AnalyzeDiversifyParameters
 65        | v1.AnalyzeEngineerParameters
 66        | v1.AnalyzeTrainParameters
 67        | v1.DiversifyParameters
 68        | v1.EngineerParameters
 69        | v1.SearchParameters
 70        | v1.SelectParameters
 71        | v1.TrainParameters
 72        | v2.AnalyzeDataParameters
 73        | v2.DiversifyParameters
 74        | v2.EngineerParameters
 75        | v2.SelectParameters
 76        | v2.SearchParameters
 77        | v2.TrainParameters
 78        | v2.SamplerConditioningParameters
 79        | v2.SamplerInferenceParameters
 80        | v2.ScorerInferenceParameters
 81        | v2.TrainBaseModelParameters
 82        | v2.TrainScorerParameters
 83    ) = Field(description="The parameters of the task.")
 84    result: (
 85        v1.AnalyzeResult
 86        | v1.DiversifyResult
 87        | v1.EngineerResult
 88        | v1.SearchResult
 89        | v1.SelectResults
 90        | v1.TrainResult
 91        | v2.AnalyzeDataResult
 92        | v2.DiversifyResult
 93        | v2.EngineerResult
 94        | v2.SelectResult
 95        | v2.SearchResult
 96        | v2.TrainResult
 97        | v2.SamplerConditioningResult
 98        | v2.SamplerInferenceResult
 99        | v2.ScorerInferenceResult
100        | v2.TrainBaseModelResult
101        | v2.TrainScorerResult
102        | None
103    ) = Field(description="The result of the completed task.")
104    state: TaskState = Field(description="The current state of the task's execution.")
105    status_details: dict[str, Any] | None = Field(
106        default=None,
107        description="Progress report for executing tasks None for tasks that don't emit progress, or when no progress has been reported.",
108    )

Mixin for resources that can return errors.

type: str = PydanticUndefined

The context in which this task runs. Tasks started in a project or round context will only 'see' table data that belongs to the associated project.

name: str | None

An optional name of the task.

display_name: str | None = None

An optional display name of the task.

idempotency_key: str | None = None

An optional idempotency key of the task. It must be unique within the task's context.

description: str | None = PydanticUndefined

A description of the task.

data_version_id: int | None

The data version at which table inputs are observed.

data_load_id: int | None = PydanticUndefined

ID of the data load for the task's results.

data_snapshots: dict[str, int] = PydanticUndefined

Mapping of input keys of type TableSource* to IDs of data snapshots reused or created for the task's inputs.

state: cradle.sdk.types.tasks.common.TaskState = PydanticUndefined

The current state of the task's execution.

status_details: dict[str, typing.Any] | None = None

Progress report for executing tasks None for tasks that don't emit progress, or when no progress has been reported.

class TaskCreate(TaskUpdateBase):
111class TaskCreate(TaskUpdateBase):
112    parameters: (
113        v1.AnalyzeDataParameters
114        | v1.AnalyzeDiversifyParameters
115        | v1.AnalyzeEngineerParameters
116        | v1.AnalyzeTrainParameters
117        | v1.DiversifyParameters
118        | v1.EngineerParameters
119        | v1.SearchParameters
120        | v1.SelectParameters
121        | v1.TrainParameters
122        | v2.AnalyzeDataParameters
123        | v2.DiversifyParameters
124        | v2.EngineerParameters
125        | v2.SelectParameters
126        | v2.SearchParameters
127        | v2.TrainParameters
128        | v2.SamplerConditioningParameters
129        | v2.SamplerInferenceParameters
130        | v2.ScorerInferenceParameters
131        | v2.TrainBaseModelParameters
132        | v2.TrainScorerParameters
133    ) = Field(description="The parameters for the task.")
134    context: ContextWorkspace | ContextProject | ContextRound = Field(
135        description="The context in which the task is executed.", discriminator="kind"
136    )
137    data_version_id: int | None = Field(
138        default=None,
139        description="For tasks that have parameters referencing data tables, this specifies the version of the table data to use. If no version is specified, it defaults to the most recent data version. Deprecated: Use TableSourceSnapshot instead.",
140        deprecated="Use data snapshots instead. `TableSourceSnapshot` allows to use a snapshot as a task input.",
141    )
142    name: str | None = Field(
143        default=None,
144        description="Optional name for the task. If provided it will ensure that only one task with that name exists within the task's context. This field is deprecated in favor of display_name + idempotency_key.",
145        min_length=1,
146        max_length=64,
147    )
148    idempotency_key: str | None = Field(
149        default=None,
150        description="Optional idempotency key to ensure only one task with this key exists within its context. If provided and a task with this key already exists, the request will be rejected with a 409 Conflict.",
151        min_length=1,
152        max_length=256,
153    )

The context in which the task is executed.

data_version_id: int | None

For tasks that have parameters referencing data tables, this specifies the version of the table data to use. If no version is specified, it defaults to the most recent data version. Deprecated: Use TableSourceSnapshot instead.

name: str | None = None

Optional name for the task. If provided it will ensure that only one task with that name exists within the task's context. This field is deprecated in favor of display_name + idempotency_key.

idempotency_key: str | None = None

Optional idempotency key to ensure only one task with this key exists within its context. If provided and a task with this key already exists, the request will be rejected with a 409 Conflict.

class TaskUpdate(TaskUpdateBase):
156class TaskUpdate(TaskUpdateBase):
157    pass