# Check Study 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](https://docs.pollination.solutions/user-manual/developers/apps/create-job) to learn how to create and submit a job.

Install the following libraries first

```python
pip install streamlit queenbee pollination-streamlit
```

Import necessary libraries

```python
import streamlit as st
from enum import Enum
from typing import Tuple
from queenbee.job.job import JobStatusEnum
from pollination_streamlit.interactors import Job
from pollination_streamlit.api.client import ApiClient
```

Helper function to get job status

```python
class SimStatus(Enum):
    NOTSTARTED = 0
    INCOPLETE = 1
    COMPLETE = 2
    FAILED = 3
    CANCELLED = 4


def get_job_status(api_key: str, owner: str, project: str,
                   job_id: str) -> Tuple[SimStatus, str]:
    """Get the status of a job from Pollination.

    args:
        api_key: The API key of the user.
        owner: The owner of the Pollination account.
        project: The name of the project inside which the job was created.
        job_id: The id of the job.

    returns:
        A tuple of two items:

        -   The status of the job.

        -   URL of the job on Pollination.
    """

    job = Job(owner,
              project,
              job_id,
              client=ApiClient(api_token=api_key))

    url = f'https://app.pollination.solutions/projects/{owner}/{project}/jobs/{job_id}'

    if job.status.status in [
            JobStatusEnum.pre_processing,
            JobStatusEnum.running,
            JobStatusEnum.created,
            JobStatusEnum.unknown]:
        return SimStatus.INCOPLETE, url

    elif job.status.status == JobStatusEnum.failed:
        return SimStatus.FAILED, url

    elif job.status.status == JobStatusEnum.cancelled:
        return SimStatus.CANCELLED, url

    else:
        return SimStatus.COMPLETE, url
```

The Streamlit form above will render the following interface;

![](https://2884583650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaZZSUE1L_iKrqfreV9%2Fuploads%2Fgit-blob-374c6408387b75b7d506ebfa9c8b11e355dc97a2%2Fjob_status.png?alt=media\&token=4e47adf3-ec45-424b-b2af-e447e939bf66)

Providing API key, owner, project and job\_id in the form above will serve the following result;

![](https://2884583650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaZZSUE1L_iKrqfreV9%2Fuploads%2Fgit-blob-6935075423d0a31be13a410c2d1d981a9a4e22a4%2Fjob_status_result.png?alt=media\&token=b8962926-9c4a-45ab-96b2-d3cae6cb81c3)
