Skip to content

Commit

Permalink
Rename Pydantic models to disambiguate
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-herrmann committed Aug 22, 2024
1 parent e73c656 commit 26c2a3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SearchField(BaseModel):
value: str


class Search(BaseModel):
class SearchConfig(BaseModel):
"""Represents the search configuration in the YAML file."""

header: Optional[str] = Field(
Expand All @@ -70,7 +70,7 @@ class Search(BaseModel):
)


class Report(BaseModel):
class ReportConfig(BaseModel):
"""Represents the report configuration in the YAML file."""

slack: Optional[dict] = Field(
Expand Down Expand Up @@ -107,7 +107,7 @@ class Report(BaseModel):
)


class DAG(BaseModel):
class DAGConfig(BaseModel):
"""Represents the DAG configuration in the YAML file."""

id: str = Field(description="Nome único da DAG")
Expand All @@ -120,17 +120,17 @@ class DAG(BaseModel):
)
schedule: Optional[str] = Field(default=None, description="Expressão cron")
dataset: Optional[str] = Field(default=None, description="Nome do Dataset")
search: Union[List[Search], Search] = Field(
search: Union[List[SearchConfig], SearchConfig] = Field(
description="Seção para definição da busca no Diário"
)
doc_md: Optional[str] = Field(default="", description="description")
report: Report = Field(
report: ReportConfig = Field(
description="Aceita: `slack`, `discord`, `emails`, `attach_csv`, "
"`subject`, `skip_null`"
)


class Config(BaseModel):
class RoDouConfig(BaseModel):
"""Represents the overall configuration in the YAML file."""

dag: DAG = Field(description="Instanciação da DAG")
dag: DAGConfig = Field(description="Instanciação da DAG")
4 changes: 2 additions & 2 deletions tests/test_validate_yaml_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# add module path so we can import from other modules
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from schemas import Config
from schemas import RoDouConfig

YAMLS_DIR = "../dags/ro_dou/dag_confs"

Expand All @@ -29,6 +29,6 @@ def test_pydantic_validation(data_file):
data = yaml.safe_load(data_fp)

try:
Config(**data)
RoDouConfig(**data)
except ValidationError as e:
pytest.fail(f"YAML file {data_file} is not valid:\n{e}")

0 comments on commit 26c2a3a

Please sign in to comment.