|
| 1 | +import functools |
1 | 2 | import sys |
2 | 3 | import inspect |
3 | 4 | import typing |
|
10 | 11 | from rdflib import RDF, RDFS, DCTERMS |
11 | 12 |
|
12 | 13 | from fairworkflows import namespaces, LinguisticSystem, LINGSYS_ENGLISH, LINGSYS_PYTHON |
13 | | -from fairworkflows.config import DUMMY_FAIRWORKFLOWS_URI, IS_FAIRSTEP_RETURN_VALUE_PARAMETER_NAME |
| 14 | +from fairworkflows.config import DUMMY_FAIRWORKFLOWS_URI, IS_FAIRSTEP_RETURN_VALUE_PARAMETER_NAME, \ |
| 15 | + LOGGER |
14 | 16 | from fairworkflows.rdf_wrapper import RdfWrapper, replace_in_rdf |
15 | 17 |
|
| 18 | + |
16 | 19 | class FairVariable: |
17 | 20 | """Represents a variable. |
18 | 21 |
|
@@ -425,16 +428,24 @@ def _modify_function(func): |
425 | 428 | inputs = _extract_inputs_from_function(func, kwargs) |
426 | 429 | outputs = _extract_outputs_from_function(func, kwargs) |
427 | 430 |
|
428 | | - func._fairstep = FairStep(uri='http://www.example.org/unpublished-'+func.__name__, |
429 | | - label=label, |
430 | | - description=description, |
431 | | - is_pplan_step=is_pplan_step, |
432 | | - is_manual_task=is_manual_task, |
433 | | - is_script_task=is_script_task, |
434 | | - language=LINGSYS_PYTHON, |
435 | | - inputs=inputs, |
436 | | - outputs=outputs) |
437 | | - |
| 431 | + fairstep = FairStep(uri='http://www.example.org/unpublished-'+func.__name__, |
| 432 | + label=label, |
| 433 | + description=description, |
| 434 | + is_pplan_step=is_pplan_step, |
| 435 | + is_manual_task=is_manual_task, |
| 436 | + is_script_task=is_script_task, |
| 437 | + language=LINGSYS_PYTHON, |
| 438 | + inputs=inputs, |
| 439 | + outputs=outputs) |
| 440 | + |
| 441 | + @functools.wraps |
| 442 | + def _add_logging(func): |
| 443 | + def _wrapper(*func_args, **func_kwargs): |
| 444 | + LOGGER.info(f'Running step: {func.__name__}') |
| 445 | + return func(*func_args, **func_kwargs) |
| 446 | + return _wrapper |
| 447 | + func = _add_logging(func) |
| 448 | + func._fairstep = fairstep |
438 | 449 | return noodles.schedule(func) |
439 | 450 |
|
440 | 451 | return _modify_function |
|
0 commit comments