Skip to content

Commit

Permalink
Added func for logging and selecting project slug
Browse files Browse the repository at this point in the history
Addedd func for logging and selecting project slug name from list
  • Loading branch information
ericdrosas87 committed Jul 2, 2024
1 parent 8129d88 commit 63e2d11
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 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.0"
version = "0.5.1"
readme = "README.md"
dependencies = [
"panoptes_client",
Expand Down
34 changes: 31 additions & 3 deletions src/rubin/citsci/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,45 @@ def login_to_zooniverse(self, slug_name, email):
if(valid_email):
self.email = email
self.client = panoptes_client.Panoptes.connect(login="interactive")
print("You now are logged in to the Zooniverse platform.")

if slug_name is not "":
self.project = Project.find(slug=slug_name)
self.project_id = self.project.id
else:
print("No project was provided! Run the create_new_project_from_template() cell if you would like to create a new one.")

print("You now are logged in to the Zooniverse platform.")
self.__log_slug_names()
return
else:
print("Invalid email address! Please check the email address you provided and ensure it is correct.")
return

def __log_slug_names(self):
projects = self.client.get(f"/projects?owner={self.client.username}")
slugnames = []
has_projects = False

print("\n*==* Your Project Slugs *==*\n")
for proj in projects:
if type(proj) is dict:
for p in proj["projects"]:
has_projects = True
slugnames.append(p["slug"])
print(p["slug"])
print("\n*==========================*\n")

slug_name = input("Which project would you like to send data to (copy & paste the slug name here)?")

if has_projects == True:
if slug_name in slugnames:
self.project = Project.find(slug=slug_name)
self.project_id = self.project.id
print(f"Current project set to: {slug_name}")
else:
print("\n### Invalid project slug name! Please re-run this cell and copy-paste a slug name from the provided list.")
else:
print("You do not have any projects on the Zooniverse platform. Please run the cell that creates a new project based on the project template.")
return

def __check_package_version(self):
try:
installed_version = version('rubin.citsci')
Expand Down

0 comments on commit 63e2d11

Please sign in to comment.