Skip to content

Commit

Permalink
fix: validate and raise error for invalid '/' characters in module na…
Browse files Browse the repository at this point in the history
…mes or aliases
  • Loading branch information
JSabadin committed Jan 29, 2025
1 parent 028da04 commit b808b4a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions luxonis_train/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,32 @@ def check_graph(self) -> Self:
raise ValueError("No outputs specified.")
return self

@model_validator(mode="after")
def check_for_invalid_characters(self) -> Self:
for modules in [
self.nodes,
self.losses,
self.metrics,
self.visualizers,
]:
invalid_char_error_message = (
"Name, alias or attached module contains a '/', which is not allowed. "
"Please rename the node or module to remove any '/' characters."
)
for module in modules:
if isinstance(module, AttachedModuleConfig):
if (module.attached_to and "/" in module.attached_to) or (
module.name and "/" in module.name
):
raise ValueError(invalid_char_error_message)

if isinstance(module, ModelNodeConfig):
if (module.alias and "/" in module.alias) or (
module.name and "/" in module.name
):
raise ValueError(invalid_char_error_message)
return self

@model_validator(mode="after")
def check_unique_names(self) -> Self:
for modules in [
Expand Down

0 comments on commit b808b4a

Please sign in to comment.