diff --git a/src/toffy/fov_watcher.py b/src/toffy/fov_watcher.py index ecf2d7de..5b3240c1 100644 --- a/src/toffy/fov_watcher.py +++ b/src/toffy/fov_watcher.py @@ -74,6 +74,10 @@ def check_run_condition(self, path: str) -> Tuple[bool, str]: filename = Path(path).parts[-1] + # if filename starts with a '.' (temp file), it should be ignored + if filename[0] == ".": + return False, "" + # filename is not corrct format of fov.bin or fov.json if len(filename.split(".")) != 2: warnings.warn( diff --git a/tests/fov_watcher_test.py b/tests/fov_watcher_test.py index 81accad7..e473feae 100644 --- a/tests/fov_watcher_test.py +++ b/tests/fov_watcher_test.py @@ -64,7 +64,7 @@ def _slow_copy_sample_tissue_data(dest: str, delta: int = 10, one_blank: bool = @parametrize_with_cases("run_json, expected_files", cases=RunStructureCases) -def test_run_structure(run_json, expected_files): +def test_run_structure(run_json, expected_files, recwarn): with RunStructureTestContext(run_json, files=expected_files) as ( tmpdir, run_structure, @@ -73,9 +73,15 @@ def test_run_structure(run_json, expected_files): run_structure.check_run_condition(os.path.join(tmpdir, file)) assert all(run_structure.check_fov_progress().values()) - # check for hidden files + # hidden files should not throw an invalid FOV file warning but still be skipped + exist, name = run_structure.check_run_condition(os.path.join(tmpdir, ".fake_file.txt")) + for warn_data in recwarn.list: + assert "not a valid FOV file and will be skipped" not in str(warn_data.message) + assert not exist and name == "" + + # check for invalid file format with pytest.warns(Warning, match="is not a valid FOV file and will be skipped"): - exist, name = run_structure.check_run_condition(os.path.join(tmpdir, ".fake_file.txt")) + exist, name = run_structure.check_run_condition(os.path.join(tmpdir, "fov.bin.txt")) assert not exist and name == "" # check for fake files