Table of Contents

Bulk import requests

Alex Cota Updated by Alex Cota

The bulkImportRequest entity represents the bulk import job for a set of predictions. Below are some common operations the GraphQL API supports for bulk import requests. For an overview, see Model-assisted labeling (importing annotations).

Create a bulk import request

Once you have properly formatted your NDJSON import file, create a public URL for your file. Then, use the GraphQL mutation below to create a bulkImportRequest:

mutation {
createBulkImportRequest(data: {
projectId: "<PROJECT_ID>",
name: "import_job_1",
fileUrl: "https://foobar.com/test2file"}) {
id
}
}

Where:

  • projectId is the Project where you want to attach the predictions.
  • name is the name of the import job.
  • fileUrl is the URL to your web-hosted NDJSON file.
Wait until the import job is complete before opening the Editor to make sure all annotations are imported properly.

Check import request status

To check the status of the import job, pass this query:

query {
bulkImportRequest(where: {
projectId: "<PROJECT_ID>",
name: "import_job_1"}) {
id
name
state
statusFileUrl
errorFileUrl
}
}

Which returns:

  • id is the ID of the import job.
  • name is the name of the import job.
  • state refers to the whole import job and will be one of the following:
RUNNING
FAILED
FINISHED
  • statusFileUrl points to an NDJSON that expires after 24 hours and contains a SUCCESS or FAILED status per annotation when state is FINISHED. When state is FAILED, statusFileUrl will be null.
  • errorFileUrl points to an NDJSON that contains error messages for each annotation that did not import successfully when state is FINISHED.When state is FAILED, this NDJSON contains the error message.

List all import requests

Use this query to return a list of each import request that is accessible to you (note: bulkImportRequests is plural):

query {
bulkImportRequests(where: {projectId:"<PROJECT_ID>"}, skip: 5, first: 100) {
id
name
}
}

Where:

  • skip indicates the number of items to skip over.
  • first indicates the max number of items to return.

Delete imported annotations

Use this mutation to delete all imported annotations associated with a bulkImportRequest (note: this mutation does not delete the import request itself).

mutation {
deleteBulkImportRequest(where: {id: "<IMPORT_REQUEST_ID>"}) {
id
name
}
}

Where:

  • id is REQUIRED and is the ID of the import request containing the imported annotations you wish to delete.

Labelbox handles each deleteBulkImportRequest atomically, meaning either all or none of the annotations will be deleted depending on whether or not the deletion is successful.

If you open the asset with the imported annotations in the Editor before using the deleteBulkImportRequest mutation, you may need to refresh the screen to see the annotations removed in the labeling interface.

Was this page helpful?

Data Rows

Labeling parameters

Contact