Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pydantic dependency #337

Merged
merged 20 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For example:
data = load_pipeline(f.read())


The returned object is a Pydantic model, `Pipeline`, defined in `pipeline/models.py`.
The returned object is an instance of `pipeline.models.Pipeline`.


## Developer docs
Expand Down
4 changes: 4 additions & 0 deletions pipeline/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ class InvalidPatternError(ProjectValidationError):

class YAMLError(Exception):
pass


class ValidationError(Exception):
pass
4 changes: 2 additions & 2 deletions pipeline/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

def get_all_output_patterns_from_project_file(project_file: str) -> list[str]:
config = load_pipeline(project_file)
all_patterns = set()
all_patterns: set[str] = set()
for action in config.actions.values():
for patterns in action.outputs.dict(exclude_unset=True).values():
for patterns in action.outputs.dict().values():
all_patterns.update(patterns.values())
return list(all_patterns)
8 changes: 3 additions & 5 deletions pipeline/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from pathlib import Path

import pydantic

from .exceptions import ProjectValidationError, YAMLError
from .exceptions import ProjectValidationError, ValidationError, YAMLError
from .loading import parse_yaml_file
from .models import Pipeline

Expand All @@ -27,8 +25,8 @@ def load_pipeline(pipeline_config: str | Path, filename: str | None = None) -> P

# validate
try:
return Pipeline(**parsed_data)
except pydantic.ValidationError as exc:
return Pipeline.build(**parsed_data)
except ValidationError as exc:
raise ProjectValidationError(
f"Invalid project: {filename or ''}\n{exc}"
) from exc
Loading