Viewing Jobs
Problem
You want to view Jobs associated with your Content.
Solution
Important
This action requires owner, collaborator, or administrator privileges.
Note
Requires posit-sdk>=0.6.0
First, obtain the content
object. In this example, we get the content using it’s GUID. Call the jobs
attribute to view the jobs associated with your content.
from posit import connect
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
GUID
= connect.Client()
client = client.content.get(GUID)
content = content.jobs jobs
>>> import polars as pl
>>> pl.DataFrame(jobs)
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 │
│ └──────────┴────────┴────────┴──────────────────┴───┴───────────┴─────────┴───────┴─────────────────┘
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.
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