Skip to content

GCP.DataLabeling reference

Source: src/GCP/DataLabeling/AnnotationSpecSet.ts

A Data Labeling annotation spec set — a collection of class labels used by labeling tasks.

Spec sets are immutable after create. There is no labels API, so Alchemy stamps ownership into description so list / nuke can find them. Ids are server-assigned.

AnnotationSpecSet: Creating an Annotation Spec Set

Section titled “AnnotationSpecSet: Creating an Annotation Spec Set”

Image classes

const specs = yield* GCP.DataLabeling.AnnotationSpecSet("Classes", {
displayName: "pets",
annotationSpecs: [
{ displayName: "dog" },
{ displayName: "cat" },
],
});

Specs with descriptions

const specs = yield* GCP.DataLabeling.AnnotationSpecSet("Classes", {
displayName: "sentiment",
description: "review polarity",
annotationSpecs: [
{ displayName: "positive", description: "favorable" },
{ displayName: "negative", description: "unfavorable" },
],
});

Source: src/GCP/DataLabeling/Dataset.ts

A Data Labeling dataset — a container for data items and annotated datasets produced by labeling tasks.

Dataset ids are server-assigned. Display name and description are immutable after create. There is no labels API, so Alchemy stamps ownership into description so list / nuke can find them.

Generated display name

const dataset = yield* GCP.DataLabeling.Dataset("Images", {});

Named dataset with a description

const dataset = yield* GCP.DataLabeling.Dataset("Images", {
displayName: "product-photos",
description: "sku images for classification",
});

DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage

Section titled “DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage”

Source: src/GCP/DataLabeling/DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage.ts

A Data Labeling feedback message on a labeling-task feedback thread.

Create is a long-running operation. Message ids are server-assigned. Parent thread, body, and image are immutable — changing them replaces the message. There is no labels API, so Alchemy stamps ownership into body so list / nuke can find them.

DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage: Creating a Feedback Message

Section titled “DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage: Creating a Feedback Message”

Text comment on a thread

const message = yield* GCP.DataLabeling.DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage(
"Note",
{
parent: threadName,
body: "please relabel the occluded boxes",
},
);

Ownership-only body

const message = yield* GCP.DataLabeling.DatasetsAnnotatedDatasetsFeedbackThreadsFeedbackMessage(
"Note",
{
parent: threadName,
},
);

Source: src/GCP/DataLabeling/EvaluationJob.ts

A Data Labeling evaluation job that periodically samples predictions from an AI Platform model version and scores them.

Patch can only update evaluationJobConfig.humanAnnotationConfig.instruction, evaluationJobConfig.exampleCount, and evaluationJobConfig.exampleSamplePercentage. Pause and resume are separate RPCs. Every other field is identity — changing it replaces the job. There is no labels API, so Alchemy stamps ownership into description.

const evaluationJobConfig = {
exampleCount: 100,
exampleSamplePercentage: 0.1,
evaluationConfig: {},
inputConfig: {
dataType: "IMAGE",
annotationType: "IMAGE_CLASSIFICATION_ANNOTATION",
classificationMetadata: { isMultiLabel: false },
bigquerySource: {
inputUri: "bq://my-project.eval.predictions",
},
},
bigqueryImportKeys: {
data_json_key: "data",
label_json_key: "label",
label_score_json_key: "score",
},
imageClassificationConfig: {
annotationSpecSet: specs.name,
},
};
const job = yield* GCP.DataLabeling.EvaluationJob("DailyEval", {
annotationSpecSet: specs.name,
modelVersion:
"projects/my-project/models/classifier/versions/v1",
schedule: "every 24 hours",
evaluationJobConfig,
});
// Same logical id, changed props: the engine updates it in place.
const job = yield* GCP.DataLabeling.EvaluationJob("DailyEval", {
annotationSpecSet: specs.name,
modelVersion:
"projects/my-project/models/classifier/versions/v1",
schedule: "every 24 hours",
evaluationJobConfig,
paused: true,
});

Source: src/GCP/DataLabeling/Instruction.ts

A Data Labeling instruction describing how human operators should label data. Create is a long-running operation. The current API only accepts a PDF stored in Cloud Storage.

Instruction ids are server-assigned. There is no labels API, so Alchemy stamps ownership into description so list / nuke can find them. All input fields are immutable — changing them replaces the instruction.

Image labeling PDF

const instruction = yield* GCP.DataLabeling.Instruction("HowTo", {
displayName: "image-classes",
dataType: "IMAGE",
pdfInstruction: {
gcsFileUri: "gs://my-bucket/instructions.pdf",
},
});

Text labeling PDF with a description

const instruction = yield* GCP.DataLabeling.Instruction("HowTo", {
displayName: "entity-extraction",
dataType: "TEXT",
description: "highlight product names",
pdfInstruction: {
gcsFileUri: "gs://my-bucket/text-instructions.pdf",
},
});