Skip to content

Commit a44b546

Browse files
committed
Merge pull request #873 from nicholsn/fix/prov-terms
Update provenance terms to be consistent with NIDM style
2 parents 3331825 + e6703ff commit a44b546

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nipype/utils/provenance.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,16 @@ def add_results(self, results):
256256
inputs = results.inputs
257257
outputs = results.outputs
258258
classname = interface.__name__
259+
modulepath = "{0}.{1}".format(interface.__module__, interface.__name__)
260+
activitytype = ''.join([i.capitalize() for i in modulepath.split('.')])
259261

260262
a0_attrs = {nipype_ns['module']: interface.__module__,
261263
nipype_ns["interface"]: classname,
264+
pm.PROV["type"]: nipype_ns[activitytype],
262265
pm.PROV["label"]: classname,
263266
nipype_ns['duration']: safe_encode(runtime.duration),
264-
nipype_ns['working_directory']: safe_encode(runtime.cwd),
265-
nipype_ns['return_code']: safe_encode(runtime.returncode),
267+
nipype_ns['workingDirectory']: safe_encode(runtime.cwd),
268+
nipype_ns['returnCode']: safe_encode(runtime.returncode),
266269
nipype_ns['platform']: safe_encode(runtime.platform),
267270
nipype_ns['version']: safe_encode(runtime.version),
268271
}
@@ -274,7 +277,7 @@ def add_results(self, results):
274277

275278
try:
276279
a0_attrs.update({nipype_ns['command']: safe_encode(runtime.cmdline)})
277-
a0_attrs.update({nipype_ns['command_path']:
280+
a0_attrs.update({nipype_ns['commandPath']:
278281
safe_encode(runtime.command_path)})
279282
a0_attrs.update({nipype_ns['dependencies']:
280283
safe_encode(runtime.dependencies)})
@@ -286,7 +289,7 @@ def add_results(self, results):
286289
id = get_id()
287290
env_collection = self.g.collection(id)
288291
env_collection.add_extra_attributes({pm.PROV['type']:
289-
nipype_ns['environment'],
292+
nipype_ns['Environment'],
290293
pm.PROV['label']: "Environment"})
291294
self.g.used(a0, id)
292295
# write environment entities
@@ -299,7 +302,7 @@ def add_results(self, results):
299302
'MKL_NUM_THREADS', 'OMP_NUM_THREADS']:
300303
continue
301304
in_attr = {pm.PROV["label"]: key,
302-
nipype_ns["environment_variable"]: key,
305+
nipype_ns["environmentVariable"]: key,
303306
pm.PROV["value"]: safe_encode(val)}
304307
id = get_attr_id(in_attr)
305308
self.g.entity(id, in_attr)
@@ -309,14 +312,14 @@ def add_results(self, results):
309312
id = get_id()
310313
input_collection = self.g.collection(id)
311314
input_collection.add_extra_attributes({pm.PROV['type']:
312-
nipype_ns['inputs'],
315+
nipype_ns['Inputs'],
313316
pm.PROV['label']: "Inputs"})
314317
# write input entities
315318
for idx, (key, val) in enumerate(sorted(inputs.items())):
316319
in_entity = prov_encode(self.g, val).get_identifier()
317320
self.g.hadMember(input_collection, in_entity)
318321
used_attr = {pm.PROV["label"]: key,
319-
nipype_ns["in_port"]: key}
322+
nipype_ns["inPort"]: key}
320323
self.g.used(activity=a0, entity=in_entity,
321324
other_attributes=used_attr)
322325
# write output entities
@@ -326,7 +329,7 @@ def add_results(self, results):
326329
if not isinstance(outputs, dict):
327330
outputs = outputs.get_traitsfree()
328331
output_collection.add_extra_attributes({pm.PROV['type']:
329-
nipype_ns['outputs'],
332+
nipype_ns['Outputs'],
330333
pm.PROV['label']:
331334
"Outputs"})
332335
self.g.wasGeneratedBy(output_collection, a0)
@@ -335,14 +338,14 @@ def add_results(self, results):
335338
out_entity = prov_encode(self.g, val).get_identifier()
336339
self.g.hadMember(output_collection, out_entity)
337340
gen_attr = {pm.PROV["label"]: key,
338-
nipype_ns["out_port"]: key}
341+
nipype_ns["outPort"]: key}
339342
self.g.generation(out_entity, activity=a0,
340343
other_attributes=gen_attr)
341344
# write runtime entities
342345
id = get_id()
343346
runtime_collection = self.g.collection(id)
344347
runtime_collection.add_extra_attributes({pm.PROV['type']:
345-
nipype_ns['runtime'],
348+
nipype_ns['Runtime'],
346349
pm.PROV['label']:
347350
"RuntimeInfo"})
348351
self.g.wasGeneratedBy(runtime_collection, a0)

0 commit comments

Comments
 (0)