diff --git a/dictionary.txt b/dictionary.txt index 16a8caf28..aaedcd23b 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -13,6 +13,7 @@ CORS ECR GCP GCR +HPC IAM OpenID JSON @@ -82,6 +83,7 @@ roadmap scaffolded scalable serverless +transcoding triages undeploy uuid diff --git a/src/nav.config.ts b/src/nav.config.ts index dc4005e52..17b723d30 100644 --- a/src/nav.config.ts +++ b/src/nav.config.ts @@ -4,6 +4,7 @@ import { ClockIcon, CloudIcon, CommandLineIcon, + CpuChipIcon, GlobeAltIcon, HomeIcon, LockClosedIcon, @@ -68,6 +69,11 @@ const buildingBlockLinks = [ href: '/http', icon: ServerIcon, }, + { + title: 'AI & Batch', + href: '/batch', + icon: CpuChipIcon, + }, { title: 'Key Value Stores', href: '/keyvalue', @@ -694,6 +700,20 @@ const fullNav: FullNav = { links: buildingBlockLinks.filter((link) => link.href !== '/http'), }, ], + batch: [ + { + links: [ + { + title: 'Overview', + href: '/batch', + }, + ], + }, + { + title: 'More Building Blocks', + links: buildingBlockLinks.filter((link) => link.href !== '/batch'), + }, + ], keyvalue: [ { links: [ @@ -1170,6 +1190,23 @@ const fullNav: FullNav = { }, ], }, + { + title: 'Batch Jobs', + links: [ + { + title: 'job()', + href: '/reference/nodejs/batch/job', + }, + { + title: 'job.handler()', + href: '/reference/nodejs/batch/job-handler', + }, + { + title: 'job.send()', + href: '/reference/nodejs/batch/job-submit', + }, + ], + }, { title: 'HTTP', links: [ @@ -1636,6 +1673,23 @@ const fullNav: FullNav = { }, ], }, + { + title: 'Batch Jobs', + links: [ + { + title: 'job()', + href: '/reference/python/batch/job', + }, + { + title: 'job.handler()', + href: '/reference/python/batch/job-handler', + }, + { + title: 'job.send()', + href: '/reference/python/batch/job-submit', + }, + ], + }, { title: 'Key Value Stores', links: [ @@ -1867,6 +1921,23 @@ const fullNav: FullNav = { }, ], }, + { + title: 'Batch Jobs', + links: [ + { + title: 'job()', + href: '/reference/dart/batch/job', + }, + { + title: 'job.handler()', + href: '/reference/dart/batch/job-handler', + }, + { + title: 'job.send()', + href: '/reference/dart/batch/job-submit', + }, + ], + }, { title: 'Key Value Stores', links: [ @@ -2498,6 +2569,10 @@ const fullNav: FullNav = { title: 'NewApi()', href: '/reference/go/api/api', }, + { + title: 'NewJob()', + href: '/reference/go/batch/job', + }, { title: 'NewKv()', href: '/reference/go/keyvalue/keyvalue', @@ -2581,6 +2656,19 @@ const fullNav: FullNav = { }, ], }, + { + title: 'Batch Jobs', + links: [ + { + title: 'Job.Handler()', + href: '/reference/go/batch/job-handler', + }, + { + title: 'Job.Send()', + href: '/reference/go/batch/job-submit', + }, + ], + }, { title: 'Key Value Stores', links: [ diff --git a/src/pages/batch.mdx b/src/pages/batch.mdx new file mode 100644 index 000000000..d056a5913 --- /dev/null +++ b/src/pages/batch.mdx @@ -0,0 +1,212 @@ +export const description = 'Running AI & Batch workloads with Nitric' + +# Batch + +Nitric provides functionality that allows you to run large-scale jobs in parallel across multiple virtual machines or compute resources. Unlike Nitric Services, which respond to real-time events (APIs, Schedules, etc.), Batch is intended to efficiently handle tasks that can be processed in batches, which means they don't need to run in real time but can be executed asynchronously. Batches can include tasks that require a lot of computing power, or access to GPU resources, such as machine learning model training, image processing, video transcoding, data processing, and data analysis. + + + Batches are currently in [Preview](/reference/preview-features) and are + currently only available in the following languages: JavaScript, Python, Go, + and Dart, using the nitric/aws@1.14.0, nitric/gcp@1.14.0 or later. + + +Nitric Batch is designed to be used in conjunction with Nitric Services, allowing you to run long-running, computationally intensive tasks in parallel with your real-time services. This allows you to build complex applications that can handle both real-time and batch processing workloads. + +Batches are deployed to cloud services such as [AWS Batch](https://aws.amazon.com/batch/), [Azure Batch](https://azure.microsoft.com/en-au/products/batch), and [Google Cloud Batch](https://cloud.google.com/batch/docs). Nitric abstracts the underlying cloud provider, allowing you to run your batch jobs on any of the supported cloud providers without having to worry about the specifics of each provider. + +## Enabling Batches + +Batches are currently in [Preview](/reference/preview-features). To enable this feature in your project add the following to your `nitric.yaml` file + +```yaml +preview: + - batch-services +``` + +## Definitions + +### Batch + +A Batch is similar to a Nitric Service, but it's intended for work with a definitive start and a finish. Where a service is designed to be reactive, a batch is designed to be proactive and run a series of jobs in parallel. + +### Job Definitions + +A Job Definition describes a type of work to be done by a Nitric `Batch` + +### Job + +A Job is an instance of a Job Definition that is running within a `Batch`, Jobs can be started from other Nitric Services or Batches. + +## Limitations of Batches + +Jobs are designed to be long running HPC workloads and can take some time to spin up. They are not designed with reactivity in mind and are not suitable for responding to events from cloud resources. + +Jobs are unable to run the following: + +- Topic Subscriptions +- Bucket Notifications +- API & HTTP resources +- Websocket message handlers + +Jobs can be used to read and write to/from all nitric resources, for example they can publish new messages to a Topic, read and write to a Bucket, or read and write to a Database. They just can't respond to real-time events from these resources. + +## Defining Batches + +Batches are defined similarly to services in a project's `nitric.yaml` file. For example: + +```yaml +batch-services: + - match: ./batches/*.ts + start: yarn dev:services $SERVICE_PATH +``` + +Batches can contain any number of Job Definitions. + +## Defining a Job + +Within a Batch we create Job Definitions, by creating a new Job with a unique name and defining a handler function that will be executed when the job is submitted. + + + +```typescript +import { job, JobContext } from '@nitric/sdk' + +const analyze = job('analyze') + +// Use `handler` to register the callback function that will run when a job is submitted +analyze.handler( + async (ctx: JobContext) => { + // Do some work + }, + { cpus: 1, memory: 1024, gpus: 0 } +) +``` + +```python +from nitric.resources import job +from nitric.application import Nitric +from nitric.context import JobContext + +analyze = job("analyze") + +# Create the callback function that will run when a job is submitted +@analyze(cpus=1, memory=1024, gpus=0) +async def generate_image(ctx: None): + # Do some work + + +Nitric.run() +``` + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyze := nitric.NewJob("analyze") + + // Use `Handler` to register the callback function that will run when a job is submitted + analyze.Handler(func(ctx *batch.Ctx) { + // Do some work + }, batch.WithCpus(1), batch.WithMemory(1024), batch.WithGpus(0)) + + nitric.Run() +} +``` + +```dart +import 'package:nitric_sdk/nitric.dart'; + +void main() { + final job = Nitric.job("analyze"); + + job.handler((ctx) async { + print("New job submitted for ${ctx.req.jobName}: ${ctx.req.message}"); + + return ctx; + }, opts: JobResourceRequirements(cpus: 1, memory: 1024, gpus: 0)); +} +``` + + + +## Submitting Jobs for Execution + +Jobs may be submitted from Nitric `services` or other `batches` using the `submit` method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function. + + + +```javascript +import * as nitric from '@nitric/sdk' + +const api = nitric.api('public') +const analyze = nitric.job('analyze').allow('submit') + +api.post('/submit-job', async (ctx) => { + await analyze.submit({ + someKey: 'someValue', + }) +}) +``` + +```python +from nitric.resources import api, job +from nitric.application import Nitric + +analyze = job("analyze").allow("submit") +public_api = api("public") + +@public_api.post("/submit-job") +async def submit_job(ctx): + await analyze.submit( + { + "someKey": "someValue" + } + ) + +Nitric.run() +``` + +```go +import ( + "context" + + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/apis" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + api := nitric.NewApi("public") + analyze := nitric.NewJob("analyze").Allow(batch.JobSubmit) + + api.Post("/submit-job", func(ctx *apis.Ctx) { + analyze.Submit(context.Background(), map[string]interface{}{ + "someKey": "someValue", + }) + }) + + nitric.Run() +} +``` + +```dart +import 'package:nitric_sdk/nitric.dart'; + +void main() { + final api = Nitric.api("public"); + final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + + api.get("/submit-job", (ctx) async { + analyze.submit({ + "someKey": "someValue" + }); + + return ctx; + }); +} +``` + + diff --git a/src/pages/reference/dart/batch/job-handler.mdx b/src/pages/reference/dart/batch/job-handler.mdx new file mode 100644 index 000000000..5f2786b75 --- /dev/null +++ b/src/pages/reference/dart/batch/job-handler.mdx @@ -0,0 +1,71 @@ +export const description = + "Reference for Nitric's Dart library - Register a job handler to with the Nitric Dart SDK" + +# Dart - job.handler() + +Job handlers are the code that is run when a job request is submitted. These handlers should be written in a separate file to your services. + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + +analyze.handler((ctx) async { + return ctx; +}, opts: JobResourceRequirements(cpus: 1, memory: 2048, gpus: 0)); +``` + +## Defining Batches + +Batches are defined in different files to services and referenced in a project's `nitric.yaml` file. For example: + +```yaml +batch-services: + - match: ./batches/*.dart + start: dart run $SERVICE_PATH +``` + +## Parameters + + + + The middleware service to use as the handler for Job requests. + + + + The number of CPUs to allocate to the handler + + + The number of GPUs to allocate to the handler + + + The amount of memory (MB) to allocate to the handler + + + + +## Examples + +### Define a job handler + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + +analyze.handler((ctx) async { + return ctx; +}); +``` + +### Create a job handler with custom resource requirements + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + +analyze.handler((ctx) async { + return ctx; +}, opts: JobResourceRequirements(cpus: 1, memory: 2048, gpus: 1)); +``` diff --git a/src/pages/reference/dart/batch/job-submit.mdx b/src/pages/reference/dart/batch/job-submit.mdx new file mode 100644 index 000000000..00faf1a9a --- /dev/null +++ b/src/pages/reference/dart/batch/job-submit.mdx @@ -0,0 +1,34 @@ +export const description = + "Reference for Nitric's Dart library - Submit a batch job request with the Nitric Dart SDK" + +# Dart - job.submit() + +Jobs may be submitted from Nitric `services` or other `batches` using the `submit` method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function. + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + +await analyze.submit({ message: "message contents" }); +``` + +## Parameters + + + + The data that will be sent to the submit + + + +## Examples + +### Submit a job request + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); + +await analyze.submit({ message: "data contents" }); +``` diff --git a/src/pages/reference/dart/batch/job.mdx b/src/pages/reference/dart/batch/job.mdx new file mode 100644 index 000000000..cb551f9a0 --- /dev/null +++ b/src/pages/reference/dart/batch/job.mdx @@ -0,0 +1,39 @@ +export const description = + "Reference for Nitric's Dart library - Create Batch Jobs with the Nitric Dart SDK" + +# Dart - job() + +Creates a new Batch Job. + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze"); +``` + +## Parameters + + + + The unique name of this Batch Job within the app. Subsequent calls to `job` + with the same name will return the same object. + + + +## Examples + +### Create a Job + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze"); +``` + +### Create a Job with permissions to submit jobs + +```dart +import 'package:nitric_sdk/nitric.dart'; + +final analyze = Nitric.job("analyze").allow([JobPermission.submit]); +``` diff --git a/src/pages/reference/go/batch/job-handler.mdx b/src/pages/reference/go/batch/job-handler.mdx new file mode 100644 index 000000000..ddc8f1473 --- /dev/null +++ b/src/pages/reference/go/batch/job-handler.mdx @@ -0,0 +1,92 @@ +export const description = + "Reference for Nitric's Go library - Register a job handler to with the Nitric Go SDK" + +# Go - job.handler() + +Job handlers are the code that is run when a job request is submitted. These handlers should be written in a separate file to your services. + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyze := nitric.NewJob("analyze") + + analyse.Handler(func(ctx *batch.Ctx) { + // do long running work + }, batch.WithCpus(1), batch.WithMemory(2048), batch.WithGpus(1)) + + nitric.Run() +} +``` + +## Defining Batches + +Batches are defined in different files to services and referenced in a project's `nitric.yaml` file. For example: + +```yaml +batch-services: + - match: ./batches/*.go + start: go run $SERVICE_PATH +``` + +## Parameters + + + + The middleware service to use as the handler for Job requests. + + + + The number of CPUs to allocate to the handler + + + The number of GPUs to allocate to the handler + + + The amount of memory (MB) to allocate to the handler + + + + +## Examples + +### Define a job handler + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyze := nitric.NewJob("analyze") + + analyse.Handler(func(ctx *batch.Ctx) { + // do long running work + }) + + nitric.Run() +} +``` + +### Create a job handler with custom resource requirements + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyze := nitric.NewJob("analyze") + + analyse.Handler(func(ctx *batch.Ctx) { + // do long running work + }, batch.WithCpus(1), batch.WithMemory(2048), batch.WithGpus(1)) + + nitric.Run() +} +``` diff --git a/src/pages/reference/go/batch/job-submit.mdx b/src/pages/reference/go/batch/job-submit.mdx new file mode 100644 index 000000000..834e0c859 --- /dev/null +++ b/src/pages/reference/go/batch/job-submit.mdx @@ -0,0 +1,56 @@ +export const description = + "Reference for Nitric's Go library - Submit a batch job request with the Nitric Go SDK" + +# Go - job.submit() + +Jobs may be submitted from Nitric `services` or other `batches` using the `submit` method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function. + +```go +import ( + "context" + + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyse := nitric.NewJob("analyse").Allow(batch.JobSubmit) + + analyze.Submit(context.TODO(), map[string]interface{}{ + "message": "message contents", + }) + + nitric.Run() +} +``` + +## Parameters + + + + The data that will be sent to the submit + + + +## Examples + +### Submit a job request + +```go +import ( + "context" + + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyse := nitric.NewJob("analyse").Allow(batch.JobSubmit) + + analyze.Submit(context.TODO(), map[string]interface{}{ + "message": "message contents", + }) + + nitric.Run() +} +``` diff --git a/src/pages/reference/go/batch/job.mdx b/src/pages/reference/go/batch/job.mdx new file mode 100644 index 000000000..b2001e857 --- /dev/null +++ b/src/pages/reference/go/batch/job.mdx @@ -0,0 +1,60 @@ +export const description = + "Reference for Nitric's Go library - Create Batch Jobs with the Nitric Go SDK" + +# Go - job() + +Creates a new Batch Job. + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" +) + +func main() { + analyze := nitric.NewJob("analyze") + + nitric.Run() +} +``` + +## Parameters + + + + The unique name of this Batch Job within the app. Subsequent calls to `job` + with the same name will return the same object. + + + +## Examples + +### Create a Job + +```go +import ( + "github.com/nitrictech/go-sdk/nitric" +) + +func main() { + analyze := nitric.NewJob("analyze") + + nitric.Run() +} +``` + +### Create a Job with permissions to submit jobs + +```go +package main + +import ( + "github.com/nitrictech/go-sdk/nitric" + "github.com/nitrictech/go-sdk/nitric/batch" +) + +func main() { + analyse := nitric.NewJob("analyse").Allow(batch.JobSubmit) + + nitric.Run() +} +``` diff --git a/src/pages/reference/nodejs/batch/job-handler.mdx b/src/pages/reference/nodejs/batch/job-handler.mdx new file mode 100644 index 000000000..547a70f5b --- /dev/null +++ b/src/pages/reference/nodejs/batch/job-handler.mdx @@ -0,0 +1,81 @@ +export const description = + "Reference for Nitric's Node.js library - Register a job handler" + +# Node.js - job.handler() + +Job handlers are the code that is run when a job request is submitted. These handlers should be written in a separate file to your services. + +```ts +import { job, JobContext } from '@nitric/sdk' + +const analyze = job('analyze') + +analyze.handler( + async (ctx: JobContext) => { + // Do some work + return ctx + }, + { cpus: 1, memory: 1024, gpus: 0 } +) +``` + +## Defining Batches + +Batches are defined in different files to services and referenced in a project's `nitric.yaml` file. For example: + +```yaml +batch-services: + - match: ./services/*.ts + start: yarn dev:services $SERVICE_PATH +``` + +## Parameters + + + + One or more middleware services to use as the handler which will run on the + defined frequency. + + + + The number of CPUs to allocate to the handler + + + The number of GPUs to allocate to the handler + + + The amount of memory (MB) to allocate to the handler + + + + +## Examples + +### Define a job handler with default resource requirements + +```ts +import { job, JobContext } from '@nitric/sdk' + +const analyze = job('analyze') + +analyze.handler(async (ctx: JobContext) => { + // Do some work + return ctx +}) +``` + +### Create a job handler with custom resource requirements + +```ts +import { job, JobContext } from '@nitric/sdk' + +const analyze = job('analyze') + +analyze.handler( + async (ctx: JobContext) => { + // Do some work + return ctx + }, + { cpus: 1, memory: 2048, gpus: 0 } +) +``` diff --git a/src/pages/reference/nodejs/batch/job-submit.mdx b/src/pages/reference/nodejs/batch/job-submit.mdx new file mode 100644 index 000000000..84a95712c --- /dev/null +++ b/src/pages/reference/nodejs/batch/job-submit.mdx @@ -0,0 +1,34 @@ +export const description = + "Reference for Nitric's Node.js library - Submit a batch job request with custom resource requirements" + +# Node.js - job.submit() + +Jobs may be submitted from Nitric `services` or other `batches` using the `submit` method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function. + +```ts +import { job } from '@nitric/sdk' + +const analyze = job('analyze').allow('submit') + +await analyze.submit({ message: 'message contents' }) +``` + +## Parameters + + + + The data that will be sent to the submit + + + +## Examples + +### Submit a job request + +```ts +import { job } from '@nitric/sdk' + +const analyze = job('analyze').allow('submit') + +await analyze.submit({ message: 'message contents' }) +``` diff --git a/src/pages/reference/nodejs/batch/job.mdx b/src/pages/reference/nodejs/batch/job.mdx new file mode 100644 index 000000000..a83dcd619 --- /dev/null +++ b/src/pages/reference/nodejs/batch/job.mdx @@ -0,0 +1,39 @@ +export const description = + "Reference for Nitric's Node.js library - Create Batch Jobs" + +# Node.js - job() + +Creates a new Batch Job. + +```ts +import { job } from '@nitric/sdk' + +const analyze = job('analyze') +``` + +## Parameters + + + + The unique name of this Batch Job within the app. Subsequent calls to `job` + with the same name will return the same object. + + + +## Examples + +### Create a Job + +```ts +import { job } from '@nitric/sdk' + +const analyze = job('analyze') +``` + +### Create a Job with permissions to submit jobs + +```ts +import { job } from '@nitric/sdk' + +const analyze = job('analyze').allow('submit') +``` diff --git a/src/pages/reference/preview-features/index.mdx b/src/pages/reference/preview-features/index.mdx index 5fdcc4625..6705cddf5 100644 --- a/src/pages/reference/preview-features/index.mdx +++ b/src/pages/reference/preview-features/index.mdx @@ -15,6 +15,7 @@ Each preview feature will have its own documentation page, which will include in | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | | [docker-providers](/reference/providers/install/docker) | CLI v1.39.0 | [feedback](https://github.com/nitrictech/nitric/issues/605) | | [sql-databases](/sql) | CLI v1.42.0
AWS Provider v1.6.0
Azure Provider v1.9.0
AWS Terraform Provider v1.8.0 | [feedback](https://github.com/nitrictech/cli/issues/732) | +| [batch-services](/batch) | CLI v1.54.0
AWS Provider v1.14.0
GCP Provider v1.14.0 | [feedback]( | ## Released Preview Features diff --git a/src/pages/reference/python/batch/job-handler.mdx b/src/pages/reference/python/batch/job-handler.mdx new file mode 100644 index 000000000..ced99bd87 --- /dev/null +++ b/src/pages/reference/python/batch/job-handler.mdx @@ -0,0 +1,69 @@ +export const description = + "Reference for Nitric's Python library - Register a job handler to with the Nitric Python SDK" + +# Python - job.handler() + +Job handlers are the code that is run when a job request is submitted. These handlers should be written in a separate file to your services. + +```python +from nitric.resources import job + +analyze = job("analyze") + +@analyze(cpus=1, memory=2048, gpus=0) +def do_analyze(data): + # Run batch job + pass +``` + +## Defining Batches + +Batches are defined in different files to services and referenced in a project's `nitric.yaml` file. For example: + +```yaml +batch-services: + - match: ./batches/*.py + start: pipenv run dev $SERVICE_PATH +``` + +## Parameters + + + + The number of CPUs to allocate to the handler + + + The number of GPUs to allocate to the handler + + + The amount of memory (MB) to allocate to the handler + + + +## Examples + +### Define a job handler + +```python +from nitric.resources import job + +analyze = job("analyze") + +@analyze() +def do_analyze(data): + # Run batch job + pass +``` + +### Create a job handler with custom resource requirements + +```python +from nitric.resources import job + +analyze = job("analyze") + +@analyze(cpus=1, memory=2048, gpus=0) +def do_analyze(data): + # Run batch job + pass +``` diff --git a/src/pages/reference/python/batch/job-submit.mdx b/src/pages/reference/python/batch/job-submit.mdx new file mode 100644 index 000000000..be34bd24b --- /dev/null +++ b/src/pages/reference/python/batch/job-submit.mdx @@ -0,0 +1,34 @@ +export const description = + "Reference for Nitric's Dart library - Submit a batch job request with the Nitric Python SDK" + +# Python - job.submit() + +Jobs may be submitted from Nitric `services` or other `batches` using the `submit` method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function. + +```python +from nitric.resources import job + +analyze = job("analyze").allow("submit") + +await analyze.submit({ "message": "message contents" }) +``` + +## Parameters + + + + The data that will be sent to the submit + + + +## Examples + +### Submit a job request + +```python +from nitric.resources import job + +analyze = job("analyze").allow("submit") + +await analyze.submit({ "message": "message contents" }) +``` diff --git a/src/pages/reference/python/batch/job.mdx b/src/pages/reference/python/batch/job.mdx new file mode 100644 index 000000000..7b5b6ba79 --- /dev/null +++ b/src/pages/reference/python/batch/job.mdx @@ -0,0 +1,39 @@ +export const description = + "Reference for Nitric's Python library - Create Batch Jobs with the Nitric Python SDK" + +# Python - job() + +Creates a new Batch Job. + +```python +from nitric.resources import job + +analyze = job("analyze") +``` + +## Parameters + + + + The unique name of this Batch Job within the app. Subsequent calls to `job` + with the same name will return the same object. + + + +## Examples + +### Create a Job + +```python +from nitric.resources import job + +analyze = job("analyze") +``` + +### Create a Job with permissions to submit jobs + +```python +from nitric.resources import job + +analyze = job("analyze").allow("submit") +```