Skip to content

Commit 774c28b

Browse files
yolanferyblsqbot
andauthored
feat: add secret field type to pipeline parameters
* Revert "chore(deps): update dependency python to 3.14 (#363)" This reverts commit 178b0a7. * fix: parameter typing for File (#371) * chore: release v2.19.4 (#370) * fix: type * fix: type test --------- Co-authored-by: blsqbot <83090543+blsqbot@users.noreply.github.com>
1 parent d334698 commit 774c28b

7 files changed

Lines changed: 30 additions & 16 deletions

File tree

.github/workflows/schema-compatibility-cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: actions/setup-python@v6
1414
with:
15-
python-version: "3.14"
15+
python-version: "3.13"
1616

1717
- run: pip install --upgrade openhexa.sdk
1818

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.19.3"
2+
".": "2.19.4"
33
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [2.19.4](https://github.com/BLSQ/openhexa-sdk-python/compare/v2.19.3...v2.19.4) (2026-04-01)
4+
5+
6+
### Bug Fixes
7+
8+
* parameter typing for File ([#371](https://github.com/BLSQ/openhexa-sdk-python/issues/371)) ([c19a404](https://github.com/BLSQ/openhexa-sdk-python/commit/c19a4048d840a849e7df0669ea100417521417e1))
9+
10+
11+
### Miscellaneous
12+
13+
* **deps:** update dependency python to 3.14 ([#363](https://github.com/BLSQ/openhexa-sdk-python/issues/363)) ([178b0a7](https://github.com/BLSQ/openhexa-sdk-python/commit/178b0a763455393be282ca9602db25f6182b6471))
14+
315
## [2.19.3](https://github.com/BLSQ/openhexa-sdk-python/compare/v2.19.2...v2.19.3) (2026-03-16)
416

517

openhexa/sdk/pipelines/parameter.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def validate(self, value: typing.Any | None) -> File:
389389
raise ParameterValueError(str(e))
390390

391391

392-
class Secret:
392+
class Secret(str):
393393
"""Marker type for secret/password pipeline parameters.
394394
395395
Use as the ``type`` argument of the ``@parameter`` decorator to indicate that the parameter value is sensitive
@@ -418,7 +418,7 @@ def spec_type(self) -> str:
418418
@property
419419
def expected_type(self) -> type:
420420
"""Returns the python type expected for values."""
421-
return str
421+
return Secret
422422

423423
@property
424424
def accepts_choices(self) -> bool:
@@ -431,8 +431,8 @@ def accepts_multiple(self) -> bool:
431431
return False
432432

433433
@staticmethod
434-
def normalize(value: typing.Any) -> str | None:
435-
"""Strip whitespace and convert empty strings to None."""
434+
def normalize(value: typing.Any) -> Secret | None:
435+
"""Strip whitespace, convert empty strings to None, and wrap as Secret."""
436436
if isinstance(value, str):
437437
normalized_value = value.strip()
438438
else:
@@ -441,6 +441,9 @@ def normalize(value: typing.Any) -> str | None:
441441
if normalized_value == "":
442442
return None
443443

444+
if isinstance(normalized_value, str):
445+
return Secret(normalized_value)
446+
444447
return normalized_value
445448

446449
def validate_default(self, value: typing.Any | None):
@@ -509,6 +512,7 @@ def __init__(
509512
| S3Connection
510513
| CustomConnection
511514
| Dataset
515+
| File
512516
],
513517
name: str | None = None,
514518
choices: typing.Sequence | None = None,
@@ -524,10 +528,7 @@ def __init__(
524528
self.code = code
525529

526530
try:
527-
if isinstance(type, ParameterType):
528-
self.type = type
529-
else:
530-
self.type = TYPES_BY_PYTHON_TYPE[type.__name__]()
531+
self.type = TYPES_BY_PYTHON_TYPE[type.__name__]()
531532
except (KeyError, AttributeError):
532533
valid_parameter_types = [k for k in TYPES_BY_PYTHON_TYPE.keys()]
533534
raise InvalidParameterError(
@@ -696,6 +697,7 @@ def parameter(
696697
| S3Connection
697698
| CustomConnection
698699
| Dataset
700+
| File
699701
],
700702
name: str | None = None,
701703
choices: typing.Sequence | None = None,
@@ -715,7 +717,7 @@ def parameter(
715717
----------
716718
code : str
717719
The parameter identifier (must be unique for a given pipeline)
718-
type : {str, int, bool, float, DHIS2Connection, IASOConnection, PostgreSQLConnection, GCSConnection, S3Connection}
720+
type : {str, int, bool, float, DHIS2Connection, IASOConnection, PostgreSQLConnection, GCSConnection, S3Connection, CustomConnection, Dataset, File}
719721
The parameter Python type
720722
name : str, optional
721723
A name for the parameter (will be used instead of the code in the web interface)
@@ -736,7 +738,7 @@ def parameter(
736738
Whether this parameter should be provided multiple values (if True, the value must be provided as a list of
737739
values of the chosen type)
738740
directory : str, optional
739-
An optional parameter to force file selection to specific directory (only used for parater type File). If the directory does not exist, it will be ignored.
741+
An optional parameter to force file selection to specific directory (only used for parameter type File). If the directory does not exist, it will be ignored.
740742
741743
Returns
742744
-------

openhexa/sdk/pipelines/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def get_pipeline(pipeline_path: Path) -> Pipeline:
308308
# Convert args spec to parameter kwargs
309309
param_kwargs = {k: v["value"] for k, v in parameter_args.items()}
310310

311-
parameter = Parameter(type=type_class, **param_kwargs)
311+
parameter = Parameter(type=type_class.expected_type, **param_kwargs)
312312
pipeline_parameters.append(parameter)
313313

314314
except KeyError as e:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "openhexa.sdk"
7-
version = "2.19.3"
7+
version = "2.19.4"
88
description = "OpenHEXA SDK"
99

1010
authors = [{ name = "Bluesquare", email = "dev@bluesquarehub.com" }]
@@ -20,7 +20,7 @@ requires-python = ">=3.11,<3.15" # the main constraint for supported Python vers
2020
dependencies = [
2121
"urllib3<3",
2222
"multiprocess~=0.70.15",
23-
"requests>=2.31,<2.33",
23+
"requests>=2.31,<2.34",
2424
"PyYAML~=6.0",
2525
"click~=8.1.3",
2626
"jinja2>3,<4",

tests/test_parameter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_secret_type_normalize():
106106
def test_secret_type_validate():
107107
"""Check validation for SecretType."""
108108
secret_type = SecretType()
109-
assert secret_type.validate("my-token") == "my-token"
109+
assert secret_type.validate(Secret("my-token")) == "my-token"
110110
with pytest.raises(ParameterValueError):
111111
secret_type.validate(123)
112112

0 commit comments

Comments
 (0)