Skip to content

Commit 3b21532

Browse files
authored
Merge pull request #20880 from jmchilton/validate_columns
Validate sample sheet column definitions in workflow definitions on backend.
2 parents 29898ba + a8df2c8 commit 3b21532

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

lib/galaxy/dependencies/pinned-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ greenlet==3.2.4 ; (python_full_version < '3.14' and platform_machine == 'AMD64')
8282
grpcio==1.74.0
8383
grpcio-status==1.74.0
8484
gunicorn==23.0.0
85-
gxformat2==0.20.0
85+
gxformat2==0.21.0
8686
h11==0.16.0
8787
h5grove==2.3.0
8888
h5py==3.14.0

lib/galaxy/workflow/modules.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from galaxy.model.dataset_collections import matching
4242
from galaxy.model.dataset_collections.query import HistoryQuery
4343
from galaxy.model.dataset_collections.type_description import COLLECTION_TYPE_DESCRIPTION_FACTORY
44+
from galaxy.model.dataset_collections.types.sample_sheet_util import validate_column_definitions
4445
from galaxy.schema.invocation import (
4546
CancelReason,
4647
FailureReason,
@@ -1166,6 +1167,9 @@ def validate_state(self, state: dict[str, Any]) -> None:
11661167
fields=fields,
11671168
)
11681169
collection_type_description.validate()
1170+
column_definitions = state.get("column_definitions")
1171+
if column_definitions:
1172+
validate_column_definitions(column_definitions)
11691173
return None
11701174

11711175
def get_runtime_inputs(self, step, connections: Optional[Iterable[WorkflowStepConnection]] = None):

lib/galaxy_test/api/test_workflows.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7836,6 +7836,72 @@ def test_invalid_collection_input_rejected(self):
78367836
assert r.status_code == 400
78377837
assert "Invalid collection type:" in r.json()["err_msg"]
78387838

7839+
@skip_without_tool("multi_data_optional")
7840+
def test_invalid_sample_sheet_definitions_rejected(self):
7841+
valid_collection_type = """
7842+
class: GalaxyWorkflow
7843+
inputs:
7844+
input:
7845+
type: collection
7846+
collection_type: sample_sheet
7847+
column_definitions:
7848+
- type: string
7849+
name: condition
7850+
default_value: treatment
7851+
optional: false
7852+
restrictions: ["treatment", "control"]
7853+
steps:
7854+
multi_data_optional:
7855+
tool_id: multi_data_optional
7856+
in:
7857+
input1: input
7858+
"""
7859+
r = self._post("workflows", files={"archive_file": io.StringIO(valid_collection_type)})
7860+
assert r.status_code == 200
7861+
7862+
invalid_collection_type = """
7863+
class: GalaxyWorkflow
7864+
inputs:
7865+
input:
7866+
type: collection
7867+
collection_type: sample_sheet
7868+
column_definitions:
7869+
- type: stringx
7870+
name: condition
7871+
default_value: treatment
7872+
optional: false
7873+
restrictions: ["treatment", "control"]
7874+
steps:
7875+
multi_data_optional:
7876+
tool_id: multi_data_optional
7877+
in:
7878+
input1: input
7879+
"""
7880+
r = self._post("workflows", files={"archive_file": io.StringIO(invalid_collection_type)})
7881+
assert r.status_code == 400
7882+
7883+
invalid_collection_type = """
7884+
class: GalaxyWorkflow
7885+
inputs:
7886+
input:
7887+
type: collection
7888+
collection_type: sample_sheet
7889+
column_definitions:
7890+
- type: string
7891+
name: condition
7892+
default_value: treatment
7893+
optional: false
7894+
restrictions: ["treatment", "control"]
7895+
extra_key: not_allowed
7896+
steps:
7897+
multi_data_optional:
7898+
tool_id: multi_data_optional
7899+
in:
7900+
input1: input
7901+
"""
7902+
r = self._post("workflows", files={"archive_file": io.StringIO(invalid_collection_type)})
7903+
assert r.status_code == 400
7904+
78397905
@skip_without_tool("random_lines1")
78407906
def test_run_replace_params_over_default_delayed(self):
78417907
with self.dataset_populator.test_history() as history_id:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
"future>=1.0.0", # Python 3.12 support
4444
"gravity>=1.1.1",
4545
"gunicorn",
46-
"gxformat2",
46+
"gxformat2>=0.21.0",
4747
"h5grove>=1.2.1",
4848
"h5py>=3.12", # Python 3.13 support
4949
"httpx",

0 commit comments

Comments
 (0)