diff --git a/pipeline/validation.py b/pipeline/validation.py index 963276b..e74ae93 100644 --- a/pipeline/validation.py +++ b/pipeline/validation.py @@ -34,7 +34,7 @@ def assert_valid_glob_pattern(pattern: str, privacy_level: str) -> None: path = Path(pattern) - if path.suffix == "": + if path.suffix == "" or path.suffix.endswith("*"): raise InvalidPatternError( "output paths must have a file type extension at the end" ) @@ -42,7 +42,7 @@ def assert_valid_glob_pattern(pattern: str, privacy_level: str) -> None: if privacy_level == "moderately_sensitive": if path.suffix not in LEVEL4_FILE_TYPES: raise InvalidPatternError( - f"{path.suffix} is not an allowed file type for moderately_sensitive outputs" + f"{path} is not an allowed file type for moderately_sensitive outputs" ) # Check that the path is in normal form diff --git a/tests/fixtures/valid_yaml/project.yaml b/tests/fixtures/valid_yaml/project.yaml index b2e10da..23b7c3c 100644 --- a/tests/fixtures/valid_yaml/project.yaml +++ b/tests/fixtures/valid_yaml/project.yaml @@ -23,21 +23,21 @@ actions: needs: [generate_cohort] outputs: highly_sensitive: - male_cohort: male.* + male_cohort: male*.csv prepare_data_f: run: python:latest python analysis/filter_by_sex.py F output/input.csv female.csv needs: [generate_cohort] outputs: highly_sensitive: - female_cohort: female.* + female_cohort: female*.csv prepare_data_with_quote_in_filename: run: python:latest python analysis/filter_by_sex.py F output/input.csv "qu'ote.csv" needs: [generate_cohort] outputs: highly_sensitive: - quote_cohort: "qu'ote.*" + quote_cohort: "qu'ote*.csv" analyse_data: run: python:latest python analysis/count_lines.py counts.txt diff --git a/tests/test_validation.py b/tests/test_validation.py index 8ca72ea..a4f63db 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -19,6 +19,7 @@ def test_assert_valid_glob_pattern(): ("metadata", "highly_sensitive"), ("metadata/test.txt", "highly_sensitive"), ("outputs/*", "highly_sensitive"), + ("outputs/foo.*", "highly_sensitive"), ("outputs/output.rds", "moderately_sensitive"), ] for pattern, sensitivity in bad_patterns: