-
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
Jinja error in validation shows incorrect context #2572
Comments
On initial investigation, I think this may be a Jinja2 bug. I'll ask a 2nd pair of eyes to confirm. |
Confirmed, this is a bad Jinja2 bug - pallets/jinja#276. |
Thanks, guys. I suspected it might be so - feel free to close if you'd like. |
@trwhitcomb We have moved this to milestone never, as a known issue related to a non-cylc bug. |
I think this and #2708 can be closed once jinja 2.11 is released and we update to this version (checking for backward compatibility, of course). Python 3.8 changed how they reported multiline errors, but without fixing the issue with exceptions being thrown from this multiline errors. My fix for Jinja was flawed, as it would break other features of Jinja. But luckily a maintainer of Jinja recently changed the code, which now removes the multiline usage - pallets/jinja#1109. This means we don't have the line number, however, the exception trace should give the correct line with the error. So for the example suite above, the output for Cylc 8
So that gives the correct line. We could later perhaps find that line and add the line number ourselves. Looks like the Jinja2Error doesn't bring that information, but on the bright side doesn't report the wrong line number. |
(actually looks like the line number never came from the |
OK, so we can close this once Jinja 2.11.0 is released? No due date, but 98% done: https://github.com/pallets/jinja/milestones |
Yup!!! It will give the correct context. Just the line number is missing from the exception/traceback printed. (Not sure if it is due to some change in Jinja, something we need to update in Cylc, etc). But the issue reported here will be fixed 👍 🎊 🎉 |
Issue fixed in Jinja2 2.11.1, released January 30th 2020 🎉 Validation Created suite 2572 in Then registered it with the code from
And tried to validate it, reproducing the issue: (venv) kinow@kinow-VirtualBox:~/Development/python/workspace/cylc-flow$ cylc validate 2572
Jinja2Error: 'watch_directory' is undefined
Context lines:
[[CheckRequests]]
[[[environment]]]
processing_suite = {{ processing_suite }} <-- UndefinedError Then installed 2.11.1, and tried to validate it again.
|
(Is Jinja 2.11.1 Python 3 only? If so, this is fixed for Cylc 8, but not Cylc 7...) |
Not yet, they still support the 2.7 series, at least from looking at their And they have the unreleased version 3.0.0 (not sure if they will re-name jinja2 to jinja3?) which mentions the drop of 2.7: ps: looking at the changelog, looks like it was fixed in 2.11.0 (also weird that they have 2.11.1 unreleased, even though it's in PYPI, maybe they still need to update it...) |
OK I guess we should put this against the 7.8.5 milestone and update the bundled version for that release. (And update dependencies for 8.0a2) |
I'm already going through other dependencies in Cylc 8. Just finished testing everything with latest versions, except pyzmq (still looking for the changelog to see what changed from 18.0 to 18.1). My tests are basically If everything works for 8.0a2, I'll prepare one for Cylc 7. |
(might pay to check that those workflows use Jinja2 - if you haven't already!) |
Ah, that was just a quick smoke check. Travis is now going through all the functional tests to confirm that everything is working. Tests under |
We will need to do a quick check that this upgrade is a non-breaking change (as some previous updates have been) else provide guidance, etc. |
Will finish testing Cylc 7.8.5 later, but will need others 👀 and some testing to confirm it indeed doesn't break any thing. |
Had a bit of spare time just now, so quickly:
First it failed due to the asyncio files included. So removed these two. Then now every test passed, but 1: It just runs Here's the output of
And here's the output from this branch:
That test passed with Cylc 8, so I assume we are good. It looks like it's printing the place on the file where the error occurred, instead of raising the error and printing the error context... will have a look tomorrow 👍 |
Closed by #3502 |
When validating a suite using Jinja2 templating commands, the error handling will print out the Jinja exception as well as the context lines. However, they don't match. Take the following suite:
When validating with no command-line Jinja options, it gives the error:
I would have expected the context lines to show the
watch_directory
line instead of theprocessing_suite
variable line contexts. I've tried to reproduce this in a standalone (non-Cylc) case but so far have been unsuccessful in my quick attempts to get Jinja to throw an error for the undefined variable. I'm also not sure if this is a Cylc-specific problem or if this is passed all the way through from Jinja. If it's Jinja, feel free to close.The text was updated successfully, but these errors were encountered: