Rapidata job definition
RevisionInfo
dataclass
#
RevisionInfo(
revision: int,
base_revision: int | None,
state: RevisionState,
created_at: datetime,
)
One revision of a job definition, as listed by RapidataJobDefinition.revisions().
RapidataJobDefinition #
RapidataJobDefinition(
id: str,
name: str,
openapi_service: OpenAPIService,
revision: int | None = None,
)
A job definition, held at one revision.
Reading a property returns the loaded revision's value, or your unsaved change.
Assigning one stages the change locally; save() sends the whole revision
in one request and moves the object to the new revision. audience.assign_job
runs the revision this object holds.
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
estimated_cost
property
#
estimated_cost: CostEstimate
An approximate estimate of what this job will cost to run to completion.
This is an estimate, not the final bill - see :class:CostEstimate. The
estimate is priced shortly after the definition is created; this call
waits for it to become available.
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If the estimate is still not available after a few minutes. |
revision
property
#
The revision this object holds. assign_job runs exactly this revision.
base_revision
property
#
The revision this one was edited from, or None if it was not recorded.
state
property
#
The current state of this revision, fetched from the server.
A new revision is Pending until its preview has been built.
dataset_id
property
#
The dataset of this revision, including an unsaved set_datapoints().
instruction
property
writable
#
The instruction shown to labelers. None when it is set per datapoint.
answer_options
property
writable
#
The answer options of a classification job definition.
None when the options are set per datapoint (the default for job definitions
created with create_classification_job_definition) or the job type has none.
Setting it shows the same options for every datapoint.
responses_per_datapoint
property
writable
#
The maximum number of responses collected per datapoint.
settings
property
writable
#
The settings of this revision, as CustomSetting objects.
Assigning a list replaces every setting, at both the rapid and campaign level.
validation_set_id
property
writable
#
The validation set pinned on this revision, or None for none.
has_unsaved_changes
property
#
Whether a change is staged that save() has not sent yet.
preview #
preview() -> RapidataJobDefinition
Will open the browser where you can preview the job definition before giving it to an audience.
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
delete #
Deletes the job definition and all its revisions.
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
set_datapoints #
set_datapoints(
datapoints: list[str] | list[list[str]],
data_type: Literal["text", "media"] = "media",
contexts: list[str] | None = None,
media_contexts: list[list[str]] | None = None,
sentences: list[str] | None = None,
private_metadata: list[dict[str, str]] | None = None,
answer_options: (
list[str] | list[list[str]] | None
) = None,
) -> None
Upload a new dataset now and stage it for the next save().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datapoints
|
list[str] | list[list[str]]
|
paths to the datapoints or strings for text datapoints. |
required |
data_type
|
Literal['text', 'media']
|
The type of the datapoints. |
'media'
|
contexts
|
list[str]
|
One text context per datapoint. Defaults to None. |
None
|
media_contexts
|
list[list[str]]
|
Image URLs / paths shown alongside each datapoint, one inner list per datapoint. Defaults to None. |
None
|
sentences
|
list[str]
|
The sentences associated with each datapoint (used by select-words workflows). Defaults to None. |
None
|
private_metadata
|
list[dict[str, str]]
|
Key-value pairs attached to each datapoint that will not be shown to labelers. Defaults to None. |
None
|
answer_options
|
list[str] | list[list[str]]
|
Classification only, required when the options are set per datapoint: one list for every datapoint, or one list per datapoint. |
None
|
Raises:
| Type | Description |
|---|---|
FailedUploadException
|
If any datapoint fails to upload. Nothing is staged. |
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
save #
Create a new revision from this object and move the object to it.
The request carries the complete revision: the one this object was loaded at,
plus your staged changes. Changes saved by someone else since you loaded are
not merged in; with require_latest=False (default) your revision becomes
the latest anyway.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
require_latest
|
bool
|
Only save if no other revision was saved since this object was loaded. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The new revision number. |
Raises:
| Type | Description |
|---|---|
RevisionConflictError
|
With |
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
reload #
reload(
revision: int | None = None,
) -> RapidataJobDefinition
Load a revision into this object, the latest one by default.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If there are unsaved changes; |
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
discard_changes #
discard_changes() -> RapidataJobDefinition
Drop every staged change; the object keeps its loaded revision.
revisions #
revisions() -> list[RevisionInfo]
Every revision of this job definition, oldest first.
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
wait_until_ready #
wait_until_ready(
timeout: float = 300,
) -> RapidataJobDefinition
Block until this revision's preview is built.
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If it is still |
RuntimeError
|
If the revision failed. |
Source code in src/rapidata/rapidata_client/job/rapidata_job_definition.py
update_dataset #
update_dataset(
datapoints: list[str] | list[list[str]],
data_type: Literal["text", "media"] = "media",
contexts: list[str] | None = None,
media_contexts: list[list[str]] | None = None,
sentences: list[str] | None = None,
private_metadata: list[dict[str, str]] | None = None,
) -> RapidataJobDefinition
Deprecated: use set_datapoints(...) followed by save().