diff --git a/examples/pipelines/iaso/pipeline.py b/examples/pipelines/iaso/pipeline.py index 018d7700..7720a4e9 100644 --- a/examples/pipelines/iaso/pipeline.py +++ b/examples/pipelines/iaso/pipeline.py @@ -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__": diff --git a/openhexa/sdk/pipelines/parameter.py b/openhexa/sdk/pipelines/parameter.py index 409f8e57..d70c9620 100644 --- a/openhexa/sdk/pipelines/parameter.py +++ b/openhexa/sdk/pipelines/parameter.py @@ -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): diff --git a/tests/test_ast.py b/tests/test_ast.py index fdd465b4..5be00140 100644 --- a/tests/test_ast.py +++ b/tests/test_ast.py @@ -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", "", ] @@ -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", @@ -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, @@ -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,