Search…
Check Job Status
On Pollination, a job's status can be checked by using the job's id, owner name, project name, and the API key. You get a job's id once the job is created and submitted to Pollination. Check here to learn how to create and submit a job.
Install the following libraries first
1
pip install streamlit queenbee pollination-streamlit
Copied!
Import necessary libraries
1
import streamlit as st
2
from enum import Enum
3
from typing import Tuple
4
from queenbee.job.job import JobStatusEnum
5
from pollination_streamlit.interactors import Job
6
from pollination_streamlit.api.client import ApiClient
Copied!
Helper function to get job status
1
class SimStatus(Enum):
2
NOTSTARTED = 0
3
INCOPLETE = 1
4
COMPLETE = 2
5
FAILED = 3
6
CANCELLED = 4
7
8
9
def get_job_status(api_key: str, owner: str, project: str,
10
job_id: str) -> Tuple[SimStatus, str]:
11
"""Get the status of a job from Pollination.
12
13
args:
14
api_key: The API key of the user.
15
owner: The owner of the Pollination account.
16
project: The name of the project inside which the job was created.
17
job_id: The id of the job.
18
19
returns:
20
A tuple of two items:
21
22
- The status of the job.
23
24
- URL of the job on Pollination.
25
"""
26
27
job = Job(owner,
28
project,
29
job_id,
30
client=ApiClient(api_token=api_key))
31
32
url = f'https://app.pollination.cloud/projects/{owner}/{project}/jobs/{job_id}'
33
34
if job.status.status in [
35
JobStatusEnum.pre_processing,
36
JobStatusEnum.running,
37
JobStatusEnum.created,
38
JobStatusEnum.unknown]:
39
return SimStatus.INCOPLETE, url
40
41
elif job.status.status == JobStatusEnum.failed:
42
return SimStatus.FAILED, url
43
44
elif job.status.status == JobStatusEnum.cancelled:
45
return SimStatus.CANCELLED, url
46
47
else:
48
return SimStatus.COMPLETE, url
Copied!
The Streamlit form above will render the following interface;
Providing API key, owner, project and job_id in the form above will serve the following result;
Copy link