Search…
Download an Output
In this section, we will see how we can download an output of a recipe that has successfully finished running on Pollination.
Install the following libraries first
1
pip install streamlit pollination-streamlit
Copied!
Importing necessary libraries
1
import zipfile
2
import streamlit as st
3
from pollination_streamlit.interactors import Job
4
from pollination_streamlit.api.client import ApiClient
Copied!
Helper function to download the output of a job
1
def download_output(api_key: str, owner: str, project: str, job_id: str, run_index: int,
2
output_name: str, target_folder: str) -> None:
3
"""Download output from a job on Pollination.
4
5
Args:
6
api_key: The API key of the Pollination account.
7
owner: The owner of the Pollination account.
8
project: The name of the project inside which the job was created.
9
job_id: The id of the job.
10
run_index: The index of the run inside the job.
11
output_name: The name of the output you wish to download. You can find the names
12
of all the outputs either on the job page or on the recipe page.
13
target_folder: The folder where the output will be downloaded.
14
"""
15
job = Job(owner, project, job_id, ApiClient(api_token=api_key))
16
run = job.runs[run_index]
17
output = run.download_zipped_output(output_name)
18
19
with zipfile.ZipFile(output) as zip_folder:
20
zip_folder.extractall(target_folder)
Copied!
Streamlit form to download the output of a job
1
with st.form('download-result'):
2
api_key = st.text_input('api_key', type='password')
3
owner = st.text_input('owner')
4
project = st.text_input('project')
5
job_id = st.text_input('job_id')
6
run_index = st.number_input('run_index', value=0)
7
output_name = st.text_input('output_name')
8
target_folder = st.text_input('target_folder', value='.')
9
10
submit_button = st.form_submit_button(
11
label='Submit')
12
13
if submit_button:
14
download_output(owner, project, job_id, api_key,
15
run_index, output_name, target_folder)
Copied!
The streamlit form above will render the following interface;
Providing the following inputs will download a file named "daylight_factor.vtkjs" in your current working directory;
Copy link