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
28 changes: 22 additions & 6 deletions examples/pipelines/iaso/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,39 @@
@parameter("iaso_con", type=IASOConnection, required=True)
@parameter(
"forms",
type=str,
type=int,
required=True,
widget=IASOWidget.FORMS,
widget=IASOWidget.IASO_FORMS,
multiple=True,
connection="iaso_con",
)
def iaso(iaso_con, forms):
@parameter(
"projects",
type=int,
required=True,
widget=IASOWidget.IASO_PROJECTS,
multiple=True,
connection="iaso_con",
)
@parameter(
"org_units",
type=int,
required=True,
widget=IASOWidget.IASO_ORG_UNITS,
multiple=True,
connection="iaso_con",
)
def iaso(iaso_con, forms, org_units, projects):
"""Get forms from IASO."""
print_forms(iaso_con, forms)
print_forms(iaso_con, forms, org_units, projects)


@iaso.task
def print_forms(iaso_con, forms):
def print_forms(iaso_con, forms, org_units, projects):
"""Print forms."""
current_run.log_info("Printing forms")

current_run.log_info(f"Forms: {forms}")
current_run.log_info(f"Forms: {forms}, Org Units: {org_units}, Projects: {projects}")


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions openhexa/sdk/pipelines/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ def validate(self, value: typing.Any | None) -> Dataset:
class IASOWidget(StrEnum):
"""Enum for IASO widgets."""

FORMS = "IASO_FORMS"
IASO_FORMS = "IASO_FORMS"
IASO_ORG_UNITS = "IASO_ORG_UNITS"
PROJECTS = "IASO_PROJECTS"
IASO_PROJECTS = "IASO_PROJECTS"


class DHIS2Widget(StrEnum):
Expand Down
18 changes: 9 additions & 9 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
"from openhexa.sdk.pipelines.widgets import IASOWidget",
"",
"@parameter('iaso_con', name='IASO Connection', type=IASOConnection, required=True)",
"@parameter('org_units', name='OrgUnits', type=str, widget=IASOWidget.IASO_ORG_UNITS, connection='iaso_con', required=True)",
"@parameter('projects', name='Projects', type=str, widget=IASOWidget.PROJECTS, connection='iaso_con', required=True)",
"@parameter('forms', name='Forms', type=str, widget=IASOWidget.FORMS, connection='iaso_con', required=True)",
"@parameter('org_units', name='OrgUnits', type=int, widget=IASOWidget.IASO_ORG_UNITS, connection='iaso_con', required=True)",
"@parameter('projects', name='Projects', type=int, widget=IASOWidget.IASO_PROJECTS, connection='iaso_con', required=True)",
"@parameter('forms', name='Forms', type=int, widget=IASOWidget.IASO_FORMS, connection='iaso_con', required=True)",
"@pipeline('Test pipeline')",
"def test_pipeline():",
"def test_pipeline(org_units, forms, projects):",
" pass",
"",
]
Expand Down Expand Up @@ -529,7 +529,7 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
},
{
"code": "org_units",
"type": "str",
"type": "int",
"name": "OrgUnits",
"widget": IASOWidget.IASO_ORG_UNITS.value,
"connection": "iaso_con",
Expand All @@ -541,9 +541,9 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
},
{
"code": "projects",
"type": "str",
"type": "int",
"name": "Projects",
"widget": IASOWidget.PROJECTS.value,
"widget": IASOWidget.IASO_PROJECTS.value,
"connection": "iaso_con",
"default": None,
"multiple": False,
Expand All @@ -553,9 +553,9 @@ def test_pipeline_with_connection_parameter_for_iaso(self):
},
{
"code": "forms",
"type": "str",
"type": "int",
"name": "Forms",
"widget": IASOWidget.FORMS.value,
"widget": IASOWidget.IASO_FORMS.value,
"connection": "iaso_con",
"default": None,
"multiple": False,
Expand Down