Skip to content

Commit

Permalink
apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Jan 24, 2025
1 parent 1f25570 commit f4ffc9d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions examples/pipelines/logistic_stats/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def model(dhis2_data: dict[str, typing.Any], gadm_data, worldpop_data):
population_df = pd.Series(data=[stat["sum"] for stat in stats], index=administrative_areas.index)
population_df = pd.DataFrame({"District": administrative_areas["NAME_2"], "Population": population_df})
corrected_population_df = population_df.copy()
corrected_population_df.loc[
corrected_population_df["District"].str.startswith("Western"), "District"
] = "Western Area"
corrected_population_df.loc[corrected_population_df["District"].str.startswith("Western"), "District"] = (
"Western Area"
)

corrected_population_df = corrected_population_df.groupby("District").sum()

Expand Down
8 changes: 4 additions & 4 deletions openhexa/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ def generate_zip_file(pipeline_directory_path: typing.Union[str, Path]) -> io.By


def upload_pipeline(
pipeline_directory_path: typing.Union[str, Path],
name: str = None,
description: str = None,
link: str = None,
pipeline_directory_path: typing.Union[str, Path],
name: str = None,
description: str = None,
link: str = None,
):
"""Upload the pipeline contained in the provided directory using the GraphQL API.
Expand Down
1 change: 1 addition & 0 deletions openhexa/sdk/pipelines/log_level.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Log levels for the pipeline runs."""

from enum import IntEnum


Expand Down
11 changes: 7 additions & 4 deletions openhexa/sdk/pipelines/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ def validate(self, value: typing.Any) -> typing.Any:
else:
return self._validate_single(value)


def to_dict(self) -> dict[str, typing.Any]:
"""Return a dictionary representation of the Parameter instance."""
return {
Expand Down Expand Up @@ -518,12 +517,16 @@ def _validate_default(self, default: typing.Any, multiple: bool):
f"The default value for {self.code} is not included in the provided choices."
)

def validate_connection_parameters(parameters : [Parameter]):
"""Validate the provided connection parameters."""

def validate_parameters_with_connection(parameters: [Parameter]):
"""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):
raise InvalidParameterError(f"Connection parameter {parameter.code} references a non-existing parameter {parameter.connection}")
raise InvalidParameterError(
f"Connection parameter {parameter.code} references a non-existing parameter {parameter.connection}"
)


def parameter(
code: str,
Expand Down
4 changes: 2 additions & 2 deletions openhexa/sdk/pipelines/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import requests

from openhexa.sdk.pipelines.exceptions import PipelineNotFound
from openhexa.sdk.pipelines.parameter import TYPES_BY_PYTHON_TYPE, Parameter, validate_connection_parameters
from openhexa.sdk.pipelines.parameter import TYPES_BY_PYTHON_TYPE, Parameter, validate_parameters_with_connection

from .pipeline import Pipeline

Expand Down Expand Up @@ -161,7 +161,7 @@ def get_pipeline(pipeline_path: Path) -> Pipeline:
parameter = Parameter(type=type_class.expected_type, **parameter_args)
pipelines_parameters.append(parameter)

validate_connection_parameters(pipelines_parameters)
validate_parameters_with_connection(pipelines_parameters)

pipeline = Pipeline(parameters=pipelines_parameters, function=None, **pipeline_decorator_spec["args"])

Expand Down
2 changes: 1 addition & 1 deletion tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,4 @@ def test_pipeline_wit_wrong_connection_parameter(self):
)
)
with self.assertRaises(InvalidParameterError):
pipeline = get_pipeline(tmpdirname)
pipeline = get_pipeline(tmpdirname)
1 change: 0 additions & 1 deletion tests/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ def test_parameter_validate_multiple():
parameter_4.validate(["ab", "xy"])



def test_parameter_decorator():
"""Ensure that the @parameter decorator behaves as expected (options and defaults)."""

Expand Down

0 comments on commit f4ffc9d

Please sign in to comment.