Skip to content

Commit

Permalink
Add module model
Browse files Browse the repository at this point in the history
  • Loading branch information
shirte committed Nov 25, 2024
1 parent 82e5058 commit cd7bcc3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions nerdd_backend/data/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Any, Optional

from nerdd_module.config import Module as NerddModule
from pydantic import model_validator

__all__ = ["Module"]


class Module(NerddModule):
id: Optional[str] = None

@model_validator(mode="after")
@classmethod
def validate_model(cls, values: Any) -> Any:
assert isinstance(values, Module)

module = super().validate_model(values)

# TODO: incorporate versioning
# compute the primary key from name and version
# if "version" in module.keys():
# version = module["version"]
# else:
# version = "1.0.0"
# name = module["name"]
module.id = module.name

return module

0 comments on commit cd7bcc3

Please sign in to comment.