Skip to content

Commit

Permalink
handle path that end with * better
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodearnest committed Nov 6, 2023
1 parent 761fc08 commit dffe6bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pipeline/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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"
)

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
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/valid_yaml/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dffe6bb

Please sign in to comment.