Skip to content

Repository files navigation

panoptes-python-client

Installation

Install latest release:

$ pip install panoptes-client

Install HEAD directly from GitHub:

$ pip install git+git://github.com/zooniverse/panoptes-python-client.git

Usage Examples

Print all project titles:

frompanoptes_clientimportProjectforprojectinProject.where():
printproject.title

Find a project by slug and print all its workflow names:

frompanoptes_clientimportProjectproject=Project.find(slug='zooniverse/example')
forworkflowinproject.links.workflows:
printworkflow.display_name

Create a project:

frompanoptes_clientimportProject, PanoptesPanoptes.connect(username='example', password='example')
p=Project()
p.display_name='test project'p.description='a test project'p.primary_language='en'p.private=Truep.save()

Create a subject set and upload a new subject to it:

frompanoptes_clientimportSubjectSet, Subject, Project, PanoptesPanoptes.connect(username='example', password='example')
project=Project.find(slug='zooniverse/example')
subject_set=SubjectSet()
subject_set.links.project=projectsubject_set.display_name='My new subject set'subject_set.save()
subject=Subject()
subject.links.project=projectsubject.add_location('/path/to/local/image.jpg')
# You can set whatever metadata you want, or none at allsubject.metadata['image_id'] =1234subject.metadata['image_title'] ='My image'subject.save()
# SubjectSet.add() can take a list of Subjects, or just one.subject_set.add(subject)

Project owners with client credentials can update their users' project settings (workflow_id only):

frompanoptes_clientimportPanoptes, User, Subject, ProjectPreferencesPanoptes.connect(client_id="example",client_secret="example")
user=User.find("1234")
project=Project.find("1234")
new_settings= {"workflow_id": "1234"}
ProjectPreferences.save_settings(project=project, user=user, settings=new_settings)

Alternatively, the project id and user id can be passed in directly if they are already known:

ProjectPreferences.save_settings(project=project_id, user=user_id, settings=new_settings)

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages