-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing value cycling_mode to cylc.flags #2865
Conversation
975ac41
to
677e934
Compare
Hi @kinow Sorry, but I really don't like these global flags. Given that the flag is read in 2 locations (and is written in 1 location), I would like to propose for it to be removed 💥: diff --git a/bin/cylc-submit b/bin/cylc-submit
index 4a67e1ac1..d502ebac1 100755
--- a/bin/cylc-submit
+++ b/bin/cylc-submit
@@ -116,7 +116,7 @@ def main():
'CYLC_DEBUG': str(cylc.flags.debug).lower(),
'CYLC_VERBOSE': str(cylc.flags.verbose).lower(),
'CYLC_SUITE_NAME': suite,
- 'CYLC_CYCLING_MODE': str(cylc.flags.cycling_mode),
+ 'CYLC_CYCLING_MODE': str(config.cfg['scheduling']['cycling mode']),
'CYLC_SUITE_INITIAL_CYCLE_POINT': str(
config.cfg['scheduling']['initial cycle point']),
'CYLC_SUITE_FINAL_CYCLE_POINT': str(
diff --git a/lib/cylc/config.py b/lib/cylc/config.py
index da3af892e..2358d33b8 100644
--- a/lib/cylc/config.py
+++ b/lib/cylc/config.py
@@ -339,8 +339,6 @@ class SuiteConfig(object):
set_utc_mode(glbl_cfg().get(['cylc', 'UTC mode']))
else:
set_utc_mode(self.cfg['cylc']['UTC mode'])
- # Capture cycling mode
- cylc.flags.cycling_mode = self.cfg['scheduling']['cycling mode']
# Initial point from suite definition (or CLI override above).
icp = self.cfg['scheduling']['initial cycle point']
diff --git a/lib/cylc/scheduler.py b/lib/cylc/scheduler.py
index a9bb75388..942ea9a2c 100644
--- a/lib/cylc/scheduler.py
+++ b/lib/cylc/scheduler.py
@@ -1105,7 +1105,8 @@ conditions; see `cylc conditions`.
'CYLC_DEBUG': str(cylc.flags.debug).lower(),
'CYLC_VERBOSE': str(cylc.flags.verbose).lower(),
'CYLC_SUITE_NAME': self.suite,
- 'CYLC_CYCLING_MODE': str(cylc.flags.cycling_mode),
+ 'CYLC_CYCLING_MODE': str(
+ self.config.cfg['scheduling']['cycling mode']),
'CYLC_SUITE_INITIAL_CYCLE_POINT': str(self.initial_point),
'CYLC_SUITE_FINAL_CYCLE_POINT': str(self.final_point),
}) |
On mobile now. Also not very fond of mutable globals like this. Removing sounds a bit drastic, but I'd be OK with that option too. Should we get a 3rd opinion here? I'm OK with both options. Cheers |
No problem. Assigned @hjoliver for a final say. 😄 Let's also block 🚫 the next release with this PR - as current master is a bit unsafe ❗ without the global flag 🎏 being defined. Note on removal:
|
Obviously I agree that any non-trivial use of global variables is bad, but for a small number of simple "constants" (quotes for Python constants) that are more or less globally used - like verbosity and debug flags - I'm not sure that the standard objections really mean much. The I'm not sure why |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(commented already)
@matthewrmshin feel free to open a PR with the code from your diff above for this. Then I will close this one, and can also help review/testing that one. WDYT? |
Superseded by #2869. |
While review #2809 and reading the code of
scheduler.py
in the IDE, I noticed it couldn't locatecycling_mode
inflags.py
. Even though it is missing, it is defined inconfig.py
'sSuiteConfig
constructor.Might be worth adding the empty value by default for clarity?