Skip to content

Commit

Permalink
option to source custom code in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov721 committed Feb 20, 2024
1 parent 8e35f25 commit 1964fd7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 237 deletions.
17 changes: 11 additions & 6 deletions luxonis_train/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,18 @@ def common(
"--version", callback=version_callback, help="Show version and exit."
),
] = False,
source: Annotated[
Optional[Path],
typer.Option(
help="Path to a python file with custom components. "
"Will be sourced before running the command.",
metavar="FILE",
),
] = None,
):
...


def main():
app()
if source:
exec(source.read_text(), {}, {})


if __name__ == "__main__":
main()
app()
5 changes: 1 addition & 4 deletions luxonis_train/core/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@


class Exporter(Core):
"""Main API which is used to create the model, setup pytorch lightning environment
and perform training based on provided arguments and config."""

def __init__(
self,
cfg: str | dict[str, Any] | Config,
opts: list[str] | tuple[str, ...] | dict[str, Any] | None = None,
):
"""Constructs a new Exporter instance.
"""Provides an interface for exporting models to .onnx and .blob formats.
@type cfg: str | dict[str, Any] | Config
@param cfg: Path to config file or config dict used to setup training.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
]

[project.scripts]
luxonis_train = "tools.main:main"
luxonis_train = "luxonis_train.__main__:app"

[project.urls]
repository = "https://github.com/luxonis/luxonis-train"
Expand Down
226 changes: 0 additions & 226 deletions tools/main.py

This file was deleted.

0 comments on commit 1964fd7

Please sign in to comment.