Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion opensafely/_vendor/pipeline/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ def validate_ehrql_outputs(action_id: str, action: Action) -> None:

output_patterns = (action.outputs.highly_sensitive or {}).values()
if not output_patterns_match_spec(output_spec, list(output_patterns)):
raise ValidationError("--output in run command and outputs must match")
expected = expected_pattern_for_spec(output_spec)
formatted_patterns = " \n".join(output_patterns)
raise ValidationError(
f"output specification must match the `--output` argument in the `run` command\n"
f" got: {formatted_patterns}\n"
f"but was expecting: {expected}"
)


def get_output_spec_from_args(args: list[str]) -> str | None:
Expand All @@ -176,6 +182,14 @@ def output_patterns_match_spec(spec: str, patterns: list[str]) -> bool:
return spec in patterns


def expected_pattern_for_spec(spec: str) -> str:
directory, extension = split_directory_and_extension(PurePosixPath(spec))
if extension:
return f"{directory}/:{extension[1:]}"
else:
return spec


# Borrowed directly from ehrQL:
# https://github.com/opensafely-core/ehrql/blob/e511dca176d0/ehrql/file_formats/main.py#L153-L166
def split_directory_and_extension(filename: PurePath) -> tuple[PurePath, str]:
Expand Down
2 changes: 1 addition & 1 deletion requirements.prod.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
opensafely-pipeline@https://github.com/opensafely-core/pipeline/archive/refs/tags/v2025.03.06.161237.zip
opensafely-pipeline@https://github.com/opensafely-core/pipeline/archive/refs/tags/v2026.01.26.163426.zip
ruyaml
requests
opentelemetry-api==1.33.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ idna==3.10
# via requests
importlib-metadata==8.5.0
# via opentelemetry-api
opensafely-pipeline @ https://github.com/opensafely-core/pipeline/archive/refs/tags/v2025.03.06.161237.zip
opensafely-pipeline @ https://github.com/opensafely-core/pipeline/archive/refs/tags/v2026.01.26.163426.zip
# via -r requirements.prod.in
opentelemetry-api==1.33.1
# via -r requirements.prod.in
Expand Down