Skip to content

Commit

Permalink
Added "guard rails" logging for project
Browse files Browse the repository at this point in the history
Added "guard rails" logging for project
  • Loading branch information
ericdrosas87 committed Jul 2, 2024
1 parent eeaeb7f commit b715cd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 14 additions & 5 deletions src/rubin/citsci/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit b715cd8

Please sign in to comment.