Skip to content

Commit b7bda3f

Browse files
Document list jobs
1 parent 22cd3d4 commit b7bda3f

File tree

5 files changed

+101
-4
lines changed

5 files changed

+101
-4
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: JobClient.all
3+
icon: diagram-project
4+
---
5+
6+
```python
7+
def JobClient.all(temporal_extent: TimeIntervalLike) -> list[Job]
8+
```
9+
10+
List all available jobs.
11+
12+
## Parameters
13+
14+
<ParamField path="temporal_extent" type="TimeIntervalLike">
15+
The interval for which to load jobs.
16+
It can be specified in the following ways:
17+
- TimeInterval: interval -> Use the time interval as its given
18+
- DatetimeScalar: [time, time] -> Construct a TimeInterval with start and end time set to the given
19+
value and the end time inclusive
20+
- tuple of two DatetimeScalar: [start, end) -> Construct a TimeInterval with the given start and
21+
end time
22+
</ParamField>
23+
24+
## Returns
25+
26+
A list of jobs.
27+
28+
<RequestExample>
29+
```python Python
30+
jobs = job_client.all(("2025-01-01", "2025-02-01"))
31+
```
32+
</RequestExample>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: JobClient.find
3+
icon: diagram-project
4+
---
5+
6+
```python
7+
def JobClient.find(job_or_id: Job | str) -> Job
8+
```
9+
10+
Get a job by its id. Can also be an existing job object, in which case this method acts as a refresh operation to fetch the latest job details.
11+
12+
## Parameters
13+
14+
<ParamField path="job_or_id" type="Job | str">
15+
The job or job id to get.
16+
</ParamField>
17+
18+
## Returns
19+
20+
A job object.
21+
22+
<RequestExample>
23+
```python Python
24+
job = job_client.find("0195c87a-49f6-5ffa-e3cb-92215d057ea6")
25+
```
26+
</RequestExample>

api-reference/python/tilebox.workflows/JobClient.retry.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ icon: diagram-project
44
---
55

66
```python
7-
def JobClient.retry(job_or_id: Job | str)
7+
def JobClient.retry(job_or_id: Job | str) -> int
88
```
99

1010
Retry a job. All failed tasks will become queued again, and queued tasks will be picked up by task runners again.
@@ -15,8 +15,12 @@ Retry a job. All failed tasks will become queued again, and queued tasks will be
1515
The job or job id to retry.
1616
</ParamField>
1717

18+
## Returns
19+
20+
The number of tasks that were rescheduled.
21+
1822
<RequestExample>
1923
```python Python
20-
job_client.retry(job)
24+
nb_rescheduled = job_client.retry(job)
2125
```
2226
</RequestExample>

mint.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@
222222
"api-reference/python/tilebox.workflows/JobCache.group",
223223
"api-reference/python/tilebox.workflows/JobCache.__iter__",
224224
"api-reference/python/tilebox.workflows/JobClient.submit",
225+
"api-reference/python/tilebox.workflows/JobClient.find",
225226
"api-reference/python/tilebox.workflows/JobClient.retry",
226227
"api-reference/python/tilebox.workflows/JobClient.cancel",
227-
"api-reference/python/tilebox.workflows/JobClient.visualize"
228+
"api-reference/python/tilebox.workflows/JobClient.visualize",
229+
"api-reference/python/tilebox.workflows/JobClient.list"
228230
]
229231
}
230232
]

workflows/concepts/jobs.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,39 @@ myJob, err := client.Jobs.Submit(ctx, "my-job", cluster,
8686

8787
In this example, if `MyFlakyTask` fails, it will be retried up to five times before being marked as failed.
8888

89+
## Listing jobs
90+
91+
You can list all jobs in a given time range using the `all` method on the job client.
92+
93+
<CodeGroup>
94+
```python Python
95+
jobs = job_client.all(("2025-01-01", "2025-02-01"))
96+
print(jobs)
97+
```
98+
```go Go
99+
import (
100+
"time"
101+
workflows "github.com/tilebox/tilebox-go/workflows/v1"
102+
"github.com/tilebox/tilebox-go/query"
103+
)
104+
105+
interval := query.NewTimeInterval(
106+
time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC),
107+
time.Date(2025, 2, 1, 0, 0, 0, 0, time.UTC),
108+
)
109+
110+
jobs, err := workflows.Collect(client.Jobs.List(ctx, interval))
111+
if err != nil {
112+
slog.Error("Failed to list jobs", slog.Any("error", err))
113+
return
114+
}
115+
116+
for _, job := range jobs {
117+
fmt.Println(job)
118+
}
119+
```
120+
</CodeGroup>
121+
89122
## Retrieving a specific job
90123

91124
When you submit a job, it's assigned a unique identifier that can be used to retrieve it later.
@@ -522,7 +555,7 @@ job_client.retry(job)
522555
job_client.display(job)
523556
```
524557
```go Go
525-
err = client.Jobs.Retry(ctx, job.ID)
558+
_, err := client.Jobs.Retry(ctx, job.ID)
526559
```
527560
</CodeGroup>
528561

0 commit comments

Comments
 (0)