Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Sep 30, 2024
1 parent bfcfd5a commit 6117838
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
1 change: 0 additions & 1 deletion openhexa/sdk/pipelines/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ def to_dict(self) -> dict[str, typing.Any]:
"multiple": self.multiple,
}


def _validate_single(self, value: typing.Any):
# Normalize empty values to None and handles default
normalized_value = self.type.normalize(value)
Expand Down
3 changes: 2 additions & 1 deletion openhexa/sdk/pipelines/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ def parameters_spec(self) -> list[dict[str, typing.Any]]:
return [arg.parameter_spec() for arg in self.parameters]

def to_dict(self):
"""Return a dictionary representation of the pipeline."""
return {
"code": self.code,
"name": self.name,
"parameters": [p.to_dict() for p in self.parameters],
"timeout": self.timeout,
"function": self.function.__name__ if self.function else None,
"function": self.function.__dict__ if self.function else None,
"tasks": [t.__dict__ for t in self.tasks],
}

Expand Down
5 changes: 3 additions & 2 deletions openhexa/sdk/pipelines/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import requests

from openhexa.sdk.pipelines.exceptions import InvalidParameterError, PipelineNotFound
from openhexa.sdk.pipelines.exceptions import PipelineNotFound
from openhexa.sdk.pipelines.parameter import TYPES_BY_PYTHON_TYPE, Parameter
from openhexa.sdk.pipelines.utils import validate_pipeline_parameter_code

Expand Down Expand Up @@ -190,7 +190,8 @@ def get_pipeline(pipeline_path: Path) -> Pipeline:
help=args.get("help"),
default=args.get("default"),
required=args.get("required") if args.get("required") is not None else True,
multiple=args.get("multiple") if args.get("multiple") is not None else False,)
multiple=args.get("multiple") if args.get("multiple") is not None else False,
)
pipelines_parameters.append(parameter)

pipeline = Pipeline(parameters=pipelines_parameters, function=None, **pipeline_decorator_spec["args"])
Expand Down
32 changes: 22 additions & 10 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""Tests related to the parsing of the pipeline code."""

import json
import tempfile
from dataclasses import asdict
from unittest import TestCase

from openhexa.sdk.pipelines.exceptions import InvalidParameterError, PipelineNotFound
from openhexa.sdk.pipelines.exceptions import PipelineNotFound
from openhexa.sdk.pipelines.runtime import get_pipeline


Expand Down Expand Up @@ -38,8 +36,15 @@ def test_pipeline_no_parameters(self):
)
pipeline = get_pipeline(tmpdirname)
self.assertEqual(
pipeline.to_dict(), {"code": "test", "name": "Test pipeline", "function": None,
"tasks": [], "parameters": [], "timeout": None}
pipeline.to_dict(),
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks": [],
"parameters": [],
"timeout": None,
},
)

def test_pipeline_with_args(self):
Expand All @@ -59,8 +64,15 @@ def test_pipeline_with_args(self):
)
pipeline = get_pipeline(tmpdirname)
self.assertEqual(
pipeline.to_dict(), {"code": "test", "function": None,
"tasks": [], "name": "Test pipeline", "parameters": [], "timeout": None}
pipeline.to_dict(),
{
"code": "test",
"function": None,
"tasks": [],
"name": "Test pipeline",
"parameters": [],
"timeout": None,
},
)

def test_pipeline_with_invalid_parameter_args(self):
Expand Down Expand Up @@ -291,8 +303,8 @@ def test_pipeline_with_timeout(self):
"parameters": [],
"timeout": 42,
"function": None,
"tasks": []
}
"tasks": [],
},
)

def test_pipeline_with_bool(self):
Expand Down Expand Up @@ -361,7 +373,7 @@ def test_pipeline_with_multiple_parameters(self):
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks" : [],
"tasks": [],
"parameters": [
{
"choices": None,
Expand Down

0 comments on commit 6117838

Please sign in to comment.