Write your first Labric job
Jobs are Python scripts that run in a sandboxed environment on Labric. They can be triggered automatically when files are uploaded, or run on demand. This guide walks through creating a simple job that reads a CSV and writes the data to a table.
Create a job
- Go to Jobs and click New
- Give your job a name (e.g., “CSV Importer”)
- Replace the default script with the code below
The script
This reads the first input file as a CSV, then writes every row to a table called measurements. The table must already exist in your organization, and each CSV header must name one of its columns. Values are converted to each column’s type, so numbers read from the CSV as text are stored as numbers.
Add dependencies
The labric SDK is always available. To use other packages, declare them in a PEP 723 inline metadata block at the top of your script — Labric installs them before the script runs:
Any standard version specifier works, so pin versions (e.g. pandas==2.2.2) when reproducibility matters. The block is validated when you save the job, so a malformed declaration surfaces immediately rather than at run time.
Set up a trigger (optional)
To run this job automatically whenever a CSV is uploaded:
- Toggle Enable trigger in the job form
- Set the file extension filter to
.csv
The job will fire each time a matching file arrives, with the file path available as LABRIC_FILE_PATH_0.
Write modes
The mode of a table write controls how its rows are written:
insert(the default) creates every row.upsertupdates rows that match an existing row on thekeycolumns and creates the rest. Running the job again on the same file then updates rows instead of duplicating them.updateanddeleterequire every row to match an existing row onkey.
A single client.data.write call can write several tables in one transaction, with rows that reference rows written earlier in the same call, and can write raw data series column by column. If any row is invalid, nothing is written and the error lists every problem by its place in the request. See the write data reference for the full request.
Run it
Click Execute on your job page, select a CSV file, and watch the execution log. Once it completes, your data will be available in the Data section.