Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit fd513d8

Browse files
committed
add resource overrides
1 parent 916d324 commit fd513d8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/pages/jobs.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ from nitric.resources import job_definition
6262
from nitric.application import Nitric
6363
from nitric.context import JobContext
6464

65-
# Define will allow the developer to fine-tune the job option, such as adding resource dependencies (e.g. CPU, Memory, GPUs) etc.
6665
@job_definition("analyse").define(cpus=1, memory=1024, gpus=0)
6766
async def generate_image(ctx: None):
6867
# Do some work
@@ -86,9 +85,13 @@ const api = nitric.api('public')
8685
const analyseJob = nitric.jobDefintion('analyse')
8786

8887
api.post('/submit-job', async (ctx) => {
89-
await analyseJob.submit({
90-
someKey: 'someValue',
91-
})
88+
await analyseJob.submit(
89+
{
90+
someKey: 'someValue',
91+
},
92+
// optional job resource overrides
93+
{ cpus: 1, memory: 1024, gpus: 0 }
94+
)
9295
})
9396
```
9497

@@ -101,9 +104,13 @@ public_api = api("public")
101104

102105
@public_api.post("/submit-job")
103106
async def submit_job(ctx):
104-
await analyse_job.submit({
107+
await analyse_job.submit(
108+
{
105109
"someKey": "someValue"
106-
})
110+
},
111+
# optional job resource overrides
112+
{ cpus: 1, memory: 1024, gpus: 0 }
113+
)
107114

108115
Nitric.run()
109116
```

0 commit comments

Comments
 (0)