Skip to content

Commit c021039

Browse files
committed
Merge pull request #451 from satra/enh/provenance
WIP: Enh/provenance
2 parents d41fa81 + 2785f04 commit c021039

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2707
-439
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ before_install:
2020
- source /etc/fsl/fsl.sh
2121
- virtualenv --system-site-packages ~/virtualenv/this
2222
- source ~/virtualenv/this/bin/activate
23-
install: python setup.py build_ext --inplace
24-
script: make test
23+
- pip install https://github.com/RDFLib/rdflib/archive/master.zip
24+
- pip install https://github.com/satra/prov/archive/enh/rdf.zip
25+
install:
26+
- source ~/virtualenv/this/bin/activate
27+
- python setup.py build_ext --inplace
28+
script:
29+
- source ~/virtualenv/this/bin/activate
30+
- make test
31+

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Next release
33

44
* ENH: SelectFiles: a streamlined version of DataGrabber
55
* ENH: New interfaces: spm.ResliceToReference
6+
* ENH: W3C PROV support with optional RDF export built into Nipype
67

78
* FIX: Deals properly with 3d files in SPM Realign
89

doc/devel/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ conventions documented in the `NIPY Developers Guide
1717
writing_custom_interfaces
1818
gitwash/index
1919
architecture
20+
provenance
2021

2122

2223
.. include:: ../links_names.txt

doc/devel/provenance.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
================
2+
W3C PROV support
3+
================
4+
5+
Overview
6+
--------
7+
8+
We're using the the `W3C PROV data model <http://www.w3.org/TR/prov-dm/`_ to
9+
capture and represent provenance in Nipype.
10+
11+
For an overview see:
12+
13+
`PROV-DM overview <http://slideviewer.herokuapp.com/url/raw.github.com/ni-/notebooks/master/NIDMIntro.ipynb>`_
14+
15+
Each interface writes out a provenance.json (currently prov-json) or
16+
provenance.rdf (if rdflib is available) file. The workflow engine can also
17+
write out a provenance of the workflow if instructed.
18+
19+
This is very much an experimental feature as we continue to refine how exactly
20+
the provenance should be stored and how such information can be used for
21+
reporting or reconstituting workflows.

doc/sphinxext/autosummary_generate.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def main():
5454
for name, path in sorted(names.items()):
5555
if options.output_dir is not None:
5656
path = options.output_dir
57-
57+
5858
if not os.path.isdir(path):
5959
os.makedirs(path)
6060

@@ -121,7 +121,7 @@ def get_documented_in_docstring(name, module=None, filename=None):
121121
"""
122122
Find out what items are documented in the given object's docstring.
123123
See `get_documented_in_lines`.
124-
124+
125125
"""
126126
try:
127127
obj, real_name = import_by_name(name)
@@ -136,7 +136,7 @@ def get_documented_in_docstring(name, module=None, filename=None):
136136
def get_documented_in_lines(lines, module=None, filename=None):
137137
"""
138138
Find out what items are documented in the given lines
139-
139+
140140
Returns
141141
-------
142142
documented : dict of list of (filename, title, keyword, toctree)
@@ -153,15 +153,15 @@ def get_documented_in_lines(lines, module=None, filename=None):
153153
module_re = re.compile(r'^\.\.\s+(current)?module::\s*([a-zA-Z0-9_.]+)\s*$')
154154
autosummary_item_re = re.compile(r'^\s+([_a-zA-Z][a-zA-Z0-9_.]*)\s*.*?')
155155
toctree_arg_re = re.compile(r'^\s+:toctree:\s*(.*?)\s*$')
156-
156+
157157
documented = {}
158-
158+
159159
current_title = []
160160
last_line = None
161161
toctree = None
162162
current_module = module
163163
in_autosummary = False
164-
164+
165165
for line in lines:
166166
try:
167167
if in_autosummary:

doc/sphinxext/inheritance_diagram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def my_import(name):
4848
"""Module importer - taken from the python documentation.
4949
5050
This function allows importing names with dots in them."""
51-
51+
5252
mod = __import__(name)
5353
components = name.split('.')
5454
for comp in components[1:]:
@@ -103,7 +103,7 @@ def _import_class_or_module(self, name):
103103
# second call will force the equivalent of 'import a.b' to happen
104104
# after the top-level import above.
105105
my_import(fullname)
106-
106+
107107
except ImportError:
108108
raise ValueError(
109109
"Could not import class or module '%s' specified for inheritance diagram" % name)

doc/sphinxext/ipython_console_highlighting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Third party
1313
from pygments.lexer import Lexer, do_insertions
14-
from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer,
14+
from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer,
1515
PythonTracebackLexer)
1616
from pygments.token import Comment, Generic
1717

@@ -47,7 +47,7 @@ class IPythonConsoleLexer(Lexer):
4747
4848
- It assumes the default IPython prompts, not customized ones.
4949
"""
50-
50+
5151
name = 'IPython console session'
5252
aliases = ['ipython']
5353
mimetypes = ['text/x-ipython-console']

doc/users/install.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,20 @@ recommendations.
112112
Must Have
113113
~~~~~~~~~
114114

115-
Python_ 2.6 -2.7
115+
Python_ 2.6 - 2.7
116116

117-
Nibabel_ 1.0 - 1.2
117+
Nibabel_ 1.0 - 1.4
118118
Neuroimaging file i/o library
119119

120-
NetworkX_ 1.0 - 1.4
120+
NetworkX_ 1.0 - 1.8
121121
Python package for working with complex networks.
122122

123-
NumPy_ 1.3 - 1.6
123+
NumPy_ 1.3 - 1.7
124124

125-
SciPy_ 0.7 - 0.10
125+
SciPy_ 0.7 - 0.12
126126
Numpy and Scipy are high-level, optimized scientific computing libraries.
127127

128-
Enthought_ Traits_ 4.0.0
128+
Enthought_ Traits_ 4.0.0 - 4.3.0
129129

130130
.. note::
131131

@@ -135,14 +135,17 @@ Enthought_ Traits_ 4.0.0
135135
Strong Recommendations
136136
~~~~~~~~~~~~~~~~~~~~~~
137137

138-
IPython_ 0.10.2 - 0.13
138+
IPython_ 0.10.2 - 1.0.0
139139
Interactive python environment. This is necessary for some parallel
140140
components of the pipeline engine.
141141

142-
Matplotlib_ 1.0
142+
Matplotlib_ 1.0 - 1.2
143143
Plotting library
144144

145-
Sphinx_
145+
`RDFLib <http://rdflib.readthedocs.org/en/latest/>`_ 4.1
146+
RDFLibrary required for provenance export as RDF
147+
148+
Sphinx_ 1.1
146149
Required for building the documentation
147150

148151
`Graphviz <http://www.graphviz.org/>`_

examples/fmri_fsl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def subjectinfo(subject_id):
633633

634634
if __name__ == '__main__':
635635
l1pipeline.write_graph()
636-
l1pipeline.run()
636+
outgraph = l1pipeline.run()
637637
#l1pipeline.run(plugin='MultiProc', plugin_args={'n_procs':2})
638638

639639

examples/fmri_openfmri.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,13 @@ def get_subs(subject_id, conds, model_id, task_id):
387387
'crashdumps'),
388388
stop_on_first_crash=True)
389389
#wf.run('MultiProc', plugin_args={'n_procs': 4})
390-
wf.run('Linear', plugin_args={'n_procs': 4})
390+
eg = wf.run('Linear')
391391
wf.export('openfmri.py')
392392
wf.write_graph(dotfilename='hgraph.dot', graph2use='hierarchical')
393393
wf.write_graph(dotfilename='egraph.dot', graph2use='exec')
394394
wf.write_graph(dotfilename='fgraph.dot', graph2use='flat')
395395
wf.write_graph(dotfilename='ograph.dot', graph2use='orig')
396+
return eg
396397

397398
if __name__ == '__main__':
398399
import argparse
@@ -403,7 +404,9 @@ def get_subs(subject_id, conds, model_id, task_id):
403404
parser.add_argument('-m', '--model', default=1)
404405
parser.add_argument('-t', '--task', default=1)
405406
args = parser.parse_args()
406-
analyze_openfmri_dataset(data_dir=os.path.abspath(args.datasetdir),
407+
eg = analyze_openfmri_dataset(data_dir=os.path.abspath(args.datasetdir),
407408
subject=args.subject,
408409
model_id=int(args.model),
409410
task_id=int(args.task))
411+
from nipype.pipeline.utils import write_prov
412+
g = write_prov(eg, format='turtle')

0 commit comments

Comments
 (0)