Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hexa 1134 dhis2 perameter validation #225

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nazarfil
Copy link
Contributor

@nazarfil nazarfil commented Jan 22, 2025

adds widget field to parameters
adds connection field to parameters
adds check on connection between parameters
removes remainings of parameter specs
https://bluesquare.atlassian.net/browse/HEXA-1134

@nazarfil nazarfil force-pushed the HEXA-1134-dhis2-perameter-validation branch from f4ffc9d to 322fd7f Compare January 24, 2025 10:04
@nazarfil nazarfil force-pushed the HEXA-1134-dhis2-perameter-validation branch 2 times, most recently from be3ef0d to fb2956a Compare January 24, 2025 10:11
@nazarfil nazarfil marked this pull request as ready for review January 24, 2025 14:53
@nazarfil nazarfil requested review from qgerome and YolanFery and removed request for qgerome January 24, 2025 15:16
@@ -159,6 +161,8 @@ def get_pipeline(pipeline_path: Path) -> Pipeline:
parameter = Parameter(type=type_class.expected_type, **parameter_args)
pipelines_parameters.append(parameter)

validate_parameters_with_connection(pipelines_parameters)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about what could we validate in SDK, and except verifying the link between a parameter with connection field and another parameter with related connection type I couldn't come up with anything else to check on.
Check if such connection if defined in database is already done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, checking that there is a link is enough. My suggestion above might help a little to make it more accurate

"connectionSlug": connection_slug,
},
)
response["data"]["connectionBySlug"]["status"] == "UP"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the pipeline run we could check in case of one of the parameters is DHIS2 connection if the server is up. But I am not sure it is adding much value in cli - wdyt?

@nazarfil nazarfil force-pushed the HEXA-1134-dhis2-perameter-validation branch from fb2956a to 1d2b736 Compare January 24, 2025 15:25
Comment on lines 515 to 531
def test_pipeline_with_widget_without_connection(self):
"""The file contains a @pipeline decorator and a @parameter decorator with a widget parameter field."""
with tempfile.TemporaryDirectory() as tmpdirname:
with open(f"{tmpdirname}/pipeline.py", "w") as f:
f.write(
"\n".join(
[
"from openhexa.sdk.pipelines import pipeline, parameter",
"",
"@parameter('test_field_for_wdiget', name='Widget Param', type=str, widget='custom_picker' help='Param help')",
"@pipeline('test', 'Test pipeline')",
"def test_pipeline():",
" pass",
"",
]
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does nothing, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed assert

"""Validate the provided connection parameters if they relate to existing connection parameter."""
for parameter in parameters:
if parameter.connection is not None:
if not any(p.code == parameter.connection for p in parameters):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to use only the parameters with a connection type (like type=DHIS2Connection), it's a bit more accurate than searching in the full list of parameters

@@ -159,6 +161,8 @@ def get_pipeline(pipeline_path: Path) -> Pipeline:
parameter = Parameter(type=type_class.expected_type, **parameter_args)
pipelines_parameters.append(parameter)

validate_parameters_with_connection(pipelines_parameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, checking that there is a link is enough. My suggestion above might help a little to make it more accurate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants