Skip to content

Commit 3cf1113

Browse files
authored
Merge pull request #445 from vkarak/bugfix/config-logdir
[bugfix] Fix reading of 'logdir' setting from system config
2 parents e792fd3 + 447bc05 commit 3cf1113

File tree

9 files changed

+50
-25
lines changed

9 files changed

+50
-25
lines changed

docs/configure.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ The valid attributes of a system are the following:
103103
* ``prefix``: Default regression prefix for this system (default ``.``).
104104
* ``stagedir``: Default stage directory for this system (default :class:`None`).
105105
* ``outputdir``: Default output directory for this system (default :class:`None`).
106-
* ``logdir``: Default performance logging directory for this system (default :class:`None`).
106+
* ``perflogdir``: Default directory prefix for storing performance logs for this system (default :class:`None`).
107+
* ``logdir``: `Deprecated since version 2.14 please use` ``perflogdir`` `instead.`
107108
* ``resourcesdir``: Default directory for storing large resources (e.g., input data files, etc.) needed by regression tests for this system (default ``.``).
108109
* ``partitions``: A set of key/value pairs defining the partitions of this system and their properties (default ``{}``).
109110
Partition configuration is discussed in the `next section <#partition-configuration>`__.
@@ -112,7 +113,7 @@ The valid attributes of a system are the following:
112113
.. versionadded:: 2.8
113114
The ``modules_system`` key was introduced for specifying custom modules systems for different systems.
114115

115-
For a more detailed description of the ``prefix``, ``stagedir``, ``outputdir`` and ``logdir`` directories, please refer to the `"Running ReFrame" <running.html#configuring-reframe-directories>`__ section.
116+
For a more detailed description of the ``prefix``, ``stagedir``, ``outputdir`` and ``perflogdir`` directories, please refer to the `"Configuring ReFrame Directories" <running.html#configuring-reframe-directories>`__ and `"Performance Logging" <running.html#performance-logging>`__ sections.
116117

117118
Partition Configuration
118119
-----------------------

docs/running.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ The attributes of this handler are the following:
625625
* ``prefix``: This is the directory prefix (usually dynamic) where the performance logs of a test will be stored.
626626
This attribute accepts any of the check-specific formatting placeholders described `above <#common-log-handler-attributes>`__.
627627
This allows you to create dynamic paths based on the current system, partition and/or programming environment a test executes.
628-
This dynamic prefix is appended to the "global" performance log directory prefix, configurable through the ``--perflogdir`` option.
628+
This dynamic prefix is appended to the "global" performance log directory prefix, configurable through the ``--perflogdir`` option or the ``perflogdir`` attribute of the `system configuration <configuring.html#system-configuration>`__.
629629
The default configuration of ReFrame for performance logging (shown in the previous listing) generates the following files:
630630

631631
.. code-block:: none
@@ -719,7 +719,7 @@ This handler introduces three new attributes:
719719
This log handler uses internally `pygelf <https://pypi.org/project/pygelf/>`__, so this Python module must be available, otherwise this log handler will be ignored.
720720
`GELF <http://docs.graylog.org/en/latest/pages/gelf.html>`__ is a format specification for log messages that are sent over the network.
721721
The ReFrame's ``graylog`` handler sends log messages in JSON format using an HTTP POST request to the specified host and port.
722-
More details on this log format may be found `here <http://docs.graylog.org/en/latest/pages/gelf.html#gelf-payload-specification>`__
722+
More details on this log format may be found `here <http://docs.graylog.org/en/latest/pages/gelf.html#gelf-payload-specification>`__.
723723

724724

725725
Asynchronous Execution of Regression Checks

reframe/core/config.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import reframe.core.debug as debug
55
import reframe.core.fields as fields
66
import reframe.utility as util
7-
from reframe.core.exceptions import ConfigError, ReframeError, ReframeFatalError
7+
from reframe.core.exceptions import (ConfigError,
8+
ReframeError,
9+
ReframeFatalError,
10+
user_deprecation_warning)
811

912

1013
_settings = None
@@ -135,11 +138,12 @@ def create_env(system, partition, name):
135138
# The System's constructor provides also reasonable defaults, but
136139
# since we are going to set them anyway from the values provided by
137140
# the configuration, we should set default values here. The stage,
138-
# output and log directories default to None, since they are
139-
# going to be set dynamically by the ResourcesManager
141+
# output and log directories default to None, since they are going
142+
# to be set dynamically by the runtime.
140143
sys_prefix = config.get('prefix', '.')
141144
sys_stagedir = config.get('stagedir', None)
142145
sys_outputdir = config.get('outputdir', None)
146+
sys_perflogdir = config.get('perflogdir', None)
143147
sys_logdir = config.get('logdir', None)
144148
sys_resourcesdir = config.get('resourcesdir', '.')
145149
sys_modules_system = config.get('modules_system', None)
@@ -155,7 +159,14 @@ def create_env(system, partition, name):
155159
sys_outputdir = os.path.expandvars(sys_outputdir)
156160

157161
if sys_logdir:
158-
sys_logdir = os.path.expandvars(sys_logdir)
162+
user_deprecation_warning(
163+
"`logdir' attribute in system config is deprecated; "
164+
"please use `perflogdir' instead"
165+
)
166+
sys_perflogdir = os.path.expandvars(sys_logdir)
167+
168+
if sys_perflogdir:
169+
sys_perflogdir = os.path.expandvars(sys_perflogdir)
159170

160171
if sys_resourcesdir:
161172
sys_resourcesdir = os.path.expandvars(sys_resourcesdir)
@@ -166,7 +177,7 @@ def create_env(system, partition, name):
166177
prefix=sys_prefix,
167178
stagedir=sys_stagedir,
168179
outputdir=sys_outputdir,
169-
logdir=sys_logdir,
180+
perflogdir=sys_perflogdir,
170181
resourcesdir=sys_resourcesdir,
171182
modules_system=sys_modules_system)
172183
for part_name, partconfig in config.get('partitions', {}).items():

reframe/core/runtime.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ class HostResources:
9494
prefix = fields.AbsolutePathField('prefix')
9595
outputdir = fields.AbsolutePathField('outputdir', allow_none=True)
9696
stagedir = fields.AbsolutePathField('stagedir', allow_none=True)
97+
perflogdir = fields.AbsolutePathField('perflogdir', allow_none=True)
9798

9899
def __init__(self, prefix=None, stagedir=None,
99-
outputdir=None, timefmt=None):
100+
outputdir=None, perflogdir=None, timefmt=None):
100101
self.prefix = prefix or '.'
101102
self.stagedir = stagedir
102103
self.outputdir = outputdir
103-
self._timestamp = datetime.now()
104+
self.perflogdir = perflogdir
104105
self.timefmt = timefmt
106+
self._timestamp = datetime.now()
105107

106108
def _makedir(self, *dirs, wipeout=False):
107109
ret = os.path.join(*dirs)
@@ -131,6 +133,13 @@ def stage_prefix(self):
131133
else:
132134
return os.path.join(self.stagedir, self.timestamp)
133135

136+
@property
137+
def perflog_prefix(self):
138+
if self.perflogdir is None:
139+
return os.path.join(self.prefix, 'perflogs')
140+
else:
141+
return self.perflogdir
142+
134143
def make_stagedir(self, *dirs, wipeout=True):
135144
return self._makedir(self.stage_prefix, *dirs, wipeout=wipeout)
136145

@@ -165,7 +174,7 @@ def __init__(self, dict_config, sysdescr=None):
165174

166175
self._resources = HostResources(
167176
self._system.prefix, self._system.stagedir,
168-
self._system.outputdir, self._system.logdir)
177+
self._system.outputdir, self._system.perflogdir)
169178
self._modules_system = ModulesSystem.create(
170179
self._system.modules_system)
171180

reframe/core/systems.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ class System:
154154
_prefix = fields.StringField('_prefix')
155155
_stagedir = fields.StringField('_stagedir', allow_none=True)
156156
_outputdir = fields.StringField('_outputdir', allow_none=True)
157-
_logdir = fields.StringField('_logdir', allow_none=True)
157+
_perflogdir = fields.StringField('_perflogdir', allow_none=True)
158158
_resourcesdir = fields.StringField('_resourcesdir')
159159

160160
def __init__(self, name, descr=None, hostnames=[], partitions=[],
161-
prefix='.', stagedir=None, outputdir=None, logdir=None,
161+
prefix='.', stagedir=None, outputdir=None, perflogdir=None,
162162
resourcesdir='.', modules_system=None):
163163
self._name = name
164164
self._descr = descr or name
@@ -168,7 +168,7 @@ def __init__(self, name, descr=None, hostnames=[], partitions=[],
168168
self._prefix = prefix
169169
self._stagedir = stagedir
170170
self._outputdir = outputdir
171-
self._logdir = logdir
171+
self._perflogdir = perflogdir
172172
self._resourcesdir = resourcesdir
173173

174174
# Set parent system for the given partitions
@@ -211,9 +211,9 @@ def outputdir(self):
211211
return self._outputdir
212212

213213
@property
214-
def logdir(self):
214+
def perflogdir(self):
215215
"""The ReFrame log directory prefix associated with this system."""
216-
return self._logdir
216+
return self._perflogdir
217217

218218
@property
219219
def resourcesdir(self):

reframe/frontend/cli.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,10 @@ def main():
297297
# NOTE: we need resources to be configured in order to set the global
298298
# perf. logging prefix correctly
299299
if options.perflogdir:
300-
logging.LOG_CONFIG_OPTS['handlers.filelog.prefix'] = (
301-
os.path.expandvars(options.perflogdir))
302-
else:
303-
logging.LOG_CONFIG_OPTS['handlers.filelog.prefix'] = (
304-
os.path.join(rt.resources.prefix, 'perflogs'))
300+
rt.resources.perflogdir = os.path.expandvars(options.perflogdir)
301+
302+
logging.LOG_CONFIG_OPTS['handlers.filelog.prefix'] = (rt.resources.
303+
perflog_prefix)
305304

306305
if hasattr(settings, 'perf_logging_config'):
307306
try:

unittests/resources/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ class ReframeSettings:
3131
# order to test different aspects of the framework.
3232
'descr': 'Fake system for unit tests',
3333
'hostnames': ['testsys'],
34-
'prefix': '.rfm_testing/install',
34+
'prefix': '.rfm_testing',
3535
'resourcesdir': '.rfm_testing/resources',
36+
'perflogdir': '.rfm_testing/perflogs',
3637
'partitions': {
3738
'login': {
3839
'scheduler': 'local',

unittests/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def test_load_success(self):
2222

2323
system = self.site_config.systems['testsys']
2424
self.assertEqual(2, len(system.partitions))
25+
self.assertEqual('.rfm_testing', system.prefix)
26+
self.assertEqual('.rfm_testing/resources', system.resourcesdir)
27+
self.assertEqual('.rfm_testing/perflogs', system.perflogdir)
2528

2629
part_login = self.get_partition(system, 'login')
2730
part_gpu = self.get_partition(system, 'gpu')

unittests/test_runtime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ def test_hostsystem_api(self):
1010
system = rt.runtime().system
1111
self.assertEqual('testsys', system.name)
1212
self.assertEqual('Fake system for unit tests', system.descr)
13-
self.assertEqual('.rfm_testing/resources', system.resourcesdir)
1413
self.assertEqual(2, len(system.partitions))
1514
self.assertIsNotNone(system.partition('login'))
1615
self.assertIsNotNone(system.partition('gpu'))
1716
self.assertIsNone(system.partition('foobar'))
1817

1918
# Test delegation to the underlying System
20-
self.assertEqual('.rfm_testing/install', system.prefix)
19+
self.assertEqual('.rfm_testing', system.prefix)
20+
self.assertEqual('.rfm_testing/resources', system.resourcesdir)
21+
self.assertEqual('.rfm_testing/perflogs', system.perflogdir)

0 commit comments

Comments
 (0)