Viewing Jobs for Content
Problem
You want to find jobs for a content item, for instance, if you need to use the job key in another recipe.
Solution
Use the content GUID to look up jobs for the content item. Get the GUID from the Dashboard’s Info tab, or by following Viewing Content Information.
from posit import connect
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
GUID
= connect.Client()
client = client.get(f"v1/content/{GUID}/jobs/")
response = response.json() result
>>> import polars as pl
>>> pl.DataFrame(result)
1, 20)
shape: (
┌──────────┬────────┬────────┬──────────────────┬───┬───────────┬─────────┬───────┬─────────────────┐id ┆ ppid ┆ pid ┆ key ┆ … ┆ hostname ┆ cluster ┆ image ┆ run_as │
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ str ┆ ┆ str ┆ null ┆ null ┆ str │
│
╞══════════╪════════╪════════╪══════════════════╪═══╪═══════════╪═════════╪═══════╪═════════════════╡32587071 ┆ 900506 ┆ 900522 ┆ zcc5ysQm5fSzTEan ┆ … ┆ example ┆ null ┆ null ┆ posit-connect │
│ └──────────┴────────┴────────┴──────────────────┴───┴───────────┴─────────┴───────┴─────────────────┘
library(connectapi)
library(dplyr)
<- connect()
client
<- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
GUID <- content_item(client, GUID)
item
# The `jobs` API call returns all jobs for a content item, including jobs that
# have finished. We can filter only for currently-running jobs by filtering
# for `finalized == FALSE`.
<- get_jobs(item)
jobs <- jobs |>
current_jobs filter(finalized == FALSE)
> current_jobs
# A tibble: 2 × 14
id pid key app_id app_guid variant_id bundle_id start_time end_time tag exit_code finalized hostname variant_key<int> <int> <chr> <int> <chr> <int> <int> <dttm> <dttm> <chr> <int> <lgl> <chr> <chr>
1 32593289 1179184 wiSznovdN3IxIliY 21537 154bd2af-e8fa-4aa4-aab8-dcef701f4af9 0 102197 2024-06-20 21:51:33 NA run_app NA FALSE connect01 NA
2 32586170 863024 DZnNuuVtA6apt2Ew 21537 154bd2af-e8fa-4aa4-aab8-dcef701f4af9 0 102197 2024-06-20 14:22:53 NA run_app NA FALSE connect01 NA