Skip to content

Commit

Permalink
Merge pull request #6404 from wxtim/fix.6286
Browse files Browse the repository at this point in the history
Pass pre-install plugins the value of workflow rundir
  • Loading branch information
oliver-sanders authored Nov 6, 2024
2 parents ddf5349 + cc233b6 commit 9ed4f50
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cylc/flow/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import asyncio

import os.path
from pathlib import Path
from typing import List, Optional, TYPE_CHECKING

from cylc.flow.cfgspec.glbl_cfg import glbl_cfg
Expand Down Expand Up @@ -202,6 +203,11 @@ async def _main(
print("\n".join(get_config_file_hierarchy(workflow_id)))
return

# Save the location of the existing workflow run dir in the
# against source option:
if options.against_source:
options.against_source = Path(get_workflow_run_dir(workflow_id))

Check warning on line 209 in cylc/flow/scripts/config.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/config.py#L209

Added line #L209 was not covered by tests

config = WorkflowConfig(
workflow_id,
flow_file,
Expand Down
7 changes: 7 additions & 0 deletions cylc/flow/scripts/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import asyncio
from difflib import unified_diff
from pathlib import Path
from shutil import which
from subprocess import Popen, PIPE
import sys
Expand All @@ -53,6 +54,7 @@
CylcOptionParser as COP,
icp_option,
)
from cylc.flow.pathutil import get_workflow_run_dir
from cylc.flow.templatevars import get_template_vars
from cylc.flow.terminal import cli_function

Expand Down Expand Up @@ -558,6 +560,11 @@ async def _main(
constraint='workflows',
)

# Save the location of the existing workflow run dir in the
# against source option:
if opts.against_source:
opts.against_source = Path(get_workflow_run_dir(workflow_id))

Check warning on line 566 in cylc/flow/scripts/graph.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/graph.py#L566

Added line #L566 was not covered by tests

if opts.diff:
return await graph_diff(
opts, workflow_id, opts.diff, start, stop, flow_file)
Expand Down
8 changes: 8 additions & 0 deletions cylc/flow/scripts/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import asyncio
import os
from pathlib import Path
import sys
from typing import TYPE_CHECKING

Expand All @@ -43,6 +44,7 @@
CylcOptionParser as COP,
icp_option,
)
from cylc.flow.workflow_files import get_workflow_run_dir
from cylc.flow.templatevars import get_template_vars
from cylc.flow.terminal import cli_function

Expand Down Expand Up @@ -151,6 +153,12 @@ async def _main(parser: COP, options: 'Values', workflow_id: str) -> None:
[options.all_tasks, options.all_namespaces, options.mro]):
print("WARNING: -t chosen, ignoring non-tree options.",
file=sys.stderr)

# Save the location of the existing workflow run dir in the
# against source option:
if options.against_source:
options.against_source = Path(get_workflow_run_dir(workflow_id))

Check warning on line 160 in cylc/flow/scripts/list.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/list.py#L160

Added line #L160 was not covered by tests

config = WorkflowConfig(
workflow_id,
flow_file,
Expand Down
8 changes: 8 additions & 0 deletions cylc/flow/scripts/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import asyncio
from ansimarkup import parse as cparse
from copy import deepcopy
from pathlib import Path
import sys
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -55,6 +56,7 @@
from cylc.flow.templatevars import get_template_vars
from cylc.flow.terminal import cli_function
from cylc.flow.scheduler_cli import RUN_MODE
from cylc.flow.workflow_files import get_workflow_run_dir
from cylc.flow.workflow_status import RunMode

if TYPE_CHECKING:
Expand Down Expand Up @@ -153,6 +155,12 @@ async def run(
src=True,
constraint='workflows',
)

# Save the location of the existing workflow run dir in the
# against source option:
if getattr(options, 'against_source', False):
options.against_source = Path(get_workflow_run_dir(workflow_id))

cfg = WorkflowConfig(
workflow_id,
flow_file,
Expand Down
11 changes: 8 additions & 3 deletions cylc/flow/scripts/validate_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"""

import asyncio
from pathlib import Path
import sys
from typing import TYPE_CHECKING, Union

Expand Down Expand Up @@ -75,7 +76,10 @@
run as cylc_reload
)
from cylc.flow.terminal import cli_function
from cylc.flow.workflow_files import detect_old_contact_file
from cylc.flow.workflow_files import (
detect_old_contact_file,
get_workflow_run_dir,
)

CYLC_ROSE_OPTIONS = COP.get_cylc_rose_options()
VR_OPTIONS = combine_options(
Expand Down Expand Up @@ -186,8 +190,9 @@ async def vr_cli(
):
return False

# Force on the against_source option:
options.against_source = True
# Save the location of the existing workflow run dir in the
# against source option:
options.against_source = Path(get_workflow_run_dir(workflow_id))

# Run cylc validate
log_subcommand('validate --against-source', workflow_id)
Expand Down
8 changes: 8 additions & 0 deletions cylc/flow/scripts/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"""

import asyncio
from pathlib import Path
from typing import TYPE_CHECKING

from cylc.flow.id_cli import parse_id_async
Expand All @@ -42,6 +43,7 @@
WORKFLOW_ID_OR_PATH_ARG_DOC,
CylcOptionParser as COP,
)
from cylc.flow.pathutil import get_workflow_run_dir
from cylc.flow.parsec.fileparse import read_and_proc
from cylc.flow.templatevars import get_template_vars
from cylc.flow.terminal import cli_function
Expand Down Expand Up @@ -122,6 +124,12 @@ async def _main(options: 'Values', workflow_id: str) -> None:
src=True,
constraint='workflows',
)

# Save the location of the existing workflow run dir in the
# against source option:
if options.against_source:
options.against_source = Path(get_workflow_run_dir(workflow_id))

Check warning on line 131 in cylc/flow/scripts/view.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/view.py#L131

Added line #L131 was not covered by tests

# read in the flow.cylc file
for line in read_and_proc(
flow_file,
Expand Down

0 comments on commit 9ed4f50

Please sign in to comment.