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 `finalized == FALSE`.
jobs <- get_jobs(item)
current_jobs <- 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

See Also