From b715cd8b3238362c0bec741f010e9f461154cd83 Mon Sep 17 00:00:00 2001 From: Eric Rosas Date: Tue, 2 Jul 2024 15:08:18 -0700 Subject: [PATCH] Added "guard rails" logging for project Added "guard rails" logging for project --- pyproject.toml | 2 +- src/rubin/citsci/pipeline.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b4e15b5..15e1f13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ authors = [ ] description = "The companion package to the Rubin citizen science notebooks." -version = "0.5.2" +version = "0.6.0" readme = "README.md" dependencies = [ "panoptes_client", diff --git a/src/rubin/citsci/pipeline.py b/src/rubin/citsci/pipeline.py index 17f7819..045c50c 100644 --- a/src/rubin/citsci/pipeline.py +++ b/src/rubin/citsci/pipeline.py @@ -56,10 +56,17 @@ def __init__(self): else: self.dev_mode_url = "" - def create_new_project_from_template(self, project_name="crhiggs/template-test"): + def project_sanity_check(self): + if self.project is None or self.project_id == -1: + print("No project has been selected! Either re-run the login cell to select the project you would like to send data to or run the cell that create a project from the Rubin template!") + return False + else: + return True + + def create_new_project_from_template(self, project_id=21302): """ This method will create a new project under the authenticated user's account - based on the provided project template slug. If no project template slug is + based on the provided Zooniverse project ID. If no project template ID is provided then a new project will be created from a Rubin test project template. @@ -68,7 +75,7 @@ def create_new_project_from_template(self, project_name="crhiggs/template-test") Returns an instance of a Zooniverse project. """ - project_template = Project.find(slug=project_name) + project_template = Project.find(id=project_id) self.project = project_template.copy() self.project.save() self.project_id = self.project.id @@ -187,7 +194,7 @@ def write_manifest_file(self, manifest, batch_dir): Returns the relative path to the manifest.csv """ - if self.project == "": + if self.project_sanity_check is False: print("Please create or specify a Zooniverse project before attempting to write a manifest file.") return manifest_filename = 'manifest.csv' @@ -345,7 +352,7 @@ def send_image_data(self, subject_set_name, zip_path, **options): set is available. """ - if self.project == "": + if self.project_sanity_check is False: print("Please create or specify a Zooniverse project before attempting to send image data!") return print("Send the data to Zooniverse") @@ -410,6 +417,8 @@ def zip_image_cutouts(self, batch_dir): to the Zooniverse, and returns the path to the zip file. """ + if self.project_sanity_check is False: + print("WARNING: You haven't specified a project yet, please ensure you have specified a project before proceeding.") self.guid = str(uuid.uuid4()) shutil.make_archive(f"./{self.guid}", 'zip', batch_dir) return [f"./{self.guid}.zip", f"{self.guid}.zip"]