Skip to content

Commit

Permalink
fix(workflow): replace BaseConfig with BaseModel and add verbose attr…
Browse files Browse the repository at this point in the history
…ibute in WorkflowConfig class
  • Loading branch information
entelecheia committed Jul 16, 2023
1 parent 1ef744a commit 5fb37fa
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/hyfi/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Dict, List, Optional, Union

from hyfi.composer import BaseConfig
from pydantic import BaseModel, ConfigDict, model_validator

from hyfi.composer import Composer
from hyfi.project import ProjectConfig
from hyfi.task import TaskConfig
from hyfi.utils.logging import LOGGING
Expand All @@ -10,16 +12,24 @@
Tasks = List[TaskConfig]


class WorkflowConfig(BaseConfig):
_config_name_: str = "__init__"
_config_group_: str = "workflow"

class WorkflowConfig(BaseModel):
project: Optional[ProjectConfig] = None
tasks: Optional[List[Union[str, Dict]]] = []
verbose: bool = False

model_config = ConfigDict(
arbitrary_types_allowed=True,
extra="allow",
validate_assignment=False,
) # type: ignore

@model_validator(mode="before")
def validate_model_config_before(cls, data):
# logger.debug("Validating model config before validating each field.")
return Composer.to_dict(data)

def get_tasks(self) -> Tasks:
self.tasks = self.tasks or []

tasks: Tasks = [
TaskConfig(**getattr(self, name))
for name in self.tasks
Expand Down

0 comments on commit 5fb37fa

Please sign in to comment.