コード例 #1
0
def test_coerce_interval():
    """Test coerce_interval."""
    validator = VDR()
    # The good
    for value, result in [('', None), ('P3D', DurationFloat(259200)),
                          ('PT10M10S', DurationFloat(610))]:
        assert validator.coerce_interval(value, ['whatever']) == result
    # The bad
    for value in ['None', '5 days', '20', '-12']:
        with pytest.raises(IllegalValueError):
            validator.coerce_interval(value, ['whatever'])
コード例 #2
0
 def test_coerce_interval(self):
     """Test coerce_interval."""
     validator = VDR()
     # The good
     for value, result in [('', None), ('P3D', DurationFloat(259200)),
                           ('PT10M10S', DurationFloat(610))]:
         self.assertEqual(validator.coerce_interval(value, ['whatever']),
                          result)
     # The bad
     for value in ['None', '5 days', '20', '-12']:
         self.assertRaises(IllegalValueError, validator.coerce_interval,
                           value, ['whatever'])
コード例 #3
0
def test_coerce_interval_list():
    """Test coerce_interval_list."""
    validator = VDR()
    # The good
    for value, results in [
            ('', []),
            ('P3D', [DurationFloat(259200)]),
            ('P3D, PT10M10S', [DurationFloat(259200), DurationFloat(610)]),
            ('25*PT30M,10*PT1H',
             [DurationFloat(1800)] * 25 + [DurationFloat(3600)] * 10)]:
        items = validator.coerce_interval_list(value, ['whatever'])
        for item, result in zip(items, results):
            assert pytest.approx(item, result)
    # The bad
    for value in ['None', '5 days', '20', 'PT10S, -12']:
        with pytest.raises(IllegalValueError):
            validator.coerce_interval_list(value, ['whatever'])
コード例 #4
0
 'err-script': [VDR.V_STRING],
 'exit-script': [VDR.V_STRING],
 'pre-script': [VDR.V_STRING],
 'script': [VDR.V_STRING],
 'post-script': [VDR.V_STRING],
 'extra log files': [VDR.V_STRING_LIST],
 'work sub-directory': [VDR.V_STRING],
 'meta': {
     'title': [VDR.V_STRING, ''],
     'description': [VDR.V_STRING, ''],
     'URL': [VDR.V_STRING, ''],
     '__MANY__': [VDR.V_STRING, ''],
 },
 'simulation': {
     'default run length': [VDR.V_INTERVAL,
                            DurationFloat(10)],
     'speedup factor': [VDR.V_FLOAT],
     'time limit buffer': [VDR.V_INTERVAL,
                           DurationFloat(30)],
     'fail cycle points': [VDR.V_STRING_LIST],
     'fail try 1 only': [VDR.V_BOOLEAN, True],
     'disable task event handlers': [VDR.V_BOOLEAN, True],
 },
 'environment filter': {
     'include': [VDR.V_STRING_LIST],
     'exclude': [VDR.V_STRING_LIST],
 },
 'job': {
     'batch system': [VDR.V_STRING, 'background'],
     'batch submit command template': [VDR.V_STRING],
     'execution polling intervals': [VDR.V_INTERVAL_LIST, None],
コード例 #5
0
    for value, result in [
            ('', None),
            ('P3D', DurationFloat(259200)),
            ('PT10M10S', DurationFloat(610))]:
        assert validator.coerce_interval(value, ['whatever']) == result
    # The bad
    for value in ['None', '5 days', '20', '-12']:
        with pytest.raises(IllegalValueError):
            validator.coerce_interval(value, ['whatever'])


@pytest.mark.parametrize(
    'value, expected',
    [
        ('', []),
        ('P3D', [DurationFloat(259200)]),
        ('P3D, PT10M10S', [DurationFloat(259200), DurationFloat(610)]),
        ('25*PT30M,10*PT1H',
         [DurationFloat(1800)] * 25 + [DurationFloat(3600)] * 10)
    ]
)
def test_coerce_interval_list(value: str, expected: List[DurationFloat]):
    """Test coerce_interval_list."""
    assert VDR.coerce_interval_list(value, ['whatever']) == approx(expected)


@pytest.mark.parametrize(
    'value',
    ['None', '5 days', '20', 'PT10S, -12']
)
def test_coerce_interval_list__bad(value: str):
コード例 #6
0
from cylc.flow.parsec.config import ParsecConfig
from cylc.flow.parsec.exceptions import ParsecError
from cylc.flow.parsec.upgrade import upgrader
from cylc.flow.parsec.validate import (
    DurationFloat, CylcConfigValidator as VDR, cylc_config_validate)

# Nested dict of spec items.
# Spec value is [value_type, default, allowed_2, allowed_3, ...]
# where:
# - value_type: value type (compulsory).
# - default: the default value (optional).
# - allowed_2, ...: the only other allowed values of this setting (optional).
SPEC = {
    # suite
    'process pool size': [VDR.V_INTEGER, 4],
    'process pool timeout': [VDR.V_INTERVAL, DurationFloat(600)],
    # client
    'disable interactive command prompts': [VDR.V_BOOLEAN, True],
    # suite
    'run directory rolling archive length': [VDR.V_INTEGER, -1],
    # suite-task communication
    'task messaging': {
        'retry interval': [VDR.V_INTERVAL, DurationFloat(5)],
        'maximum number of tries': [VDR.V_INTEGER, 7],
        'connection timeout': [VDR.V_INTERVAL, DurationFloat(30)],
    },

    # suite
    'cylc': {
        'UTC mode': [VDR.V_BOOLEAN],
        'health check interval': [VDR.V_INTERVAL, DurationFloat(600)],
コード例 #7
0
       Prior to Cylc 8, ``global.cylc`` was named ``global.rc``, but that name
       is no longer supported.
''') as SPEC:

    # suite
    Conf('process pool size',
         VDR.V_INTEGER,
         4,
         desc='''
        Maximum number of concurrent processes used to execute external job
        submission, event handlers, and job poll and kill commands - see
        :ref:`Managing External Command Execution`.
    ''')
    Conf('process pool timeout',
         VDR.V_INTERVAL,
         DurationFloat(600),
         desc='''
        Interval after which long-running commands in the process pool will be
        killed - see :ref:`Managing External Command Execution`.

        .. note::
           The default is set quite high to avoid killing important
           processes when the system is under load.
    ''')
    Conf('run directory rolling archive length',
         VDR.V_INTEGER,
         -1,
         desc='''
        The number of old run directory trees to retain at start-up.
    ''')
コード例 #8
0
        ''')
        Conf('process pool size',
             VDR.V_INTEGER,
             4,
             desc='''
            Maximum number of concurrent processes used to execute external job
            submission, event handlers, and job poll and kill commands - see
            :ref:`Managing External Command Execution`.

            .. versionchanged:: 8.0.0

               Moved here from the top level.
        ''')
        Conf('process pool timeout',
             VDR.V_INTERVAL,
             DurationFloat(600),
             desc='''
            Interval after which long-running commands in the process pool
            will be killed - see :ref:`Managing External Command Execution`.

            .. note::
               The default is set quite high to avoid killing important
               processes when the system is under load.

            .. versionchanged:: 8.0.0

               Moved here from the top level.
        ''')
        Conf('auto restart delay',
             VDR.V_INTERVAL,
             desc='''
コード例 #9
0
       The ``global.cylc`` file can be templated using Jinja2 variables.
       See :ref:`Jinja`.

    .. note::

       Prior to Cylc 8, ``global.cylc`` was named ``global.rc``, but that name
       is no longer supported.
''') as SPEC:

    # suite
    Conf('process pool size', VDR.V_INTEGER, 4, desc='''
        Maximum number of concurrent processes used to execute external job
        submission, event handlers, and job poll and kill commands - see
        :ref:`Managing External Command Execution`.
    ''')
    Conf('process pool timeout', VDR.V_INTERVAL, DurationFloat(600), desc='''
        Interval after which long-running commands in the process pool will be
        killed - see :ref:`Managing External Command Execution`.

        .. note::
           The default is set quite high to avoid killing important
           processes when the system is under load.
    ''')
    Conf('run directory rolling archive length', VDR.V_INTEGER, -1, desc='''
        The number of old run directory trees to retain at start-up.
    ''')

    with Conf('scheduler', desc='''
        Default values for entries in :cylc:conf:`flow.cylc[scheduler]`
        section. This should not be confused with scheduling in the
        ``flow.cylc`` file.
コード例 #10
0
     'abort on inactivity': [VDR.V_BOOLEAN],
     'mail events': [VDR.V_STRING_LIST, None],
     'mail from': [VDR.V_STRING],
     'mail smtp': [VDR.V_STRING],
     'mail to': [VDR.V_STRING],
     'mail footer': [VDR.V_STRING],
 },
 'reference test': {
     'suite shutdown event handler':
     [VDR.V_STRING, 'cylc hook check-triggering'],
     'required run mode':
     [VDR.V_STRING, '', 'live', 'simulation', 'dummy-local', 'dummy'],
     'allow task failures': [VDR.V_BOOLEAN],
     'expected task failures': [VDR.V_STRING_LIST],
     'live mode suite timeout': [VDR.V_INTERVAL,
                                 DurationFloat(60)],
     'dummy mode suite timeout': [VDR.V_INTERVAL,
                                  DurationFloat(60)],
     'dummy-local mode suite timeout':
     [VDR.V_INTERVAL, DurationFloat(60)],
     'simulation mode suite timeout':
     [VDR.V_INTERVAL, DurationFloat(60)],
 },
 'authentication': {
     # Allow owners to grant public shutdown rights at the most, not
     # full control.
     'public': ([VDR.V_STRING, ''] + [
         level.name.lower().replace('_', '-') for level in [
             Priv.IDENTITY, Priv.DESCRIPTION, Priv.STATE_TOTALS,
             Priv.READ, Priv.SHUTDOWN
         ]
コード例 #11
0
ファイル: suite.py プロジェクト: shadowscape/cylc-flow
 'env-script': [VDR.V_STRING],
 'err-script': [VDR.V_STRING],
 'exit-script': [VDR.V_STRING],
 'pre-script': [VDR.V_STRING],
 'script': [VDR.V_STRING],
 'post-script': [VDR.V_STRING],
 'extra log files': [VDR.V_STRING_LIST],
 'work sub-directory': [VDR.V_STRING],
 'meta': {
     'title': [VDR.V_STRING, ''],
     'description': [VDR.V_STRING, ''],
     'URL': [VDR.V_STRING, ''],
     '__MANY__': [VDR.V_STRING, ''],
 },
 'simulation': {
     'default run length': [VDR.V_INTERVAL, DurationFloat(10)],
     'speedup factor': [VDR.V_FLOAT],
     'time limit buffer': [VDR.V_INTERVAL, DurationFloat(30)],
     'fail cycle points': [VDR.V_STRING_LIST],
     'fail try 1 only': [VDR.V_BOOLEAN, True],
     'disable task event handlers': [VDR.V_BOOLEAN, True],
 },
 'environment filter': {
     'include': [VDR.V_STRING_LIST],
     'exclude': [VDR.V_STRING_LIST],
 },
 'job': {
     'batch system': [VDR.V_STRING, 'background'],
     'batch submit command template': [VDR.V_STRING],
     # TODO All the remaining items to be moved to top level of TASK
     # When platforms work is completed.
コード例 #12
0
ファイル: globalcfg.py プロジェクト: retro486/cylc-flow
from cylc.flow.parsec.exceptions import ParsecError
from cylc.flow.parsec.upgrade import upgrader
from cylc.flow.parsec.validate import (DurationFloat, CylcConfigValidator as
                                       VDR, cylc_config_validate)

# Nested dict of spec items.
# Spec value is [value_type, default, allowed_2, allowed_3, ...]
# where:
# - value_type: value type (compulsory).
# - default: the default value (optional).
# - allowed_2, ...: the only other allowed values of this setting (optional).
SPEC = {
    # suite
    'process pool size': [VDR.V_INTEGER, 4],
    'process pool timeout': [VDR.V_INTERVAL,
                             DurationFloat(600)],
    # client
    'disable interactive command prompts': [VDR.V_BOOLEAN, True],
    # suite
    'run directory rolling archive length': [VDR.V_INTEGER, -1],
    # suite-task communication
    'task messaging': {
        'retry interval': [VDR.V_INTERVAL, DurationFloat(5)],
        'maximum number of tries': [VDR.V_INTEGER, 7],
        'connection timeout': [VDR.V_INTERVAL,
                               DurationFloat(30)],
    },

    # suite
    'cylc': {
        'UTC mode': [VDR.V_BOOLEAN],