From 855aa316c08ae8907a0ffeaeb59d5c0a3798c7aa Mon Sep 17 00:00:00 2001 From: John Brittain Date: Thu, 12 Sep 2024 16:44:38 +0100 Subject: [PATCH] Update test-repo to use grapevne-helper --- electron-app/postbuild_tests/modules.test.ts | 35 ++++++++++++++++--- .../modules/MyNewModule2/config/config.yaml | 12 +++++++ .../modules/MyNewModule2/workflow/Snakefile | 8 +++++ .../single_modules/modules/copy_run/.test.sh | 4 +++ .../modules/copy_run/config/.test.yaml | 4 +++ .../modules/copy_run/workflow/Snakefile | 24 +++++++------ .../copy_run/workflow/grapevne_helper.py | 24 +++++++++++++ .../modules/copy_run_multiport/.test.sh | 4 +++ .../copy_run_multiport/config/.test.yaml | 7 ++++ .../results/{in => in1}/data.csv | 0 .../copy_run_multiport/workflow/Snakefile | 24 +++++++------ .../workflow/grapevne_helper.py | 24 +++++++++++++ .../single_modules/sources/conda/.test.sh | 4 +++ .../sources/conda/config/.test.yaml | 4 +++ .../sources/conda/workflow/Snakefile | 24 +++++++------ .../sources/conda/workflow/grapevne_helper.py | 24 +++++++++++++ .../sources/container_touch/.test.sh | 4 +++ .../sources/container_touch/config/.test.yaml | 17 +++++++++ .../container_touch/workflow/Snakefile | 1 - .../sources/payload_run/.test.sh | 4 +++ .../sources/payload_run/config/.test.yaml | 4 +++ .../sources/payload_run/workflow/Snakefile | 20 +++++++---- .../payload_run/workflow/grapevne_helper.py | 24 +++++++++++++ .../sources/payload_shell/.test.sh | 4 +++ .../sources/payload_shell/config/.test.yaml | 4 +++ .../sources/payload_shell/workflow/Snakefile | 20 +++++++---- .../payload_shell/workflow/grapevne_helper.py | 24 +++++++++++++ 27 files changed, 300 insertions(+), 52 deletions(-) create mode 100644 electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/config/config.yaml create mode 100644 electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/workflow/Snakefile create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/config/.test.yaml create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/grapevne_helper.py create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/config/.test.yaml rename electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/results/{in => in1}/data.csv (100%) create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/grapevne_helper.py create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/config/.test.yaml create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/grapevne_helper.py create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/config/.test.yaml create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/config/.test.yaml create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/grapevne_helper.py create mode 100755 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/.test.sh create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/config/.test.yaml create mode 100644 electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/grapevne_helper.py diff --git a/electron-app/postbuild_tests/modules.test.ts b/electron-app/postbuild_tests/modules.test.ts index 3c69dd50..a7c9b8a0 100644 --- a/electron-app/postbuild_tests/modules.test.ts +++ b/electron-app/postbuild_tests/modules.test.ts @@ -595,13 +595,40 @@ describe('modules', () => { // Conda tests runif(is_installed(['mamba', 'conda'], 'any')).each([ - ['conda', [path.join('results', 'conda', 'data.csv')]], + // Test: 1 (connect two modules) + [ + [ + // Modules to add to scene + 'payload shell', // data-nodeid="n0" + 'conda', // data-nodeid="n1" + ], + [ + // Connections to make between modules + ['n0-out-source', 'n1-in-target'], // (nodeid)-(portname)-(porttype) + ], + [ + // Expected output files + path.join('results', 'conda', 'data.csv'), + ], + ], ])( "Build and Test the conda workflow: module '%s'", - async (modulename, outfiles) => { - await BuildAndRun_SingleModuleWorkflow(driver, modulename, outfiles); + async (modulenames, connections, outfiles) => { + // Open settings pane + await driver.findElement(By.xpath('//div[@id="btnSidenavSettings"]')).click(); + + // Set snakemake command line arguments + const args = await driver.findElement(webdriver.By.id('inputBuilderSettingsSnakemakeArgs')); + await OverwriteInputField(args, '--cores 1 --use-conda'); + + // Close settings pane + await driver.findElement(By.xpath('//div[@id="btnSidenavBuilder"]')).click(); + console.log('<<< test Set snakemake arguments list to use conda'); + + // Build and run workflow + await BuildAndRun_MultiModuleWorkflow(driver, modulenames, connections, outfiles); }, - 10 * ONE_MINUTE, + 5 * ONE_MINUTE, ); // long timeout test( diff --git a/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/config/config.yaml b/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/config/config.yaml new file mode 100644 index 00000000..6be24bc2 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/config/config.yaml @@ -0,0 +1,12 @@ +"input_namespace": + "payload_run$": "in" +"output_namespace": "payload_run" +"payload_run": + "name": "payload_run" + "type": "module" + "snakefile": "/Users/jsb/repos/jsbrittain/GRAPEVNE/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/Snakefile" + "config": + "input_namespace": "in" + "output_namespace": "payload_run" + "params": + "filename": "data.csv" diff --git a/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/workflow/Snakefile new file mode 100644 index 00000000..9fd58eb5 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/MyNewProject/modules/MyNewModule2/workflow/Snakefile @@ -0,0 +1,8 @@ +configfile: "config/config.yaml" + +module payload_run: + snakefile: + config["payload_run"]["snakefile"] + config: + config["payload_run"]["config"] +use rule * from payload_run exclude _test as payload_run_* diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/.test.sh new file mode 100755 index 00000000..c2a7dca4 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results/out +snakemake --cores 1 --use-conda --configfile=config/.test.yaml _test diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/config/.test.yaml new file mode 100644 index 00000000..9f68be66 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/config/.test.yaml @@ -0,0 +1,4 @@ +input_namespace: in +output_namespace: out +params: + filename: data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/Snakefile index ec3efee1..9d4c6c24 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/Snakefile @@ -1,20 +1,22 @@ configfile: "config/config.yaml" +from grapevne_helper import * import shutil -params = config["params"] +init(workflow) rule copy: input: - expand( - "results/{indir}/{filename}", - indir=config["input_namespace"], - filename=params["filename"], - ) + input(params("filename")), output: - expand( - "results/{outdir}/{filename}", - outdir=config["output_namespace"], - filename=params["filename"], - ) + output(params("filename")), run: shutil.copy(input[0], output[0]) + +rule _test: + input: + src=rules.copy.input[0], + dst=rules.copy.output[0], + run: + # Verify that the file has been copied correctly + with open(input.src) as src, open(input.dst) as dst: + assert src.read() == dst.read() diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/grapevne_helper.py b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/grapevne_helper.py new file mode 100644 index 00000000..2d668b0d --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run/workflow/grapevne_helper.py @@ -0,0 +1,24 @@ +import sys +import logging + +try: + from grapevne.helpers import * # noqa: F403 +except ImportError: + import ensurepip + import subprocess + + ensurepip.bootstrap() + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--upgrade", "grapevne"] + ) + try: + from grapevne.helpers import * # noqa: F403 F401 + except ImportError: + logging.error("Failed to install grapevne. Exiting.") + sys.exit(1) + +# Tidy-up namespace +del sys, logging + +# Dynamically export all names imported from grapevne +__all__ = [name for name in dir() if not name.startswith("_")] diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/.test.sh new file mode 100755 index 00000000..c2a7dca4 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results/out +snakemake --cores 1 --use-conda --configfile=config/.test.yaml _test diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/config/.test.yaml new file mode 100644 index 00000000..fa4c1072 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/config/.test.yaml @@ -0,0 +1,7 @@ +input_namespace: + in1: in1 + in2: in2 + in3: in3 +output_namespace: out +params: + filename: data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/results/in/data.csv b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/results/in1/data.csv similarity index 100% rename from electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/results/in/data.csv rename to electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/results/in1/data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/Snakefile index 72236e34..f8a94c7c 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/Snakefile @@ -3,22 +3,24 @@ Input namespaces: [in1, in2, in3] Copy file from first input namespace (in1) only """ configfile: "config/config.yaml" +from grapevne_helper import * import shutil -params = config["params"] +init(workflow) rule copy: input: - expand( - "results/{indir}/{filename}", - indir=config["input_namespace"]["in1"], - filename=params["filename"], - ) + input(params("filename"), "in1"), output: - expand( - "results/{outdir}/{filename}", - outdir=config["output_namespace"], - filename=params["filename"], - ) + output(params("filename")), run: shutil.copy(input[0], output[0]) + +rule _test: + input: + src=rules.copy.input[0], + dst=rules.copy.output[0], + run: + # Verify that the file has been copied correctly + with open(input.src) as src, open(input.dst) as dst: + assert src.read() == dst.read() diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/grapevne_helper.py b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/grapevne_helper.py new file mode 100644 index 00000000..2d668b0d --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/modules/copy_run_multiport/workflow/grapevne_helper.py @@ -0,0 +1,24 @@ +import sys +import logging + +try: + from grapevne.helpers import * # noqa: F403 +except ImportError: + import ensurepip + import subprocess + + ensurepip.bootstrap() + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--upgrade", "grapevne"] + ) + try: + from grapevne.helpers import * # noqa: F403 F401 + except ImportError: + logging.error("Failed to install grapevne. Exiting.") + sys.exit(1) + +# Tidy-up namespace +del sys, logging + +# Dynamically export all names imported from grapevne +__all__ = [name for name in dir() if not name.startswith("_")] diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/.test.sh new file mode 100755 index 00000000..c2a7dca4 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results/out +snakemake --cores 1 --use-conda --configfile=config/.test.yaml _test diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/config/.test.yaml new file mode 100644 index 00000000..9f68be66 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/config/.test.yaml @@ -0,0 +1,4 @@ +input_namespace: in +output_namespace: out +params: + filename: data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/Snakefile index 0046f293..eb024ea6 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/Snakefile @@ -1,23 +1,25 @@ configfile: "config/config.yaml" +from grapevne_helper import * -params = config["params"] +init(workflow) rule copy: input: - expand( - srcdir("../results/{indir}/{filename}"), - indir=config["input_namespace"], - filename=params["filename"], - ) + input(params("filename")), output: - expand( - "results/{outdir}/{filename}", - outdir=config["output_namespace"], - filename=params["filename"], - ) + output(params("filename")), conda: "envs/conda.yaml" shell: """ cp {input} {output} """ + +rule _test: + input: + src=rules.copy.input[0], + dst=rules.copy.output[0], + run: + # Verify that the file has been copied correctly + with open(input.src) as src, open(input.dst) as dst: + assert src.read() == dst.read() diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/grapevne_helper.py b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/grapevne_helper.py new file mode 100644 index 00000000..2d668b0d --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/conda/workflow/grapevne_helper.py @@ -0,0 +1,24 @@ +import sys +import logging + +try: + from grapevne.helpers import * # noqa: F403 +except ImportError: + import ensurepip + import subprocess + + ensurepip.bootstrap() + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--upgrade", "grapevne"] + ) + try: + from grapevne.helpers import * # noqa: F403 F401 + except ImportError: + logging.error("Failed to install grapevne. Exiting.") + sys.exit(1) + +# Tidy-up namespace +del sys, logging + +# Dynamically export all names imported from grapevne +__all__ = [name for name in dir() if not name.startswith("_")] diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/.test.sh new file mode 100755 index 00000000..3f49f621 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results +snakemake --cores 1 --use-conda --configfile=config/.test.yaml diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/config/.test.yaml new file mode 100644 index 00000000..083324ae --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/config/.test.yaml @@ -0,0 +1,17 @@ +input_namespace: null +output_namespace: utility_touch +utility_touch: + config: + input_namespace: null + output_namespace: utility_touch + params: + filename: data.csv + name: (Utility) touch + snakefile: + args: + - jsbrittain/snakeshack + function: github + kwargs: + branch: main + path: workflows/Utility/modules/touch/workflow/Snakefile + type: module diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/workflow/Snakefile index 6c4f138a..284a60a4 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/container_touch/workflow/Snakefile @@ -6,7 +6,6 @@ module utility_touch: *config["utility_touch"]["snakefile"]["args"], **config["utility_touch"]["snakefile"]["kwargs"], ) - ) config: config["utility_touch"]["config"] use rule * from utility_touch as utility_touch_* diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/.test.sh new file mode 100755 index 00000000..c2a7dca4 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results/out +snakemake --cores 1 --use-conda --configfile=config/.test.yaml _test diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/config/.test.yaml new file mode 100644 index 00000000..9f68be66 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/config/.test.yaml @@ -0,0 +1,4 @@ +input_namespace: in +output_namespace: out +params: + filename: data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/Snakefile index 8d45ba1d..d801b5ba 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/Snakefile @@ -1,20 +1,26 @@ configfile: "config/config.yaml" +from grapevne_helper import * import os import pathlib import shutil -params = config["params"] +init(workflow) rule copy: input: - srcdir("../resources/file"), + resource("file"), output: - expand( - "results/{outdir}/{filename}", - outdir=config["output_namespace"], - filename=params["filename"], - ) + output(params("filename")), run: pathlib.Path(os.path.dirname(output[0])).mkdir(parents=True, exist_ok=True) shutil.copy(input[0], output[0]) + +rule _test: + input: + src=resource("file"), + dst=output(params("filename")), + run: + # Verify that the file has been copied correctly + with open(input.src) as src, open(input.dst) as dst: + assert src.read() == dst.read() diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/grapevne_helper.py b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/grapevne_helper.py new file mode 100644 index 00000000..2d668b0d --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_run/workflow/grapevne_helper.py @@ -0,0 +1,24 @@ +import sys +import logging + +try: + from grapevne.helpers import * # noqa: F403 +except ImportError: + import ensurepip + import subprocess + + ensurepip.bootstrap() + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--upgrade", "grapevne"] + ) + try: + from grapevne.helpers import * # noqa: F403 F401 + except ImportError: + logging.error("Failed to install grapevne. Exiting.") + sys.exit(1) + +# Tidy-up namespace +del sys, logging + +# Dynamically export all names imported from grapevne +__all__ = [name for name in dir() if not name.startswith("_")] diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/.test.sh b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/.test.sh new file mode 100755 index 00000000..c2a7dca4 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/.test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf results/out +snakemake --cores 1 --use-conda --configfile=config/.test.yaml _test diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/config/.test.yaml b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/config/.test.yaml new file mode 100644 index 00000000..9f68be66 --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/config/.test.yaml @@ -0,0 +1,4 @@ +input_namespace: in +output_namespace: out +params: + filename: data.csv diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/Snakefile b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/Snakefile index 0f6c9209..971d4c59 100644 --- a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/Snakefile +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/Snakefile @@ -1,17 +1,23 @@ configfile: "config/config.yaml" +from grapevne_helper import * -params = config["params"] +init(workflow) rule copy: input: - srcdir("../resources/file"), + resource("file"), output: - expand( - "results/{outdir}/{filename}", - outdir=config["output_namespace"], - filename=params["filename"], - ) + output(params("filename")), shell: """ cp {input} {output} """ + +rule _test: + input: + src=resource("file"), + dst=output(params("filename")), + run: + # Verify that the file has been copied correctly + with open(input.src) as src, open(input.dst) as dst: + assert src.read() == dst.read() diff --git a/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/grapevne_helper.py b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/grapevne_helper.py new file mode 100644 index 00000000..2d668b0d --- /dev/null +++ b/electron-app/postbuild_tests/test-repo/workflows/single_modules/sources/payload_shell/workflow/grapevne_helper.py @@ -0,0 +1,24 @@ +import sys +import logging + +try: + from grapevne.helpers import * # noqa: F403 +except ImportError: + import ensurepip + import subprocess + + ensurepip.bootstrap() + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--upgrade", "grapevne"] + ) + try: + from grapevne.helpers import * # noqa: F403 F401 + except ImportError: + logging.error("Failed to install grapevne. Exiting.") + sys.exit(1) + +# Tidy-up namespace +del sys, logging + +# Dynamically export all names imported from grapevne +__all__ = [name for name in dir() if not name.startswith("_")]