Skip to content

Commit 32a2f1a

Browse files
author
nazarfil
committed
fix: prefix iaso widget with IASO_
1 parent 670fe92 commit 32a2f1a

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

examples/pipelines/iaso/pipeline.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,39 @@
99
@parameter("iaso_con", type=IASOConnection, required=True)
1010
@parameter(
1111
"forms",
12-
type=str,
12+
type=int,
1313
required=True,
14-
widget=IASOWidget.FORMS,
14+
widget=IASOWidget.IASO_FORMS,
1515
multiple=True,
1616
connection="iaso_con",
1717
)
18-
def iaso(iaso_con, forms):
18+
@parameter(
19+
"projects",
20+
type=int,
21+
required=True,
22+
widget=IASOWidget.IASO_PROJECTS,
23+
multiple=True,
24+
connection="iaso_con",
25+
)
26+
@parameter(
27+
"org_units",
28+
type=int,
29+
required=True,
30+
widget=IASOWidget.IASO_ORG_UNITS,
31+
multiple=True,
32+
connection="iaso_con",
33+
)
34+
def iaso(iaso_con, forms, org_units, projects):
1935
"""Get forms from IASO."""
20-
print_forms(iaso_con, forms)
36+
print_forms(iaso_con, forms, org_units, projects)
2137

2238

2339
@iaso.task
24-
def print_forms(iaso_con, forms):
40+
def print_forms(iaso_con, forms, org_units, projects):
2541
"""Print forms."""
2642
current_run.log_info("Printing forms")
2743

28-
current_run.log_info(f"Forms: {forms}")
44+
current_run.log_info(f"Forms: {forms}, Org Units: {org_units}, Projects: {projects}")
2945

3046

3147
if __name__ == "__main__":

openhexa/sdk/pipelines/parameter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ def validate(self, value: typing.Any | None) -> Dataset:
362362
class IASOWidget(StrEnum):
363363
"""Enum for IASO widgets."""
364364

365-
FORMS = "IASO_FORMS"
365+
IASO_FORMS = "IASO_FORMS"
366366
IASO_ORG_UNITS = "IASO_ORG_UNITS"
367-
PROJECTS = "IASO_PROJECTS"
367+
IASO_PROJECTS = "IASO_PROJECTS"
368368

369369

370370
class DHIS2Widget(StrEnum):

tests/test_ast.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,11 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
496496
"from openhexa.sdk.pipelines.widgets import IASOWidget",
497497
"",
498498
"@parameter('iaso_con', name='IASO Connection', type=IASOConnection, required=True)",
499-
"@parameter('org_units', name='OrgUnits', type=str, widget=IASOWidget.IASO_ORG_UNITS, connection='iaso_con', required=True)",
500-
"@parameter('projects', name='Projects', type=str, widget=IASOWidget.PROJECTS, connection='iaso_con', required=True)",
501-
"@parameter('forms', name='Forms', type=str, widget=IASOWidget.FORMS, connection='iaso_con', required=True)",
499+
"@parameter('org_units', name='OrgUnits', type=int, widget=IASOWidget.IASO_ORG_UNITS, connection='iaso_con', required=True)",
500+
"@parameter('projects', name='Projects', type=int, widget=IASOWidget.IASO_PROJECTS, connection='iaso_con', required=True)",
501+
"@parameter('forms', name='Forms', type=int, widget=IASOWidget.IASO_FORMS, connection='iaso_con', required=True)",
502502
"@pipeline('Test pipeline')",
503-
"def test_pipeline():",
503+
"def test_pipeline(org_units, forms, projects):",
504504
" pass",
505505
"",
506506
]
@@ -529,7 +529,7 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
529529
},
530530
{
531531
"code": "org_units",
532-
"type": "str",
532+
"type": "int",
533533
"name": "OrgUnits",
534534
"widget": IASOWidget.IASO_ORG_UNITS.value,
535535
"connection": "iaso_con",
@@ -541,9 +541,9 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
541541
},
542542
{
543543
"code": "projects",
544-
"type": "str",
544+
"type": "int",
545545
"name": "Projects",
546-
"widget": IASOWidget.PROJECTS.value,
546+
"widget": IASOWidget.IASO_PROJECTS.value,
547547
"connection": "iaso_con",
548548
"default": None,
549549
"multiple": False,
@@ -553,9 +553,9 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
553553
},
554554
{
555555
"code": "forms",
556-
"type": "str",
556+
"type": "int",
557557
"name": "Forms",
558-
"widget": IASOWidget.FORMS.value,
558+
"widget": IASOWidget.IASO_FORMS.value,
559559
"connection": "iaso_con",
560560
"default": None,
561561
"multiple": False,

0 commit comments

Comments
 (0)