From d194259aebe7d789bf1a2509f34574e489322d5d Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Fri, 26 Jun 2020 12:47:06 +0100 Subject: [PATCH 1/3] Address issue 39 --- ceci/main.py | 2 ++ ceci/sites/__init__.py | 7 +++++++ ceci/sites/cori.py | 6 +++++- tests/test_site.py | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/test_site.py diff --git a/ceci/main.py b/ceci/main.py index e0eb549..0b93d29 100644 --- a/ceci/main.py +++ b/ceci/main.py @@ -66,6 +66,8 @@ def run(pipeline_config_filename, extra_config=None, dry_run=False): # parsl execution/launcher configuration information launcher_config = pipe_config.get("launcher", {"name": "mini"}) launcher_name = launcher_config["name"] + # Launchers may need to know if this is a dry-run + launcher_config["dry_run"] = dry_run # Python modules in which to search for pipeline stages modules = pipe_config["modules"].split() diff --git a/ceci/sites/__init__.py b/ceci/sites/__init__.py index b3cc1f2..1cc4e2c 100644 --- a/ceci/sites/__init__.py +++ b/ceci/sites/__init__.py @@ -57,10 +57,17 @@ def load(launcher_config, site_configs): sites = [] launcher_name = launcher_config["name"] + dry_run = launcher_config.get("dry_run", False) # Create an object for each site. for site_config in site_configs: site_name = site_config["name"] + # Also tell the sites whether this is a dry-run. + # for example, the cori site checks you're not + # trying to run srun on a login node, but we skip + # that test if we are not actually running the command, + # just printing it. + site_config["dry_run"] = dry_run try: cls = site_classes[site_name] diff --git a/ceci/sites/cori.py b/ceci/sites/cori.py index 1f747b7..25de6b6 100644 --- a/ceci/sites/cori.py +++ b/ceci/sites/cori.py @@ -35,7 +35,11 @@ def command(self, cmd, sec): if sec.nodes: mpi1 += f" --nodes {sec.nodes}" - if (sec.nprocess > 1) and (os.environ.get("SLURM_JOB_ID") is None): + if ( + (sec.nprocess > 1) + and (os.environ.get("SLURM_JOB_ID") is None) + and (not self.config.get("dry_run")) + ): raise ValueError( "You cannot use MPI (by setting nprocess > 1) " "on Cori login nodes, only inside jobs." diff --git a/tests/test_site.py b/tests/test_site.py new file mode 100644 index 0000000..d89cc8a --- /dev/null +++ b/tests/test_site.py @@ -0,0 +1,39 @@ +from ceci.sites import load, get_default_site +from ceci.pipeline import StageExecutionConfig +from ceci.main import run +import pytest + + +def test_cori_error(): + # check that errors when trying to run multi-process + # jobs on cori login nodes are handled correctly. + # should fail unless dry-run is set. + + launcher_config = { + "name": "mini", + "interval": 1.0, + + } + site_config = { + "name": "cori-interactive", + } + + stage_config = { + "name": "Test", + "nprocess": 2, + } + + load(launcher_config, [site_config]) + site = get_default_site() + sec = StageExecutionConfig(stage_config) + + # should fail if we don't set dry-run + with pytest.raises(ValueError): + site.command("xxx", sec) + + # should work if we do set dry-run + launcher_config['dry_run'] = True + load(launcher_config, [site_config]) + site = get_default_site() + site.command("xxx", sec) + From ba7de89bc09d6b5aaad73501849d41298830713c Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Fri, 26 Jun 2020 12:52:01 +0100 Subject: [PATCH 2/3] run black on test_site --- tests/test_site.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_site.py b/tests/test_site.py index d89cc8a..c9009ef 100644 --- a/tests/test_site.py +++ b/tests/test_site.py @@ -12,7 +12,6 @@ def test_cori_error(): launcher_config = { "name": "mini", "interval": 1.0, - } site_config = { "name": "cori-interactive", @@ -32,8 +31,7 @@ def test_cori_error(): site.command("xxx", sec) # should work if we do set dry-run - launcher_config['dry_run'] = True + launcher_config["dry_run"] = True load(launcher_config, [site_config]) site = get_default_site() site.command("xxx", sec) - From 58c757445a1cbbd4ef365072319e6c8c6da6a1a7 Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Fri, 26 Jun 2020 12:55:16 +0100 Subject: [PATCH 3/3] import travis fix from issue_42 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c93a818..eb67f55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ python: - "3.8" install: + - pip install --upgrade pytest codecov - pip install .[test,cwl,parsl] # Test three different pipelines