Skip to content

Document list jobs #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api-reference/go/datasets/Datapoints.Query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The output sequence can be transformed into a typed `proto.Message` using [Colle

## Options

<ParamField path="WithTemporalExtent(temporalExtent query.TemporalExtent)">
<ParamField path="WithTemporalExtent(temporalExtent query.TemporalExtent)" required>
Specify the time interval for which data should be queried.
Right now, a temporal extent is required for every query.
</ParamField>
Expand Down
47 changes: 0 additions & 47 deletions api-reference/go/workflows/Jobs.List.mdx

This file was deleted.

61 changes: 61 additions & 0 deletions api-reference/go/workflows/Jobs.Query.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Client.Jobs.Query
sidebarTitle: Jobs.Query
icon: diagram-project
---

```go
func (*JobClient) Query(
ctx context.Context,
options ...job.QueryOption,
) iter.Seq2[*workflows.Job, error]
```

Query jobs in the specified interval.

The jobs are lazily loaded and returned as a sequence of Jobs.
The jobs are returned sorted by creation time in reverse order.
The output sequence can be transformed into a slice of Job using [Collect](/api-reference/go/workflows/Collect) function.

## Parameters

<ParamField path="options" type="[]job.QueryOption">
Options for querying jobs
</ParamField>

## Options

<ParamField path="WithTemporalExtent(temporalExtent query.TemporalExtent)" required>
Specify the time interval for which data should be queried.
Right now, a temporal extent is required for every query.
</ParamField>
<ParamField path="WithAutomationID(automationID uuid.UUID)">
Specify the automation id for which data should be queried.
Only jobs that were created by the specified automation will be returned.
</ParamField>

## Returns

A sequence of jobs.

<RequestExample>
```go Go
import (
"time"
workflows "github.com/tilebox/tilebox-go/workflows/v1"
"github.com/tilebox/tilebox-go/workflows/v1/job"
"github.com/tilebox/tilebox-go/query"
)

interval := query.NewTimeInterval(
time.Now().Add(-24 * time.Hour),
time.Now(),
)

jobs, err := workflows.Collect(
client.Jobs.Query(ctx,
job.WithTemporalExtent(interval),
),
)
```
</RequestExample>
26 changes: 26 additions & 0 deletions api-reference/python/tilebox.workflows/JobClient.find.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: JobClient.find
icon: diagram-project
---

```python
def JobClient.find(job_or_id: Job | str) -> Job
```

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.

## Parameters

<ParamField path="job_or_id" type="Job | str">
The job or job id to get.
</ParamField>

## Returns

A job object.

<RequestExample>
```python Python
job = job_client.find("0195c87a-49f6-5ffa-e3cb-92215d057ea6")
```
</RequestExample>
42 changes: 42 additions & 0 deletions api-reference/python/tilebox.workflows/JobClient.query.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: JobClient.query
icon: diagram-project
---

```python
def JobClient.query(
temporal_extent: TimeIntervalLike | IDIntervalLike,
automation_id: UUID | None = None,
) -> list[Job]
```

Query jobs in the specified interval.

## Parameters

<ParamField path="temporal_extent" type="TimeIntervalLike | IDIntervalLike" required>
The temporal extent to filter jobs by. If an `IDInterval` is given, jobs are filtered by their job id instead of their creation time.
It can be specified in the following ways:
- TimeInterval: interval -> Use the time interval as its given
- DatetimeScalar: [time, time] -> Construct a TimeInterval with start and end time set to the given
value and the end time inclusive
- tuple of two DatetimeScalar: [start, end) -> Construct a TimeInterval with the given start and
end time
- `IDInterval`: interval -> Use the ID interval as its given
- tuple of two UUIDs: [start, end) -> Construct an `IDInterval` with the given start and end id
- tuple of two strings: [start, end) -> Construct an `IDInterval` with the given start and end id
parsed from the strings
</ParamField>
<ParamField path="automation_id" type="UUID | None">
The automation id to filter jobs by. If not provided, jobs from all automations are returned.
</ParamField>

## Returns

A list of jobs.

<RequestExample>
```python Python
jobs = job_client.query(("2025-01-01", "2025-02-01"))
```
</RequestExample>
8 changes: 6 additions & 2 deletions api-reference/python/tilebox.workflows/JobClient.retry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ icon: diagram-project
---

```python
def JobClient.retry(job_or_id: Job | str)
def JobClient.retry(job_or_id: Job | str) -> int
```

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

## Returns

The number of tasks that were rescheduled.

<RequestExample>
```python Python
job_client.retry(job)
nb_rescheduled = job_client.retry(job)
```
</RequestExample>
6 changes: 4 additions & 2 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@
"api-reference/python/tilebox.workflows/JobCache.group",
"api-reference/python/tilebox.workflows/JobCache.__iter__",
"api-reference/python/tilebox.workflows/JobClient.submit",
"api-reference/python/tilebox.workflows/JobClient.find",
"api-reference/python/tilebox.workflows/JobClient.retry",
"api-reference/python/tilebox.workflows/JobClient.cancel",
"api-reference/python/tilebox.workflows/JobClient.visualize"
"api-reference/python/tilebox.workflows/JobClient.visualize",
"api-reference/python/tilebox.workflows/JobClient.query"
]
}
]
Expand Down Expand Up @@ -273,7 +275,7 @@
"api-reference/go/workflows/Jobs.Get",
"api-reference/go/workflows/Jobs.Retry",
"api-reference/go/workflows/Jobs.Cancel",
"api-reference/go/workflows/Jobs.List",
"api-reference/go/workflows/Jobs.Query",
"api-reference/go/workflows/Collect"
]
}
Expand Down
38 changes: 37 additions & 1 deletion workflows/concepts/jobs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,42 @@ myJob, err := client.Jobs.Submit(ctx, "my-job", cluster,

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

## Querying jobs

You can query jobs in a given time range using the `query` method on the job client.

<CodeGroup>
```python Python
jobs = job_client.query(("2025-01-01", "2025-02-01"))
print(jobs)
```
```go Go
import (
"time"
workflows "github.com/tilebox/tilebox-go/workflows/v1"
"github.com/tilebox/tilebox-go/workflows/v1/job"
"github.com/tilebox/tilebox-go/query"
)

interval := query.NewTimeInterval(
time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(2025, 2, 1, 0, 0, 0, 0, time.UTC),
)

jobs, err := workflows.Collect(client.Jobs.Query(ctx,
job.WithTemporalExtent(interval),
))
if err != nil {
slog.Error("Failed to query jobs", slog.Any("error", err))
return
}

for _, job := range jobs {
fmt.Println(job)
}
```
</CodeGroup>

## Retrieving a specific job

When you submit a job, it's assigned a unique identifier that can be used to retrieve it later.
Expand Down Expand Up @@ -522,7 +558,7 @@ job_client.retry(job)
job_client.display(job)
```
```go Go
err = client.Jobs.Retry(ctx, job.ID)
_, err := client.Jobs.Retry(ctx, job.ID)
```
</CodeGroup>

Expand Down