Activities

This example shows how to create an Activity record, linking inputs, outputs and related files using the Ovation command line interface (CLI)

Create a new activity

First, we'll create the activity record. After the record is created, we'll add inputs and outputs (if needed). Files related to the activity (procotols, code, etc.) can be specified at activity creation. You can reference an existing revisions' UUIDs or local files. Local files will be uploaded to the project as part of activity creation.

create_activity creates the activity and associates it with the given Project.


In [ ]:
PROJECT='c77efb46-fa1b-4e1a-8640-87acf8da1abf' # Project UUID
NAME='Example activity' # Activity NAME
USER='changeme@example.com' # Your Email

# Create 
ACTIVITY=$(python -m ovation.cli create-activity -u "$USER" --concise -p "$PROJECT" -n "$NAME" --related example.m)

Add inputs

You can add inputs to the Activity to indicate file Revisions or Sources that served as the input to the experiment or analysis described by the activity. You can specify existing (already uploaded) Revisions or existing Sources by UUID. You can also provide path(s) of local file(s) when adding inputs. Local files will be uploaded to Ovation as new File instances before being added as activity inputs.

This example adds an existing Revision or Source as the activity input:


In [ ]:
PROJECT='d1e0c30b-6e0b-46f1-bdca-33228e4da361' # Revision or Source UUID

# Add input
python -m ovation.cli add-input -u "$USER" "$ACTIVITY" "$UUID"

This example uploads a local file and adds it as an activity input:


In [ ]:
$PATH=example/input.csv

# Add input
python -m ovation.cli add-input -u "$USER" "$ACTIVITY" "$UUID"

Add outputs

You can add outputs to the Activity to indicate file Revisions or Sources that are the result of the experiment or analysis described by the activity. You can specify existing (already uploaded) Revisions or existing Sources by UUID. You can also provide path(s) of local file(s) when adding inputs. Local files will be uploaded to Ovation as new File instances before being added as activity outputs.

This example adds an existing Revision as an activity output:


In [ ]:
PROJECT='05890b26-d628-4925-9a85-a10ed6075edb' # Revision or Source UUID

# Add input
python -m ovation.cli add-output -u "$USER" "$ACTIVITY" "$UUID"

This example adds a local file an activity output:


In [ ]:
$PATH=example/output.csv

# Add input
python -m ovation.cli add-input -u "$USER" "$ACTIVITY" "$UUID"

A complete workflow

It's common to create an activity from exsting inputs, download the activity inputs and run an analysis and then upload the results as outputs to the activity. This example shows this common workflow:

First, we create the activity and upload inputs:


In [ ]:
PROJECT='c77efb46-fa1b-4e1a-8640-87acf8da1abf' # Project UUID
NAME='Example activity' # Activity NAME
USER='changeme@example.com' # Your Email

# Create a new activity and assign its UUID to $ACTIVITY
ACTIVITY=$(python -m ovation.cli create-activity -u "$USER" --concise -p "$PROJECT" -n "$NAME" --related example.m)

# Add inputs
$PATH=example/input.csv

# Add input
python -m ovation.cli add-input -u "$USER" "$ACTIVITY" "$UUID"

Now, our collaborator can download the inputs, and run analysis:


In [ ]:
# Downloads inputs/ outputs/ and related/
python -m ovation.cli download -u "$USER" "$ACTIVITY"

# Run analysis on /inputs using /related

Now, our collaborator uploads the results of the analysis as activity outputs:


In [ ]:
$PATH=outputs/result.csv

# Add input
python -m ovation.cli add-output -u "$USER" "$ACTIVITY" "$PATH"