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

Commit a651b06

Browse files
committed
update batch page to use code switcher
1 parent da41980 commit a651b06

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

docs/batch.mdx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const description = 'Running AI & Batch workloads with Nitric'
1+
---
2+
description: Running AI & Batch workloads with Nitric
3+
---
24

35
# Batch
46

@@ -66,9 +68,9 @@ batch-services:
6668

6769
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.
6870

69-
<CodeGroup>
71+
<CodeSwitcher>
7072

71-
```typescript
73+
```typescript !!
7274
import { job, JobContext } from '@nitric/sdk'
7375
7476
const analyze = job('analyze')
@@ -78,11 +80,11 @@ analyze.handler(
7880
async (ctx: JobContext) => {
7981
// Do some work
8082
},
81-
{ cpus: 1, memory: 1024, gpus: 0 }
83+
{ cpus: 1, memory: 1024, gpus: 0 },
8284
)
8385
```
8486

85-
```python
87+
```python !!
8688
from nitric.resources import job
8789
from nitric.application import Nitric
8890
from nitric.context import JobContext
@@ -98,7 +100,7 @@ async def generate_image(ctx: None):
98100
Nitric.run()
99101
```
100102

101-
```go
103+
```go !!
102104
import (
103105
"github.com/nitrictech/go-sdk/nitric"
104106
"github.com/nitrictech/go-sdk/nitric/batch"
@@ -116,7 +118,7 @@ func main() {
116118
}
117119
```
118120

119-
```dart
121+
```dart !!
120122
import 'package:nitric_sdk/nitric.dart';
121123
122124
void main() {
@@ -130,15 +132,15 @@ void main() {
130132
}
131133
```
132134

133-
</CodeGroup>
135+
</CodeSwitcher>
134136

135137
## Submitting Jobs for Execution
136138

137139
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.
138140

139-
<CodeGroup>
141+
<CodeSwitcher>
140142

141-
```javascript
143+
```javascript !!
142144
import * as nitric from '@nitric/sdk'
143145

144146
const api = nitric.api('public')
@@ -151,7 +153,7 @@ api.post('/submit-job', async (ctx) => {
151153
})
152154
```
153155

154-
```python
156+
```python !!
155157
from nitric.resources import api, job
156158
from nitric.application import Nitric
157159

@@ -169,7 +171,7 @@ async def submit_job(ctx):
169171
Nitric.run()
170172
```
171173

172-
```go
174+
```go !!
173175
import (
174176
"context"
175177

@@ -192,7 +194,7 @@ func main() {
192194
}
193195
```
194196

195-
```dart
197+
```dart !!
196198
import 'package:nitric_sdk/nitric.dart';
197199
198200
void main() {
@@ -209,4 +211,4 @@ void main() {
209211
}
210212
```
211213

212-
</CodeGroup>
214+
</CodeSwitcher>

0 commit comments

Comments
 (0)