Raise an error if template variables are set with no shebang#6948
Raise an error if template variables are set with no shebang#6948wxtim wants to merge 6 commits intocylc:8.5.xfrom
Conversation
3b4b88d to
58b6cdb
Compare
c236a30 to
7de3421
Compare
but no shebang line is set in the flow.cylc.
7de3421 to
85d9252
Compare
oliver-sanders
left a comment
There was a problem hiding this comment.
This change is overzealous for this example:
# ./flow.cylc
[scheduling]
[[graph]]
R1 = foo
[runtime]
[[foo]]
# ./rose-suite.conf
[env]
FOO=bar
$ cylc val . -s FOO=1
TemplateVarLanguageClash: No shebang line (#!jinja2) in config file.But underzealous for this one
# ./flow.cylc
[scheduling]
[[graph]]
R1 = foo
[runtime]
[[foo]]
$ cylc val . -s FOO=1
Valid for cylc-8.5.2.dev| TEMPLATE_VARIABLES: {}, | ||
| TEMPLATING_DETECTED: None | ||
| } | ||
| JINJA2_SHEBANG = '#!jinja2' |
There was a problem hiding this comment.
Note we allow #!Jinja2 (capitalized) as well... but this is just for insertion, not detection?
There was a problem hiding this comment.
Where it's used for detection it'd be used with JINJA2_SHEBANG = var.lower()
Correction: It's a regex
|
Converted to draft. |
|
I'm slightly worried that this has the potential to throw out a lot of valid workflows, just because they have a @oliver-sanders what think you? |
This isn't a biggie, I'm not too concerned. We shouldn't add a check which has the potential to fail, so if there ain't a good way to do it, let's not do it. |
| @@ -1,3 +1,4 @@ | |||
| #!jinja2 | |||
There was a problem hiding this comment.
Why?
This config doesn't use Jinja2!
There was a problem hiding this comment.
But template variables are supplied - looks like there's vestigial garbage in the test.
tests/functional/platforms/05-host-to-platform-upgrade-fail/flow.cylc
Outdated
Show resolved
Hide resolved
| flines = jinja2process( | ||
| fpath, flines, fdir, template_vars | ||
| ) | ||
| elif template_vars.keys() - {"CYLC_VERSION", "CYLC_TEMPLATE_VARS"}: |
There was a problem hiding this comment.
Does cylc-rose provide default template vars even if templating was not configured?
There was a problem hiding this comment.
If you turn Cylc Rose on it provides template variables. You turn it on by adding a blank rose-suite.conf.
There was a problem hiding this comment.
So adding a rose-suite.conf file will force the user to add a Jinja2 shebang line, even if they are not using Jinja2 in the config?
There was a problem hiding this comment.
I don't think there's a simple/sane* way around that. If you think that's a deal breaker IMO we just call this PR off. It's too small an issue for me to spend much more time on it.
* Non simple ways
- with supress: from cylc.rose.utilites import STANDARD_VARS (less general change, but I don't like adding a single plugin exception)
- Modify the plugin interface (more general, but I don't want to change the interface!)
There was a problem hiding this comment.
I don't think there's a simple/sane* way around that.
I think forcing people to add Jinja2 shebangs where they aren't needed is going to be more of a problem than failing to spot when shebangs aren't needed but should have been added.
|
Solutions worse than problem. Bug recorded at #6971 |
|
I guess this is to be closed then? |
Thought I had |
line in the
flow.cylc.Fixes an otherwise unreported bug.
Real world example of bug:
Check List
CONTRIBUTING.mdand added my name as a Code Contributor.setup.cfg(andconda-environment.ymlif present).?.?.xbranch.