From 751ceb39e3522ee12301b701f976d2c720c2e982 Mon Sep 17 00:00:00 2001 From: Eric Rosas Date: Fri, 13 Sep 2024 13:10:25 -0700 Subject: [PATCH] Added `list_workflows()` function Added `list_workflows()` function --- pyproject.toml | 2 +- src/rubin/citsci/pipeline.py | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a2f3f36..f438451 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ authors = [ ] description = "The companion package to the Rubin citizen science notebooks." -version = "0.6.6" +version = "0.7.0" readme = "README.md" dependencies = [ "panoptes_client", diff --git a/src/rubin/citsci/pipeline.py b/src/rubin/citsci/pipeline.py index 81c29fe..a2c822b 100644 --- a/src/rubin/citsci/pipeline.py +++ b/src/rubin/citsci/pipeline.py @@ -4,7 +4,7 @@ from importlib.metadata import version import google.cloud.storage as storage import panoptes_client -from panoptes_client import Project, SubjectSet, Classification +from panoptes_client import Project, SubjectSet, Classification, Workflow class CitSciPipeline: """ @@ -115,6 +115,28 @@ def login_to_zooniverse(self, email): print("Invalid email address! Please check the email address you provided and ensure it is correct.") return + def list_workflows(self): + """ + If the user has logged into the Zooniverse platform via the login_to_zooniverse() + function and selected a project, then this cell will list all active workflows for + the selected project. + """ + + if self.project is None: + print("Please log in first using login_to_zooniverse() first before attempting to retrieve workflows.") + return + + active_workflows = self.project.raw["links"]["active_workflows"] + if len(active_workflows) > 0: + print("\n*==* Your Workflows *==*\n") + for workflow in active_workflows: + display_name = Workflow.find(workflow).raw["display_name"] + print(f"Workflow ID: {workflow} - Display Name: {display_name}") + print("\n*==========================*\n") + else: + print("There are no active workflows for the project you have selected.") + return + def __log_slug_names(self): projects = self.client.get(f"/projects?owner={self.client.username}") slugnames = []