forked from cylc/cylc-flow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobalcfg.py
More file actions
2292 lines (1756 loc) · 79 KB
/
globalcfg.py
File metadata and controls
2292 lines (1756 loc) · 79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Cylc site and user configuration file spec."""
from contextlib import suppress
import os
from pathlib import Path
from sys import stderr
from textwrap import (
dedent,
indent,
)
from typing import (
Any,
Dict,
List,
Optional,
Tuple,
Union,
)
from packaging.version import Version
from cylc.flow import (
LOG,
__version__ as CYLC_VERSION,
)
from cylc.flow.exceptions import GlobalConfigError
from cylc.flow.hostuserutil import get_user_home
from cylc.flow.network.client_factory import CommsMeth
from cylc.flow.parsec.config import (
ConfigNode as Conf,
ParsecConfig,
)
from cylc.flow.parsec.exceptions import (
ItemNotFoundError,
ParsecError,
ValidationError,
)
from cylc.flow.parsec.upgrade import upgrader
from cylc.flow.parsec.util import (
expand_many_section,
printcfg,
)
from cylc.flow.parsec.validate import (
CylcConfigValidator as VDR,
DurationFloat,
Range,
cylc_config_validate,
)
from cylc.flow.pathutil import SYMLINKABLE_LOCATIONS
from cylc.flow.platforms import validate_platforms
from cylc.flow.workflow_events import WorkflowEventHandler
PLATFORM_REGEX_TEXT = '''
Configured names are regular expressions; any match is a valid platform.
They are searched from the bottom up, until the first match is found.'''
# 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).
# Standard executable search paths to pass to job submission subprocesses.
SYSPATH = [
'/bin',
'/usr/bin',
'/usr/local/bin',
'/sbin',
'/usr/sbin',
'/usr/local/sbin'
]
REPLACES = 'This item was previously called '
PLATFORM_REPLACES = (
"(Replaces the deprecated setting "
":cylc:conf:`flow.cylc[runtime][<namespace>]{}`.)"
)
PLATFORM_META_DESCR = '''
Metadata for this platform or platform group.
Allows writers of platform configurations to add information
about platform usage. There are no-preset items because
Cylc does not use any platform (or group) metadata internally.
Users can then see information about defined platforms using::
cylc config -i [platforms]
cylc config -i [platform groups]
.. seealso::
:ref:`AdminGuide.PlatformConfigs`
.. versionadded:: 8.0.0
'''
# ----------------------------------------------------------------------------
# Config items shared between global and workflow config:
SCHEDULER_DESCR = f'''
Settings for the scheduler.
.. note::
Not to be confused with :cylc:conf:`flow.cylc[scheduling]`.
.. versionchanged:: 8.0.0
{REPLACES}``[cylc]``
'''
UTC_MODE_DESCR = '''
If ``True``, UTC will be used as the time zone for timestamps in
the logs. If ``False``, the local/system time zone will be used.
.. seealso::
To set a time zone for cycle points, see
:cylc:conf:`flow.cylc[scheduler]cycle point time zone`.
'''
LOG_RETR_SETTINGS = {
'retrieve job logs': dedent('''
Whether to retrieve job logs from the job platform.
'''),
'retrieve job logs command': dedent('''
The command used to retrieve job logs from the job platform.
'''),
'retrieve job logs max size': dedent('''
The maximum size of job logs to retrieve.
Can be anything
accepted by the ``--max-size=SIZE`` option of ``rsync``.
'''),
'retrieve job logs retry delays': dedent('''
Configure retries for unsuccessful job log retrieval.
If there is a significant delay between job completion and
logs appearing in their final location (due to the job runner)
you can configure time intervals here to delay the first and
subsequent retrieval attempts.
''')
}
EVENTS_DESCR = '''
Configure the workflow event handling system.
'''
EVENTS_SETTINGS: Dict[str, Union[str, Dict[str, Any]]] = { # workflow events
'handlers': '''
Configure :term:`event handlers` that run when certain workflow
events occur.
.. admonition:: Not to be confused with
:class: tip
For *task* events, see
:cylc:conf:`flow.cylc[runtime][<namespace>][events]`.
Event handlers can be held in the workflow ``bin/`` directory,
otherwise it is up to you to ensure their location is in ``$PATH``
(in the shell in which the scheduler runs). They should require
little resource to run and return quickly.
Template variables can be used to configure handlers. For a full list
of supported variables see :ref:`workflow_event_template_variables`.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
''',
'handler events': {
'desc': '''
Specify the events for which workflow event handlers should be
invoked.
.. seealso::
:ref:`user_guide.scheduler.workflow_events.list`
''',
'options': WorkflowEventHandler.EVENTS.copy(),
'depr_options': WorkflowEventHandler.EVENTS_DEPRECATED.copy(),
},
'mail events': {
'desc': '''
Specify the workflow events for which notification emails should
be sent.
.. seealso::
:ref:`user_guide.scheduler.workflow_events.list`
''',
'options': WorkflowEventHandler.EVENTS.copy(),
'depr_options': WorkflowEventHandler.EVENTS_DEPRECATED.copy(),
},
'startup handlers': f'''
Handlers to run at scheduler startup.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``startup handler``.
''',
'shutdown handlers': f'''
Handlers to run at scheduler shutdown.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``shutdown handler``.
''',
'abort handlers': f'''
Handlers to run if the scheduler shuts down with error status due to
a configured timeout or a fatal error condition.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``aborted handler``.
''',
'workflow timeout': '''
Workflow timeout interval. The timer starts counting down at scheduler
startup. It resets on workflow restart.
When the workflow timeout is reached, any configured
`[..]workflow timeout handlers` will be called. Additionally, the
workflow will shut down if `[..]abort on workflow timeout` is set.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionadded:: 8.0.0
''',
'workflow timeout handlers': '''
Handlers to run if the `[..]workflow timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionadded:: 8.0.0
''',
'abort on workflow timeout': '''
Whether the scheduler should shut down immediately with error status if
the :cylc:conf:`[..]workflow timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionadded:: 8.0.0
''',
'stall handlers': f'''
Handlers to run if the scheduler stalls.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``stalled handler``.
''',
'stall timeout': f'''
The length of a timer which starts if the scheduler stalls.
When the stall timeout is reached, any `[..]stall timeout handlers`
will be called. Additionally, the workflow will shut down if
`[..]abort on stall timeout` is set.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``timeout``.
''',
'stall timeout handlers': f'''
Handlers to run if the `[..]stall timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``timeout handler``.
''',
'abort on stall timeout': f'''
Whether the scheduler should shut down immediately with error status if
the `[..]stall timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``abort on timeout``.
''',
'inactivity timeout': f'''
Scheduler inactivity timeout interval. The timer resets when any
workflow activity occurs.
When the inactivity timeout is reached, any
`[..]inactivity timeout handlers` will be called. Additionally, the
workflow will shut down if `[..]abort on inactivity timeout` is set.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES} ``inactivity``.
''',
'inactivity timeout handlers': f'''
Handlers to run if the `[..]inactivity timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``inactivity handler``.
''',
'abort on inactivity timeout': f'''
Whether the scheduler should shut down immediately with error status if
the `[..]inactivity timeout` is reached.
.. seealso::
:ref:`user_guide.scheduler.workflow_events`
.. versionchanged:: 8.0.0
{REPLACES}``abort on inactivity``.
''',
'restart timeout': '''
How long to wait for intervention on restarting a completed workflow.
When a workflow reaches the end of the :term:`graph`, it will
:term:`shut down <shutdown>` automatically. We call such workflows
:ref:`completed <workflow completion>` as there are no more tasks for
Cylc to run.
Completed workflows can be caused by:
* Cylc reaching the end of the :term:`graph`.
* The workflow reaching the
:cylc:conf:`flow.cylc[scheduling]final cycle point`.
* The workflow reaching the
:cylc:conf:`flow.cylc[scheduling]stop after cycle point`.
* Tasks being manually removed :ref:`interventions.remove_tasks`.
When you restart a completed workflow, it will detect that there are no
more tasks to run, and shut itself down again. The ``restart timeout``
delays this shutdown for a configured period allowing you to trigger
more task(s) to run.
.. seealso::
* :ref:`user_guide.scheduler.workflow_events`
* :ref:`workflow completion`
* :ref:`examples.extending-workflow`
.. versionadded:: 8.2.0
.. versionchanged:: 8.5.2
The ``restart timeout`` is now also activated for workflows that
have hit the
:cylc:conf:`flow.cylc[scheduling]stop after cycle point`.
'''
}
MAIL_DESCR = '''
Settings for the scheduler to send event emails.
These settings are used for both workflow and task events.
.. versionadded:: 8.0.0
'''
MAIL_FROM_DESCR = f'''
Specify an alternative ``from`` email address for workflow event notifications.
.. versionchanged:: 8.0.0
{REPLACES}``[cylc][events]mail from``.
'''
MAIL_TO_DESCR = f'''
A list of email addresses that event notifications should be sent to.
.. versionchanged:: 8.0.0
{REPLACES}``[cylc][events]mail to``.
'''
MAIL_FOOTER_DESCR = f'''
Specify a string or string template for footers of emails sent for both
workflow and task events.
Template variables may be used in the mail footer. For a list of supported
variables see :ref:`workflow_event_template_variables`.
Example::
footer = see http://ahost/%(owner)s/notes/%(workflow)s``
.. versionchanged:: 8.0.0
{REPLACES}``[cylc][events]mail footer``.
'''
MAIL_INTERVAL_DESCR = f'''
Gather all task event notifications in the given interval into a single email.
Useful to prevent being overwhelmed by emails.
.. versionchanged:: 8.0.0
{REPLACES}``[cylc]task event mail interval``.
'''
MAIN_LOOP_DESCR = '''
Configuration of main loop plugins for the scheduler.
For a list of built in plugins see :ref:`Main Loop Plugins <BuiltInPlugins>`.
.. versionadded:: 8.0.0
'''
MAIN_LOOP_PLUGIN_DESCR = '''
Configure a main loop plugin.
.. note::
Only the configured list of
:cylc:conf:`global.cylc[scheduler][main loop]plugins`
is loaded when a scheduler is started.
.. versionadded:: 8.0.0
'''
MAIN_LOOP_PLUGIN_INTERVAL_DESCR = '''
Interval at which the plugin is invoked.
.. versionadded:: 8.0.0
'''
DIRECTIVES_DESCR = '''
Job runner (batch scheduler) directives.
Supported for use with job runners:
- pbs
- slurm
- loadleveler
- lsf
- sge
- slurm_packjob
- moab
Directives are written to the top of the job script in the correct format
for the job runner.
Specifying directives individually like this allows use of default directives
for task families which can be individually overridden at lower levels of the
runtime namespace hierarchy.
'''
DIRECTIVES_ITEM_DESCR = '''
Example directives for the built-in job runner handlers are shown in
:ref:`AvailableMethods`.
'''
SUBMISSION_POLL_DESCR = f'''
List of intervals at which to poll status of job submission.
Cylc can poll submitted jobs to catch problems that prevent the submitted job
from executing at all, such as deletion from an external job runner queue.
The last value is used repeatedly until the task starts running.
Multipliers can be used as shorthand as in the example below.
Example::
5*PT2M, PT5M
Note that if the polling
:cylc:conf:`global.cylc[platforms][<platform name>]communication method`
is used then Cylc relies on polling to detect all task state changes,
so you may want to configure more frequent polling.
.. versionchanged:: 8.0.0
{REPLACES}``[runtime][<namespace>][job]submission polling intervals``.
'''
SUBMISSION_RETY_DESCR = f'''
Cylc can automatically resubmit jobs after submission failures.
Submission retry delays is a list of ISO 8601 durations which tell Cylc
how long to wait before the next try.
The job environment variable ``$CYLC_TASK_SUBMIT_NUMBER`` increments with each
job submission attempt.
Tasks only go to the ``submit-failed`` state if job submission fails with no
retries left.
.. versionchanged:: 8.0.0
{REPLACES}``[runtime][<namespace>][job]submission retry delays``.
'''
EXECUTION_POLL_DESCR = f'''
List of intervals at which to poll status of job execution.
Cylc can poll running jobs to catch problems that prevent task messages from
being sent back to the workflow, such as hard job kills, network outages, or
unplanned job host shutdown.
The last interval in the list is used repeatedly until the job completes.
Multipliers can be used as shorthand as in the example below.
Example::
5*PT2M, PT5M
Note that if the polling
:cylc:conf:`global.cylc[platforms][<platform name>]communication method` is
used then Cylc relies on polling to detect all task state changes, so you may
want to configure more frequent polling.
.. versionchanged:: 8.0.0
{REPLACES}``[runtime][<namespace>][job]execution polling intervals``.
'''
TASK_EVENTS_DESCR = '''
Configure the task event handling system.
.. admonition:: Not to be confused with
:class: tip
For *workflow* events, see :cylc:conf:`flow.cylc[scheduler][events]`.
Task :term:`event handlers` are scripts to run when task events occur.
Event handlers can be stored in the workflow ``bin/`` directory, or
anywhere the scheduler environment ``$PATH``. They should return quickly.
Multiple event handlers can be specified as a list of command line templates.
For supported template variables see :ref:`user_guide.runtime.\
event_handlers.task_event_handling.template_variables`.
Python template substitution syntax is used:
`String Formatting Operations in the Python documentation
<https://docs.python.org/3/library/stdtypes.html
#printf-style-string-formatting>`_.
'''
TASK_EVENTS_SETTINGS = {
'handlers': '''
Commands to run on task :cylc:conf:`[..]handler events`.
A command or list of commands to run for each task event handler
set in
:cylc:conf:`flow.cylc[runtime][<namespace>][events]handler events`.
Information about the event can be provided to the command
using :ref:`user_guide.runtime.event_handlers.\
task_event_handling.template_variables`.
For more information, see
:ref:`user_guide.runtime.task_event_handling`.
Example::
echo %(event)s occurred in %(workflow)s >> my-log-file
''',
'handler events': '''
A list of events for which :cylc:conf:`[..]handlers` are run.
See :ref:`user_guide.runtime.task_event_handling.list` for valid
events.
Example::
submission failed, failed
''',
'handler retry delays': '''
Specify an initial delay before running an event handler command and
any retry delays in case the command returns a non-zero code.
The default behaviour is to run an event handler command once without
any delay.
Example::
PT10S, PT1M, PT5M
''',
'mail events': '''
A list of events for which notification emails should be sent.
See :ref:`user_guide.runtime.task_event_handling.list` for valid
events.
Example::
submission failed, failed
''',
'execution timeout': '''
If a task has not finished after the specified interval, any configured
execution timeout event handler(s) will be called.
''',
'submission timeout': '''
If a task has not started after the specified interval, any configured
submission timeout event handler(s) will be called.
'''
}
def comma_sep_section_note(version_changed: str = '') -> str:
note_text = "This section can be a comma separated list."
if version_changed:
note_text = (
f".. versionchanged:: {version_changed}\n\n" +
indent(note_text, 3 * ' ')
)
example = dedent('''
.. spoiler:: Example
For example:
.. code-block:: cylc
[a, b]
setting = x
[a]
another_setting = y
Will become:
.. code-block:: cylc
[a]
setting = x
[b]
setting = x
[a]
another_setting = y
Which will then be combined according to
:ref:`the rules for Cylc config syntax<syntax>`.
''')
return "\n\n.. note::\n\n" + indent(note_text + example, 3 * ' ')
# ----------------------------------------------------------------------------
def short_descr(text: str) -> str:
"""Get dedented one-paragraph description from long description."""
return dedent(text).split('\n\n', 1)[0]
def default_for(
text: str, config_path: str, section: bool = False
) -> str:
"""Get dedented short description and insert a 'Default(s) For' directive
that links to this config item's flow.cylc counterpart."""
directive = f":Default{'s' if section else ''} For:"
return (
f"{directive} :cylc:conf:`flow.cylc{config_path}`.\n\n"
f"{short_descr(text)}"
)
with Conf('global.cylc', desc='''
The global configuration which defines default Cylc Flow settings
for a user or site.
To view your global config, run::
$ cylc config
Cylc will attempt to load the global configuration (``global.cylc``) from a
hierarchy of locations, including the site directory (defaults to
``/etc/cylc/flow/``) and the user directory (``~/.cylc/flow/``). For
example at Cylc version 8.0.1, the hierarchy would be, in order of
ascending priority:
.. code-block:: sub
<site-conf-path>/flow/global.cylc
<site-conf-path>/flow/8/global.cylc
<site-conf-path>/flow/8.0/global.cylc
<site-conf-path>/flow/8.0.1/global.cylc
~/.cylc/flow/global.cylc
~/.cylc/flow/8/global.cylc
~/.cylc/flow/8.0/global.cylc
~/.cylc/flow/8.0.1/global.cylc
Where ``<site-conf-path>`` is ``/etc/cylc/flow/`` by default but can be
changed by :envvar:`CYLC_SITE_CONF_PATH`.
A setting in a file lower down in the list will override the same setting
from those higher up (but if a setting is present in a file higher up and
not in any files lower down, it will not be overridden).
The following environment variables can change the files which are loaded:
.. envvar:: CYLC_CONF_PATH
If set this bypasses the default site/user configuration hierarchy used
to load the Cylc Flow global configuration.
This should be set to a directory containing a :cylc:conf:`global.cylc`
file.
.. envvar:: CYLC_SITE_CONF_PATH
By default the site configuration is located in ``/etc/cylc/``. For
installations where this is not convenient, this path can be overridden
by setting ``CYLC_SITE_CONF_PATH`` to point at another location.
Configuration for different Cylc components should be in sub-directories
within this location.
For example to configure Cylc Flow you could do the following::
$CYLC_SITE_CONF_PATH/
`-- flow/
`-- global.cylc
.. note::
The ``global.cylc`` file can be templated using Jinja2 variables.
See :ref:`Jinja`.
.. note::
Most of the global settings can be changed while a workflow is running
using ``cylc reload --global``. Exceptions are:
`[scheduler]`: The majority of these settings affect the server and
cannot be reloaded while the server is running. The server must be
stopped and restarted for changes to take effect except for the sections
`[scheduler][mail]` and `[scheduler][events]` which provide workflow
defaults.
`[install][symlink dirs]`: These settings create files on disk, once a
task has started on a remote host these can't be changed for that host.
.. versionchanged:: 8.0.0
Prior to Cylc 8, ``global.cylc`` was named ``global.rc``, but that name
is no longer supported.
''') as SPEC:
with Conf('hub', desc='''
Configure the public URL of Jupyter Hub.
If configured, the ``cylc gui`` command will open a web browser at this
location rather than starting a standalone server when called.
.. seealso::
* The cylc hub :ref:`architecture-reference` for fuller details.
* :ref:`UI_Server_config` for practical details.
'''):
Conf('url', VDR.V_STRING, '', desc='''
.. versionadded:: 8.3.0
Where Jupyter Hub is used a url can be provided for routing on
execution of ``cylc gui`` command.
''')
with Conf('scheduler', desc=(
default_for(SCHEDULER_DESCR, "[scheduler]", section=True)
)):
Conf('UTC mode', VDR.V_BOOLEAN, False, desc=(
default_for(UTC_MODE_DESCR, "[scheduler]UTC mode")
))
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
.. seealso::
:ref:`Managing External Command Execution`.
.. versionchanged:: 8.0.0
Moved into the ``[scheduler]`` section from the top level.
''')
Conf('process pool timeout', VDR.V_INTERVAL, DurationFloat(600),
desc='''
After this interval Cylc will kill long running commands in the
process pool.
.. seealso::
: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 into the ``[scheduler]`` section from the top level.
''')
Conf('auto restart delay', VDR.V_INTERVAL, desc=f'''
Maximum number of seconds the auto-restart mechanism will delay
before restarting workflows.
When a host is set to automatically
shutdown/restart it waits a random period of time
between zero and ``auto restart delay`` seconds before
beginning the process. This is to prevent large numbers of
workflows from restarting simultaneously.
.. seealso::
:ref:`auto-stop-restart`
.. versionchanged:: 8.0.0
{REPLACES}``global.rc[suite servers]auto restart delay``.
''')
with Conf('run hosts', desc=f'''
Configure workflow hosts and ports for starting workflows.
Additionally configure host selection settings specifying how to
determine the most suitable run host at any given time from those
configured.
.. versionchanged:: 8.0.0
{REPLACES}``[suite servers]``.
'''):
Conf('available', VDR.V_SPACELESS_STRING_LIST, desc=f'''
A list of workflow run hosts.
Cylc will choose one of these hosts for a workflow to start on.
(Unless an explicit host is provided as an option to the
``cylc play --host=<myhost>`` command.)
.. versionchanged:: 8.0.0
{REPLACES}``[suite servers]run hosts``.
''')
Conf('ports', VDR.V_RANGE, Range((43001, 43101)),
desc=f'''
The range of ports for Cylc to use to run workflows.
The minimum and maximum port numbers in the format
``min .. max``.
.. versionchanged:: 8.0.0
{REPLACES}``[suite servers]run ports``.
It can no longer be used to define a non-contiguous port
range.
''')
Conf('condemned', VDR.V_ABSOLUTE_HOST_LIST, desc=f'''
List run hosts that workflows should *not* run on.
These hosts will be subtracted from the
`available <global.cylc[scheduler][run hosts]>` hosts
preventing new workflows from starting on the "condemned" host.
Any workflows running on these hosts will either migrate
to another host, or shut down according to
:py:mod:`the configuration <cylc.flow.main_loop.auto_restart>`.
This feature requires ``auto restart`` to be listed
in `global.cylc[scheduler][main loop]plugins`.
For more information, see the
:py:mod:`auto restart <cylc.flow.main_loop.auto_restart>`
plugin.
.. rubric:: Example:
.. code-block:: cylc
[scheduler]
[[main loop]]
# activate the "auto restart" plugin
plugins = auto restart
[[run hosts]]
# there are three hosts in the "pool"
available = host1, host2, host3
# however two have been taken out:
# * workflows running on "host1" will attempt to
# restart on "host3"
# * workflows running on "host2" will shutdown
condemned = host1, host2!
.. seealso::
:py:mod:`cylc.flow.main_loop.auto_restart`
:ref:`auto-stop-restart`
.. versionchanged:: 8.4.2
The "force mode" (activated by a "!" suffix) caused issues
at workflow startup for Cylc versions between 8.0.0 and
8.4.1 inclusive.
.. versionchanged:: 8.0.0
{REPLACES}``[suite servers]condemned hosts``.
''')
Conf('ranking', VDR.V_STRING, desc=f'''
Rank and filter run hosts based on system information.
By default, when a workflow is started, Cylc will pick a host
for it to run on at random from :cylc:conf:`[..]available`.
If no hosts are specified in :cylc:conf:`[..]available` it
will start the scheduler locally.
Ranking can be used to provide load balancing to ensure no
single run host is overloaded. It also provides thresholds
beyond which Cylc will not attempt to start new schedulers on
a host.
.. _psutil: https://psutil.readthedocs.io/en/latest/
This should be a multiline string containing Python expressions
to rank and/or filter hosts. All `psutil`_ attributes are
available for use in these expressions, e.g, ``cpu_percent``.
You can supply these with positional arguments e.g,
``cpu_percent(1)``, however, keyword arguments will not work
e.g, ``cpu_percent(interval=1)``.
.. rubric:: Ranking
Rankings are expressions which return numerical values.
The host which returns the lowest value is chosen. Examples:
.. code-block:: python
# rank hosts by cpu_percent
cpu_percent()
# rank hosts by 15min average of server load
getloadavg()[2]
# rank hosts by the amount of available RAM (multiply by -1
# to make it choose the host with the most available memory
# rather than the least)
-1 * virtual_memory().available