Skip to content

Instantly share code, notes, and snippets.

@PmasonFF
Forked from adammcmaster/org_workflow_stats.py
Last active May 24, 2019 15:46
Show Gist options
  • Save PmasonFF/80601eadf23b6b1dde1ddf6f465c1edb to your computer and use it in GitHub Desktop.
Save PmasonFF/80601eadf23b6b1dde1ddf6f465c1edb to your computer and use it in GitHub Desktop.
Print workflow stats for an organisation
# -*- coding: utf-8 -*-
"""
Requires panoptes-client and (on Python 2) futures.
pip install panoptes-client futures
"""
import sys
import panoptes_client
from panoptes_client import Panoptes, Organization
ORG_ID = 16
Panoptes.connect(
username=u'',
password=u'',
)
print(u"{:<8}{:<28}{:<28}{:<10}{}".format(
'ID',
'Created date',
'Finished date',
'Subjects',
'Workflow name',
))
for project in Organization(ORG_ID).links.projects:
try:
print(u"{}".format(project.display_name))
for workflow in project.links.workflows:
finished_at = workflow.finished_at
if finished_at is None:
finished_at = ''
print(u"{:<8}{:<28}{:<28}{:<10}{}".format(
workflow.id,
workflow.created_at,
finished_at,
workflow.subjects_count,
workflow.display_name,
))
except panoptes_client.panoptes.PanoptesAPIException:
print(sys.exc_info()[1])
# ________________________________________________________
@PmasonFF
Copy link
Author

Added error handling - private projects will result in "project not found" unless the credentials entered in lines 13, 14 allow collaborator or owner access to the project in question.

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