-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split parsing classes between declaration and validation (#63)
* split Task and Data classes in parsing in 2 classes: - one for declaration of fields that are needed in core classes - one for pydantic validation This way core classes can inherit from the declaration classes and we avoid duplication. * remove metaclass for core.graph_items.Task this was overkill and has been replaced by an __init_subclass__ class method ---- Co-authored-by: Alexander Goscinski <[email protected]>
- Loading branch information
Showing
6 changed files
with
134 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from typing import ClassVar, Literal | ||
from dataclasses import dataclass | ||
|
||
from sirocco.core.graph_items import Task | ||
from sirocco.parsing import ConfigIconTask | ||
from sirocco.parsing._yaml_data_models import ConfigIconTaskSpecs | ||
|
||
|
||
@dataclass | ||
class IconTask(Task): | ||
plugin: ClassVar[Literal[ConfigIconTask.plugin]] = ConfigIconTask.plugin | ||
|
||
namelists: dict = field(default_factory=dict) | ||
class IconTask(ConfigIconTaskSpecs, Task): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import ClassVar, Literal | ||
|
||
from sirocco.core.graph_items import Task | ||
from sirocco.parsing import ConfigShellTask | ||
from sirocco.parsing._yaml_data_models import ConfigShellTaskSpecs | ||
|
||
|
||
@dataclass | ||
class ShellTask(Task): | ||
# plugin: ClassVar[str] = "shell" | ||
plugin: ClassVar[Literal[ConfigShellTask.plugin]] = ConfigShellTask.plugin | ||
|
||
command: str | None = None | ||
command_option: str | None = None | ||
input_arg_options: dict[str, str] | None = None | ||
src: str | None = None | ||
class ShellTask(ConfigShellTaskSpecs, Task): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
from ._yaml_data_models import ( | ||
ConfigBaseTask, | ||
ConfigIconTask, | ||
ConfigShellTask, | ||
load_workflow_config, | ||
) | ||
|
||
__all__ = [ | ||
"load_workflow_config", | ||
"ConfigBaseTask", | ||
"ConfigShellTask", | ||
"ConfigIconTask", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.