Add tools and tests for AnyImage model management and documentation
- Implement sync_models.py for preparing and uploading ONNX artifacts. - Create build_node.py for building and validating Blender scripts. - Add docs.py for building and previewing documentation with Mike or MkDocs. - Introduce model_exports.py for exporting PyTorch models to ONNX format. - Develop pack.py for packaging the project with dependencies for different platforms. - Add test_sync_models.py to validate sync_models functionality. - Add test_tool_commands.py to ensure repository tools have correct command scripts. - Initialize tools package with __init__.py.
This commit is contained in:
48
tools/docs.py
Normal file
48
tools/docs.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import argparse
|
||||
import subprocess
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def project_version():
|
||||
"""Return the documentation version declared by the project."""
|
||||
project = tomllib.loads(
|
||||
(PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")
|
||||
)["project"]
|
||||
return project["version"]
|
||||
|
||||
|
||||
def documentation_command(dev=False):
|
||||
"""Return the Mike or MkDocs command for the requested mode."""
|
||||
if dev:
|
||||
return ["mkdocs", "serve"]
|
||||
return [
|
||||
"mike",
|
||||
"deploy",
|
||||
"--update-aliases",
|
||||
project_version(),
|
||||
"latest",
|
||||
]
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description="Build or preview documentation.")
|
||||
parser.add_argument(
|
||||
"-dev",
|
||||
"--dev",
|
||||
action="store_true",
|
||||
help="preview the current documentation with live reload",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
subprocess.run(
|
||||
documentation_command(args.dev),
|
||||
cwd=PROJECT_ROOT,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user