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
pip install streamlit pollination-streamlit
Importing necessary libraries
import zipfile
import streamlit as st
from pollination_streamlit.interactors import Job
from pollination_streamlit.api.client import ApiClient
Helper function to download the output of a job
def download_output(api_key: str, owner: str, project: str, job_id: str, run_index: int,
output_name: str, target_folder: str) -> None:
"""Download output from a job on Pollination.
Args:
api_key: The API key of the Pollination account.
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.
run_index: The index of the run inside the job.
output_name: The name of the output you wish to download. You can find the names
of all the outputs either on the job page or on the recipe page.
target_folder: The folder where the output will be downloaded.
"""
job = Job(owner, project, job_id, ApiClient(api_token=api_key))
run = job.runs[run_index]
output = run.download_zipped_output(output_name)
with zipfile.ZipFile(output) as zip_folder:
zip_folder.extractall(target_folder)