Skip to content

Commit 58853ff

Browse files
authored
πŸ“ Document expected_outputs.log (#273)
2 parents ffc4383 + c13b6a3 commit 58853ff

File tree

6 files changed

+55
-2
lines changed

6 files changed

+55
-2
lines changed
Lines changed: 1 addition & 0 deletions
Loading

β€Ždocs/_sources/conf.pyβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,15 @@ def _unireplace(release_note, unireplace):
575575
""".format(
576576
versions=', '.join(gh_tags[:5])
577577
)
578+
579+
def setup(app):
580+
from CPAC.utils.monitoring import custom_logging
581+
582+
# initilaize class to make factory functions available to Sphinx
583+
ml = custom_logging.MockLogger('test', 'test.log', 0, '/tmp')
584+
for method in [
585+
method for method in
586+
set(dir(ml)) - set(dir(custom_logging.MockLogger)) if
587+
method not in ['name', 'handlers']
588+
]:
589+
setattr(custom_logging.MockLogger, method, getattr(ml, method))

β€Ždocs/_sources/developer/index.rstβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Contents:
1919
pipeline
2020
nodes
2121
random_state
22+
logging
2223
workflow_documentation
2324
workflows/index
2425
xcpqc
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Logging
2+
=======
3+
4+
Most C-PAC logging is handled by the built-in Python ``logging`` library. When logging, take care to choose an appropriate ``getLogger`` function or method. While :py:func:`CPAC.utils.monitoring.custom_logging.getLogger` and ``nipype.utils.logger.Logging.getLogger`` each fall back on ``logging.getLogger``,
5+
6+
.. raw:: html
7+
8+
<div class="flowchart-container"><object data="../_static/flowcharts/getLogger.svg" type="image/svg+xml"></object></div>
9+
10+
11+
each have their own intended use cases.
12+
13+
Loggers are singletons that are never freed during a script execution, and so creating lots of loggers will use up memory which can’t then be freed.
14+
15+
-- `Logging Cookbook: Creating a lot of loggers <https://docs.python.org/3/howto/logging-cookbook.html#creating-a-lot-of-loggers>`_
16+
17+
``CPAC.utils.monitoring.custom_logging.getLogger`` will look for a :py:class:`CPAC.utils.monitoring.custom_logging.MockLogger` before falling back on ``logging.getLogger``.
18+
19+
A ``CPAC.utils.monitoring.custom_logging.MockLogger`` can be used in place of a :py:class:`logging.Logger` and deleted from memory when no longer needed. For an example, see how ``missing_log`` is created and deleted in :py:func:`CPAC.pipeline.check_outputs.check_outputs`.
20+
21+
``nipype.utils.logger.Logging.getLogger`` will only consider loggers that are part of the class instance calling the method.
22+
23+
.. autofunction:: CPAC.utils.monitoring.custom_logging.getLogger
24+
25+
.. autoclass:: CPAC.utils.monitoring.custom_logging.MockLogger
26+
:special-members: __init__
27+
:members:
28+
:inherited-members:
29+
30+
.. automethod:: nipype.utils.logger.Logging.getLogger
31+
32+
.. automethod:: nipype.utils.logger.Logging.__init__
33+
34+
.. autofunction:: logging.getLogger

β€Ždocs/_sources/user/output_dir.rstβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ The output structure of C-PAC β‰₯ 1.8.0 is based on `the Brain Imaging Data Stru
1212
1313
└── pipeline-name
1414
β”œβ”€β”€ log
15-
β”‚Β Β  └── pipeline_pipeline-name
16-
β”‚Β Β  └── subject_session
15+
β”‚ └── pipeline_pipeline-name
16+
β”‚ └── subject_session
1717
└── output
1818
└── cpac_pipeline-name
1919
└── subject_session
2020
β”œβ”€β”€ anat
2121
└── func
2222
23+
24+
Beginning with C-PAC v1.8.4, C-PAC generates a YAML file called ``expected_outputs.yml`` near the beginning of each participant run. This file is stored in the participant's log directory and lists derivative modalities (e.g., ``anat``, ``func``) and partial BIDS filenames for outputs expected to be generated and stored for each modality given the provided data and pipeline configuration. At the end of the run (or when crashing gracefully), C-PAC will check the output directory for the presence of all expected outputs. If any expected outputs are missing, C-PAC will generate a ``missing_ouputs.yml`` file listing those missing outputs, also in the participant's log directory.
25+
26+
2327
.. note::
2428

2529
If any nodes use more memory at runtime than C-PAC estimates, C-PAC will report those instances near the end of the log in the terminal and in a log file called ``callback.log.resource_overusage.txt`` (beginning in v1.8.0). Please `report excessive memory usage <https://github.com/FCP-INDI/C-PAC/issues/new>`_ to the C-PAC team.

β€Žrequirements.txtβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
docutils<0.18
12
m2r
23
mistune==0.8.4
34
numpydoc

0 commit comments

Comments
Β (0)