Skip to content

Commit 08b13e5

Browse files
committed
feat: minor minor improvements
1 parent 4f97ab0 commit 08b13e5

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

openhexa/sdk/pipelines/parameter/choices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ChoicesFromFile(AstConstructible):
2626
def __init__(self, path: str, column: str | None = None):
2727
self.path = path
2828
self.column = column
29-
self.validate_spec()
29+
self._validate_spec()
3030
self.format = self._detect_format(path)
3131

3232
@staticmethod
@@ -39,7 +39,7 @@ def _detect_format(path: str) -> str:
3939
)
4040
return "yaml" if ext == "yml" else ext
4141

42-
def validate_spec(self):
42+
def _validate_spec(self):
4343
"""Validate the path and column specification."""
4444
if not self.path or not isinstance(self.path, str):
4545
raise InvalidParameterError("ChoicesFromFile path must be a non-empty string.")

openhexa/sdk/pipelines/parameter/decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def parameter(
277277
An optional default value for the parameter (should be of the type defined by the type parameter)
278278
required : bool, default=True
279279
Whether the parameter is mandatory
280-
multiple : bool, default=True
280+
multiple : bool, default=False
281281
Whether this parameter should be provided multiple values (if True, the value must be provided as a list of
282282
values of the chosen type)
283283
directory : str, optional

tests/test_choices.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ class TestStringShorthand:
6767

6868
def test_string_shorthand_csv(self):
6969
p = Parameter(code="district", type=str, choices="districts.csv")
70-
assert isinstance(p.choices, ChoicesFromFile)
71-
assert p.choices.path == "districts.csv"
72-
assert p.choices.format == "csv"
73-
assert p.choices.column is None
70+
assert p.choices == ChoicesFromFile("districts.csv")
7471

7572
def test_string_shorthand_json(self):
7673
p = Parameter(code="district", type=str, choices="data/regions.json")
@@ -104,7 +101,7 @@ def test_static_list_unaffected(self):
104101

105102
def test_explicit_choices_from_file_unaffected(self):
106103
p = Parameter(code="district", type=str, choices=ChoicesFromFile("districts.csv", column="code"))
107-
assert p.choices.column == "code"
104+
assert p.choices == ChoicesFromFile("districts.csv", column="code")
108105

109106
# --- invalid strings raise clearly ---
110107

@@ -124,7 +121,7 @@ def test_empty_string_raises(self):
124121

125122
def test_shorthand_has_no_column(self):
126123
p = Parameter(code="district", type=str, choices="districts.csv")
127-
assert p.choices.column is None
124+
assert p.choices == ChoicesFromFile("districts.csv")
128125

129126
def test_decorator_with_string_shorthand(self):
130127
@parameter(code="district", type=str, choices="districts.csv")

0 commit comments

Comments
 (0)