It is required to have npm (TypeScript) or uv (Python) installed to use the following command.
You can quickly initialize a new job from scratch by using CLI command bl new.
Copy
Ask AI
bl new job
This will create a pre-scaffolded local directory where your entire code can be added. In the generated folder, you’ll find a boilerplate job with multiple steps in the entrypoint file index.ts.
Copy
Ask AI
import { blStartJob, withSpan } from '@blaxel/core'; // You can load any Blaxel SDK functionimport '@blaxel/telemetry'; // This import is required to connect all the metrics and tracing with blaxel platformimport step1 from './steps/step1';import step2 from './steps/step2';import step3 from './steps/step3';type JobArguments = { name: string;}async function myJob({name}: JobArguments) { console.log(`Hello, world ${name}!`); // You can call standard Javascript functions await step1(); await step2(); ...}// You need to use a Blaxel SDK function to wrap your job, this is the only requirement to make it work with Blaxel blStartJob(myJob);
Start the job locally:
Copy
Ask AI
# Run the job with a sample batch filebl run job <<JOB-NAME>> --local --file batches/sample-batch.json# Or directly with --data argumentbl run job <<JOB-NAME>> --local --data '{"tasks": [{"name": "John"}]}'# Or without blaxel CLIpnpm start --name John