Skip to content

Instantly share code, notes, and snippets.

@cbare
Created January 28, 2013 22:06
Show Gist options
  • Select an option

  • Save cbare/4659607 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/4659607 to your computer and use it in GitHub Desktop.
## first, let's dump some data into a file
python generate_random_data.py > data.txt
## Create a project in synapse
synapse create -name "provenance test project" Project
## Add a couple of entities to our project, first a Data entity...
synapse add -parentid syn1661878 -name "data.txt" -description "My randomly generated data" data.txt
## ...and a Code entity that holds the script
synapse add -parentid syn1661878 -name "generate_random_data.py" -description "Generate data randomly from the normal distribution" -type "Code" generate_random_data.py
## Add provenance to the effect that the data entity was generated by executing the code entity
synapse set-provenance -id syn1661879 -name 'generate random data' -description 'A fabulous script generated this random data' -executed syn1661881
## retrieve the activity like this:
synapse get-provenance -id syn1661879
## next, derive a new data entity from the existing one by squaring all the elements
python square.py data.txt > squares.txt
## To save a step, you can also specify provenance in the 'synapse add' command
## by first adding the source entities, in this case just the one code entity
synapse add -parentid syn1661878 -name "square.py" -description "Square input data" -type "Code" square.py
## Then add the derived entity, specifying the source entities as either -executed or -used
## Be sure to include the '--' separator between the arguments to -executed (there can be several)
## and the required file argument 'data.txt'
synapse add -parentid syn1661878 -name "squares.txt" -description "Squares of randomly generated data" -executed syn1661884 -used <synBBBBB> -- squares.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment