diff --git a/README.md b/README.md index 879a8d3..127aeda 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ the API behind [the Zooniverse](https://www.zooniverse.org/). The Panoptes CLI is written in Python, so in order to install it you will need to install Python 3 along with `pip`. Please note: while still compatible with Python 2.7, we have ended support for use of the CLI with this deprecated version. -macOS and Linux already come with Python installed, so run this to see if you +macOS and Linux already come with Python installed, so run this to see if you already have everything you need: ``` @@ -18,7 +18,7 @@ $ python --version && pip --version If you see an error like `python: command not found` or `pip: command not found` then you will need to install this: -- [Python installation](https://wiki.python.org/moin/BeginnersGuide/Download) +- [Python installation](https://wiki.python.org/moin/BeginnersGuide/Download) (or [Miniconda installation](https://docs.conda.io/en/latest/miniconda.html)) - [Pip installation](https://pip.pypa.io/en/stable/installing/) @@ -280,6 +280,34 @@ $ panoptes workflow retire-subjects 101 2001 2002 $ panoptes workflow unretire-subjects 101 2001 2002 ``` +### Run aggregations + +``` +# for running batch aggregation on workflow with id 101, user id 2001 and conditional delete flag -d +$ panoptes workflow run-aggregation 101 2001 -d +``` + +### Get batch aggregations + +``` +# for fetching existing batch aggregation on workflow with id 101 +$ panoptes workflow get-batch-aggregations 101 +``` + +### Check batch aggregation run status + +``` +# for checking existing batch aggregation status on workflow with id 101 +$ panoptes workflow check-batch-aggregation-run-status 101 +``` + +### Get batch aggregation links + +``` +# for fetching links to the run aggregation on workflow with id 101 +$ panoptes workflow get-batch-aggregation-links 101 +``` + #### By subject sets, i.e. for all the linked subjects in a subject set ``` @@ -325,7 +353,7 @@ Optional: include an updated_since timestamp (string) to include only observatio $ panoptes inaturalist import-observations --taxon-id 46017 --subject-set-id 999999 --updated-since 2022-12-03 ``` -The `--updated-since` argument is a standard ISO timestamp, such as '2022-12-03' or `2022-12-03T18:56:06+00:00'. It is passed directly to the iNat Observations v2 API as the 'updated_since' query parameter. +The `--updated-since` argument is a standard ISO timestamp, such as '2022-12-03' or `2022-12-03T18:56:06+00:00'. It is passed directly to the iNat Observations v2 API as the 'updated_since' query parameter. diff --git a/panoptes_cli/commands/workflow.py b/panoptes_cli/commands/workflow.py index d02c513..6a48593 100644 --- a/panoptes_cli/commands/workflow.py +++ b/panoptes_cli/commands/workflow.py @@ -4,7 +4,7 @@ from panoptes_cli.scripts.panoptes import cli from panoptes_client import Workflow - +from panoptes_client.panoptes import PanoptesAPIException @cli.group() def workflow(): @@ -230,6 +230,49 @@ def delete(force, workflow_ids): workflow.delete() +@workflow.command() +@click.argument('workflow-id', required=True, type=int) +@click.argument('user-id', required=True, type=int) +@click.option( + '--delete-if-exists', + '-d', + is_flag=True, + help='Delete if it exists.') +def run_aggregation(workflow_id, user_id, delete_if_exists): + """Kicks off a new aggregation job.""" + + agg = Workflow(workflow_id).run_aggregation(user_id, delete_if_exists) + try: + click.echo(agg.raw) + except PanoptesAPIException as err: + click.echo(err) + + +@workflow.command() +@click.argument('workflow-id', required=True, type=int) +def get_batch_aggregations(workflow_id): + """Gets existing batch aggregations.""" + + agg = Workflow(workflow_id).get_batch_aggregations() + click.echo(agg.object_list) + + +@workflow.command() +@click.argument('workflow-id', required=True, type=int) +def check_batch_aggregation_run_status(workflow_id): + """Fetches the run status of existing aggregation.""" + + click.echo(Workflow(workflow_id).check_batch_aggregation_run_status()) + + +@workflow.command() +@click.argument('workflow-id', required=True, type=int) +def get_batch_aggregation_links(workflow_id): + """Fetches batch aggregation download links.""" + + click.echo(Workflow(workflow_id).get_batch_aggregation_links()) + + def echo_workflow(workflow): click.echo( u'{} {}'.format(