Skip to content

Commit eefe899

Browse files
committed
feat: finish implementation and refactorings for entrypoint validation
1 parent 27917ad commit eefe899

11 files changed

Lines changed: 353 additions & 525 deletions

File tree

src/dioptra/restapi/errors.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ def __init__(self):
348348
)
349349

350350

351-
class EntrypointWorkflowYamlValidationError(DioptraError):
352-
"""The entrypoint worklfow yaml is invalid."""
351+
class EntrypointValidationError(DioptraError):
352+
"""The proposed inputs for the entrypoint are invalid."""
353353

354354
def __init__(self, issues: list[ValidationIssue]):
355-
super().__init__("The entrypoint worklfow yaml is invalid.")
355+
super().__init__("The proposed inputs for the entrypoint are invalid.")
356356
self.issues = issues
357357

358358

@@ -557,9 +557,9 @@ def handle_base_error(error: DioptraError):
557557
log.debug(error.to_message())
558558
return error_result(error, http.HTTPStatus.BAD_REQUEST, {})
559559

560-
@api.errorhandler(DioptraError)
560+
@api.errorhandler(EntrypointValidationError)
561561
def handle_entrypoint_workflow_yaml_validation_error(
562-
error: EntrypointWorkflowYamlValidationError,
562+
error: EntrypointValidationError,
563563
):
564564
log.debug(error.to_message())
565565
return error_result(
@@ -572,7 +572,7 @@ def handle_entrypoint_workflow_yaml_validation_error(
572572
"severity": str(issue.severity),
573573
"message": issue.message,
574574
}
575-
for issue in error.args[0]
575+
for issue in error.issues
576576
]
577577
},
578578
)

src/dioptra/restapi/v1/shared/build_task_engine_dict.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/dioptra/restapi/v1/shared/entrypoint_validate_service.py

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/dioptra/restapi/v1/shared/task_engine_yaml/protocols.py

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515
# ACCESS THE FULL CC BY 4.0 LICENSE HERE:
1616
# https://creativecommons.org/licenses/by/4.0/legalcode
17+
from collections.abc import Sequence
1718
from typing import Any, Protocol
1819

1920

@@ -24,43 +25,73 @@ class EntryPointParameterProtocol(Protocol):
2425

2526

2627
class EntryPointProtocol(Protocol):
27-
task_graph: str
28-
parameters: list[EntryPointParameterProtocol]
28+
@property
29+
def task_graph(self) -> str: # fmt: skip
30+
...
31+
32+
@property
33+
def parameters(self) -> Sequence[EntryPointParameterProtocol]: # fmt: skip
34+
...
2935

3036

3137
class PluginTaskParameterTypeProtocol(Protocol):
32-
name: str
33-
structure: dict[str, Any] | None
38+
@property
39+
def name(self) -> str: # fmt: skip
40+
...
41+
42+
@property
43+
def structure(self) -> dict[str, Any] | None: # fmt: skip
44+
...
3445

3546

3647
class PluginTaskInputParameterProtocol(Protocol):
3748
parameter_number: int
3849
name: str
3950
required: bool
40-
parameter_type: PluginTaskParameterTypeProtocol
51+
52+
@property
53+
def parameter_type(self) -> PluginTaskParameterTypeProtocol: # fmt: skip
54+
...
4155

4256

4357
class PluginTaskOutputParameterProtocol(Protocol):
4458
parameter_number: int
4559
name: str
46-
parameter_type: PluginTaskParameterTypeProtocol
60+
61+
@property
62+
def parameter_type(self) -> PluginTaskParameterTypeProtocol: # fmt: skip
63+
...
4764

4865

4966
class PluginTaskProtocol(Protocol):
5067
plugin_task_name: str
51-
input_parameters: list[PluginTaskInputParameterProtocol]
52-
output_parameters: list[PluginTaskOutputParameterProtocol]
68+
69+
@property
70+
def input_parameters(self) -> Sequence[PluginTaskInputParameterProtocol]: # noqa: B950; fmt: skip
71+
...
72+
73+
@property
74+
def output_parameters(self) -> Sequence[PluginTaskOutputParameterProtocol]: # noqa: B950; fmt: skip
75+
...
5376

5477

5578
class PluginFileProtocol(Protocol):
5679
filename: str
57-
tasks: list[PluginTaskProtocol]
80+
81+
@property
82+
def tasks(self) -> Sequence[PluginTaskProtocol]: # fmt: skip
83+
...
5884

5985

6086
class PluginProtocol(Protocol):
6187
name: str
6288

6389

6490
class PluginPluginFileProtocol(Protocol):
65-
plugin: PluginProtocol
66-
plugin_file: PluginFileProtocol
91+
@property
92+
def plugin(self) -> PluginProtocol: # fmt: skip
93+
...
94+
95+
@property
96+
def plugin_file(self) -> PluginFileProtocol: # fmt: skip
97+
...

0 commit comments

Comments
 (0)