Projects

This example shows how to work with projects

We can find particular jobs in a project, or perhaps only retrieve projects that match certain criteria.

from pathlib import Path
from pyro_dash_py import PyroDash
import os

from pyro_dash_py.project import ProjectFilter

apikey = os.environ.get("PYRO_API_KEY")
if apikey is None:
    raise SystemError("PYRO_API_KEY missing!")

# initialize comms with the pyro-dashboard api
pyro = PyroDash(
    host="https://dev-api.dashboard.pyrologix.com",
    email="jack.campanella@pyrologix.com",
    apikey=apikey,
)

# Get all of my projects (returns maximum of 20)
projects = pyro.projects.filter(num_per_page=20)
for project in projects:
    print(f"{project.name} - ({project.id})")

# Get all projects that have wildest in the name (not case sensitive)
filters = [ProjectFilter("name", "wildest")]
wildest_projects = pyro.projects.filter(filters)

for project in wildest_projects:
    print(f"{project.name} - ({project.id})")

# find a specific project by name (expecting exactly 1 result)
my_project = pyro.projects.find_by_name("3.3.2 testing")
print(my_project)

# find jobs in that project
jobs = my_project.list_jobs()
for job in jobs:
    print("Job in that project", job.name, job.id)
    # keep in mind, you have access to all of the methods
    # available to a job such as job.start, job.add_file, job.logs, etc