Skip to content

Instantly share code, notes, and snippets.

@adammcmaster
Created May 3, 2019 11:36
Show Gist options
  • Save adammcmaster/605695db28d73a88c9020fe1da53c72d to your computer and use it in GitHub Desktop.
Save adammcmaster/605695db28d73a88c9020fe1da53c72d to your computer and use it in GitHub Desktop.
Print workflow stats for an organisation
"""
Requires panoptes-client and (on Python 2) futures.
pip install panoptes-client futures
"""
from panoptes_client import Panoptes, Organization
ORG_ID = 16
Panoptes.connect(
username='',
password='',
)
print(u"{:<8}{:<28}{:<28}{:<10}{}".format(
'ID',
'Created date',
'Finished date',
'Subjects',
'Workflow name',
))
for project in Organization(ORG_ID).links.projects:
print("{}".format(project.display_name))
for workflow in project.links.workflows:
print(u"{:<8}{:<28}{:<28}{:<10}{}".format(
workflow.id,
workflow.created_at,
workflow.finished_at,
workflow.subjects_count,
workflow.display_name,
))
@PmasonFF
Copy link

When I run this in python3 some workflow.finished_at are NoneType and it bombed. so I tried to fork this and fix it thinking I would be able to issue a pull request if successful... but this is a gist and I don't know howto work it all. So a version is in the fork you can see here which runs for me in both 3.7 and 2.7. I also added a bunch of u's for string literals - some had them and some did not - I am not al all sure they are needed but explicit is better than yada yada yada.... The main change was to test for None type finished _at's which may be giving Michael D a problem too!

@PmasonFF
Copy link

Please see my latest attempt to add the functionality requested by Laura Trouille here:
https://github.com/PmasonFF/Zooniverse-data-digging/blob/master/Panoptes_client_examples/org_workflow_stats_expanded.py
with a readme file here:
https://github.com/PmasonFF/Zooniverse-data-digging/blob/master/Panoptes_client_examples/org_workflow_stats_expanded_readme.md

Adam please have a look and pass them on to Michael Denslowm or request changes as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment