Skip to content
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 CYLC_ variables to template engine globals. #5571

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

hjoliver
Copy link
Member

@hjoliver hjoliver commented Jun 6, 2023

What it says. Make this sort of thing work during flow.cylc parsing:

{{ CYLC_WORKFLOW_RUN_DIR | default("not defined") }}

See explanation in #5570 (comment)

If agreed, I'll document this, and do the same for Empy.

Will need to document that this should not be used in place of the associated environment variables in task definitions (they get evaluated at job run time and will therefore always be defined).

[UPDATE: for the linked use case, #5589 makes this PR redundant. But this might be useful for other reasons]

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • CHANGES.md entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at Update Jinja2 and EmPy templating sections. cylc-doc#631.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@hjoliver hjoliver self-assigned this Jun 6, 2023
@hjoliver hjoliver added this to the cylc-8.2.0 milestone Jun 6, 2023
@hjoliver hjoliver added the question Flag this as a question for the next Cylc project meeting. label Jun 7, 2023
@hjoliver hjoliver removed the question Flag this as a question for the next Cylc project meeting. label Jun 19, 2023
@hjoliver hjoliver marked this pull request as ready for review June 19, 2023 07:49
@oliver-sanders
Copy link
Member

(remote tests unhappy)

@oliver-sanders
Copy link
Member

Hmm, found this in the debug section for the failed test:

Can't find:
===========
CYLC_JOB_RUNNER_NAME=background
===========
in:
===========
CYLC_JOB_RUNNER_NAME=at
...

???

@wxtim
Copy link
Member

wxtim commented Jul 12, 2023

I've not put anything demanding radical changes in my comments, mostly suggestions for shrinking the test, not of which I'm emotionally attached to (apart from match=, I like that).

I've had a play with a checked out copy.

Will approve once conflicts are resolved.

Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliver-sanders

I've done a deconflict merge.

Could you do a final check that my merge hasn't broken anything?

@oliver-sanders
Copy link
Member

Could you do a final check that my merge hasn't broken anything?

This PR will still have tests failing, see above.

@MetRonnie
Copy link
Member

The test that is failing had this in it:

platform = {{CYLC_TEST_PLATFORM | default("localhost")}}

Before this PR I think CYLC_TEST_PLATFORM was always an undefined Jinja2 variable so the workflow was not actually running remotely and the test was not doing what it was supposed to be doing (it was testing local cat-log not remote cat-log)

@oliver-sanders
Copy link
Member

oliver-sanders commented Jul 19, 2023

That doesn't make sense to me, there are other tests which follow this pattern:

export REQUIRE_PLATFORM='loc:remote'

But don't provide a default:

platform = {{ environ['CYLC_TEST_PLATFORM'] }}

So would get a Jinja2Undefined error if so.

@oliver-sanders
Copy link
Member

Oh, sorry, didn't read that properly, it's a Jinja2 variable 🤦

@oliver-sanders
Copy link
Member

Here's a test that runs in CI and uses the Jinja2 variable:

platform = {{ CYLC_TEST_PLATFORM }}

@MetRonnie
Copy link
Member

In that one it uses cylc play -s "CYLC_TEST_PLATFORM=$CYLC_TEST_PLATFORM" but not in the failing one

@wxtim wxtim modified the milestones: cylc-8.2.0, cylc-8.2.1 Jul 21, 2023
@hjoliver hjoliver changed the title Add CYLC_ variables to Jinja2 globals. Add CYLC_ variables to template engine globals. Jul 24, 2023
@hjoliver
Copy link
Member Author

hjoliver commented Jul 24, 2023

Addressed review comments.
Extended to empy.
Rebased.

@hjoliver
Copy link
Member Author

In that one it uses cylc play -s "CYLC_TEST_PLATFORM=$CYLC_TEST_PLATFORM" but not in the failing one

And fixed the failing test (it now runs remote jobs, as advertised).

@hjoliver
Copy link
Member Author

Should be good to go now. Cylc-doc PR up too.

CHANGES.md Outdated Show resolved Hide resolved
@MetRonnie MetRonnie changed the base branch from master to 8.2.x July 25, 2023 16:03
@hjoliver hjoliver marked this pull request as draft July 26, 2023 04:39
@hjoliver hjoliver force-pushed the jinja2-scheduler-context branch 2 times, most recently from 896d451 to bb1a75f Compare July 26, 2023 06:37
@hjoliver hjoliver marked this pull request as ready for review July 26, 2023 06:38
@hjoliver
Copy link
Member Author

Right, all done.

I think tests/functional/broadcast/00-simple.t is going to fail, but is also failing on 8.2.x ... I've run out of time to investigate for now.

@MetRonnie
Copy link
Member

Regression in tests/f/cylc-cat-log/01-remote.t failing again

Btw as this is an enhancement should it be on the 8.3.0 milestone (and base changed to master)?

@hjoliver
Copy link
Member Author

Regression in tests/f/cylc-cat-log/01-remote.t failing again

Damn it, problem was I stupidly force-pushed from my outdated branch on the laptop at home today after yesterday's fixes at work. I had to redo some changes, but forgot this one.

And yes, it should be rebased to master.

@MetRonnie MetRonnie modified the milestones: cylc-8.2.1, cylc-8.3.0 Jul 26, 2023
@MetRonnie MetRonnie changed the base branch from 8.2.x to master July 26, 2023 10:49
@MetRonnie
Copy link
Member

MetRonnie commented Jul 26, 2023

I've cherry picked the missing commit. And changed the base + milestone; no need to rebase however (and no need to fiddle with the changelog anymore 😁)

@hjoliver
Copy link
Member Author

hjoliver commented Jul 26, 2023

Great, thanks! (change base on the PR is what I meant)

@MetRonnie MetRonnie requested a review from wxtim July 26, 2023 12:33
@wxtim wxtim merged commit e4803ce into cylc:master Jul 26, 2023
25 checks passed
@hjoliver hjoliver deleted the jinja2-scheduler-context branch July 26, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants