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

GUID = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"

client = connect.Client()
content = client.content.get(GUID)
jobs = content.jobs
>>> import polars as pl
>>> pl.DataFrame(jobs)
shape: (1, 20)
┌──────────┬────────┬────────┬──────────────────┬───┬───────────┬─────────┬───────┬─────────────────┐
id       ┆ ppid   ┆ pid    ┆ key              ┆ … ┆ hostname  ┆ cluster ┆ image ┆ run_as          │
------------              ┆   ┆ ------------
strstrstrstr              ┆   ┆ str       ┆ null    ┆ null  ┆ str
╞══════════╪════════╪════════╪══════════════════╪═══╪═══════════╪═════════╪═══════╪═════════════════╡
32587071900506900522 ┆ 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)
client <- connect()

GUID <- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
item <- content_item(client, GUID)

# 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 `status == 0`.
jobs <- get_jobs(item)
current_jobs <- jobs |>
  filter(status == 0)
> current_jobs
# A tibble: 23 × 20
   id       ppid    pid   key   remote_id app_id variant_id bundle_id start_time          end_time            last_heartbeat_time queued_time queue_name tag     exit_code status
   <chr>    <chr>   <chr> <chr> <chr>     <chr>  <chr>      <chr>     <dttm>              <dttm>              <dttm>              <dttm>      <chr>      <chr>       <int>  <int>
 1 40870303 3519450 3519… WVL7… NA        52389  0          127015    2024-12-06 17:23:49 NA                  2024-12-06 17:26:09 NA          NA         run_app        NA      0
 2 40870302 3090873 3090… OXrb… NA        52389  0          127015    2024-12-06 17:23:38 NA                  2024-12-06 17:26:18 NA          NA         run_app        NA      0
# ℹ 4 more variables: hostname <chr>, cluster <chr>, image <chr>, run_as <chr>

See Also