From 3f2335417e3c34585f149db419353bf77170eb42 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 3 Jul 2023 15:39:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20`remote=5Fcopy=5Flist`=20t?= =?UTF-8?q?o=20`test=5Fcalculation=5Ffile=5Ftransfer`=20(#24)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codecov.yml | 4 ++-- tests/test_calculation.py | 36 +++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/codecov.yml b/codecov.yml index 382607a..f086aa0 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,9 +2,9 @@ coverage: status: project: default: - target: 70% + target: 75% threshold: 0.2% patch: default: - target: 70% + target: 75% threshold: 0.2% diff --git a/tests/test_calculation.py b/tests/test_calculation.py index cedd0f3..3ff1eca 100644 --- a/tests/test_calculation.py +++ b/tests/test_calculation.py @@ -39,7 +39,16 @@ def _firecrest_computer(firecrest_server: FirecrestConfig): return computer -@pytest.mark.usefixtures("aiida_profile_clean") +@pytest.fixture(name="no_retries") +def _no_retries(): + """Remove calcjob retries, to make failing the test faster.""" + max_attempts = manage.get_config().get_option(MAX_ATTEMPTS_OPTION) + manage.get_config().set_option(MAX_ATTEMPTS_OPTION, 1) + yield + manage.get_config().set_option(MAX_ATTEMPTS_OPTION, max_attempts) + + +@pytest.mark.usefixtures("aiida_profile_clean", "no_retries") def test_calculation_basic(firecrest_computer: orm.Computer): """Test running a simple `arithmetic.add` calculation.""" code = orm.InstalledCode( @@ -66,14 +75,21 @@ def test_calculation_basic(firecrest_computer: orm.Computer): assert node.is_finished_ok -@pytest.mark.usefixtures("aiida_profile_clean") +@pytest.mark.usefixtures("aiida_profile_clean", "no_retries") def test_calculation_file_transfer( firecrest_computer: orm.Computer, entry_points: EntryPointManager ): - """Test a more calculation, with multiple files uploaded/retrieved.""" + """Test a calculation, with multiple files copied/uploaded/retrieved.""" + # add temporary entry points entry_points.add(MultiFileCalcjob, "aiida.calculations:testing.multifile") entry_points.add(NoopParser, "aiida.parsers:testing.noop") + # add a remote file which is used remote_copy_list + firecrest_computer.get_transport()._cwd.joinpath( + firecrest_computer.get_workdir(), "remote_copy.txt" + ).touch() + + # setup the calculation code = orm.InstalledCode( label="test_code", description="test code", @@ -82,12 +98,8 @@ def test_calculation_file_transfer( filepath_executable="/bin/sh", ) code.store() - builder = code.get_builder() - # TODO reset in fixture? - manage.get_config().set_option(MAX_ATTEMPTS_OPTION, 1) - node: orm.CalcJobNode _, node = engine.run_get_node(builder) assert node.is_finished_ok @@ -104,6 +116,7 @@ def test_calculation_file_transfer( "folder1/a/b.txt", "folder1/a/c.txt", "folder2", + "folder2/remote_copy.txt", "folder2/x", "folder2/y", "folder2/y/z", @@ -153,6 +166,15 @@ def prepare_for_submission(self, folder: Folder) -> common.CalcInfo: calcinfo = common.CalcInfo() calcinfo.codes_info = [codeinfo] calcinfo.retrieve_list = [("folder1/*/*.txt", ".", 99), ("folder2", ".", 99)] + comp: orm.Computer = self.inputs.code.computer + calcinfo.remote_copy_list = [ + ( + comp.uuid, + f"{comp.get_workdir()}/remote_copy.txt", + "folder2/remote_copy.txt", + ) + ] + # TODO also add remote_symlink_list return calcinfo