mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-13 19:33:46 +08:00
1 parent
ea591246cb
commit
edbfccccfe
19 files changed
+68
-68
No files matched your search
@@ -12,7 +12,7 @@ import subprocess
|
||||
import sys
|
||||
from typing import List, Literal, Union
|
||||
|
||||
import dcargs
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
from rich.prompt import Confirm
|
||||
from typing_extensions import assert_never
|
||||
@@ -33,8 +33,8 @@ ENTRYPOINTS = [
|
||||
]
|
||||
|
||||
|
||||
def _check_dcargs_cli(script_path: pathlib.Path) -> bool:
|
||||
"""Check if a path points to a script containing a dcargs.cli() call. Also checks
|
||||
def _check_tyro_cli(script_path: pathlib.Path) -> bool:
|
||||
"""Check if a path points to a script containing a tyro.cli() call. Also checks
|
||||
for any permissions/shebang issues.
|
||||
|
||||
Args:
|
||||
@@ -48,7 +48,7 @@ def _check_dcargs_cli(script_path: pathlib.Path) -> bool:
|
||||
|
||||
if '\nif __name__ == "__main__":\n' in script_src:
|
||||
# Check script for execute permissions. For consistency, note that we apply this
|
||||
# and the shebang check even if dcargs isn't used.
|
||||
# and the shebang check even if tyro isn't used.
|
||||
execute_flags = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||
if not script_path.stat().st_mode & execute_flags and Confirm.ask(
|
||||
f"[yellow]:warning: {script_path} is not marked as executable. Fix?[/yellow]",
|
||||
@@ -63,15 +63,15 @@ def _check_dcargs_cli(script_path: pathlib.Path) -> bool:
|
||||
):
|
||||
script_path.write_text("#!/usr/bin/env python\n" + script_src)
|
||||
|
||||
# Return True only if compatible with dcargs.
|
||||
return "import dcargs" in script_src and "dcargs.cli" in script_src
|
||||
# Return True only if compatible with tyro.
|
||||
return "import tyro" in script_src and "tyro.cli" in script_src
|
||||
return False
|
||||
|
||||
|
||||
def _generate_completion(
|
||||
path_or_entrypoint: Union[pathlib.Path, str], shell: ShellType, completions_dir: pathlib.Path
|
||||
) -> pathlib.Path:
|
||||
"""Given a path to a dcargs CLI, write a completion script to a target directory.
|
||||
"""Given a path to a tyro CLI, write a completion script to a target directory.
|
||||
|
||||
Args:
|
||||
script_path: Path to Python CLI to generate completion script for.
|
||||
@@ -84,11 +84,11 @@ def _generate_completion(
|
||||
if isinstance(path_or_entrypoint, pathlib.Path):
|
||||
# Scripts.
|
||||
target_name = "_" + path_or_entrypoint.name.replace(".", "_")
|
||||
args = [sys.executable, str(path_or_entrypoint), "--dcargs-print-completion", shell]
|
||||
args = [sys.executable, str(path_or_entrypoint), "--tyro-print-completion", shell]
|
||||
elif isinstance(path_or_entrypoint, str):
|
||||
# Entry points.
|
||||
target_name = "_" + path_or_entrypoint
|
||||
args = [path_or_entrypoint, "--dcargs-print-completion", shell]
|
||||
args = [path_or_entrypoint, "--tyro-print-completion", shell]
|
||||
else:
|
||||
assert_never(path_or_entrypoint)
|
||||
|
||||
@@ -204,7 +204,7 @@ def main(
|
||||
assert completions_dir.name == "completions"
|
||||
assert scripts_dir.name == "scripts"
|
||||
|
||||
# Install mode: Generate completion for each dcargs script.
|
||||
# Install mode: Generate completion for each tyro script.
|
||||
if mode == "uninstall":
|
||||
for shell in shells_supported:
|
||||
# Reset target directory for each shell type.
|
||||
@@ -219,8 +219,8 @@ def main(
|
||||
# Set to True to install completions for scripts as well.
|
||||
include_scripts = False
|
||||
|
||||
# Find dcargs CLIs.
|
||||
script_paths = list(filter(_check_dcargs_cli, scripts_dir.glob("**/*.py"))) if include_scripts else []
|
||||
# Find tyro CLIs.
|
||||
script_paths = list(filter(_check_tyro_cli, scripts_dir.glob("**/*.py"))) if include_scripts else []
|
||||
script_names = tuple(p.name for p in script_paths)
|
||||
assert len(set(script_names)) == len(script_names)
|
||||
|
||||
@@ -264,8 +264,8 @@ def main(
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main, description=__doc__)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main, description=__doc__)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import sys
|
||||
from glob import glob
|
||||
|
||||
import dcargs
|
||||
import nbformat as nbf
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
|
||||
console = Console(width=120)
|
||||
@@ -75,5 +75,5 @@ def main(check: bool = False):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main)
|
||||
@@ -3,7 +3,7 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import dcargs
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
from rich.style import Style
|
||||
|
||||
@@ -48,5 +48,5 @@ def main(clean_cache: bool = False):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main)
|
||||
@@ -6,8 +6,8 @@ import zipfile
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
|
||||
import dcargs
|
||||
import gdown
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
|
||||
console = Console(width=120)
|
||||
@@ -74,7 +74,7 @@ nerfstudio_file_ids = {
|
||||
"vegetation": grab_file_id("https://drive.google.com/file/d/1wBhLQ2odycrtU39y2akVurXEAt9SsVI3/view?usp=sharing"),
|
||||
}
|
||||
|
||||
DatasetName = dcargs.extras.literal_type_from_choices(nerfstudio_file_ids.keys())
|
||||
DatasetName = tyro.extras.literal_type_from_choices(nerfstudio_file_ids.keys())
|
||||
|
||||
|
||||
def download_nerfstudio(save_dir: Path, capture_name: str):
|
||||
@@ -141,12 +141,12 @@ def main(
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entrypoint()
|
||||
|
||||
# For sphinx docs
|
||||
get_parser_fn = lambda: dcargs.extras.get_parser(main) # noqa
|
||||
get_parser_fn = lambda: tyro.extras.get_parser(main) # noqa
|
||||
+4
-4
@@ -9,7 +9,7 @@ import logging
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import dcargs
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
|
||||
from nerfstudio.utils.eval_utils import eval_setup
|
||||
@@ -48,12 +48,12 @@ class ComputePSNR:
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(ComputePSNR).main()
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(ComputePSNR).main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entrypoint()
|
||||
|
||||
# For sphinx docs
|
||||
get_parser_fn = lambda: dcargs.extras.get_parser(ComputePSNR) # noqa
|
||||
get_parser_fn = lambda: tyro.extras.get_parser(ComputePSNR) # noqa
|
||||
@@ -3,7 +3,7 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import dcargs
|
||||
import tyro
|
||||
import yaml
|
||||
from rich.console import Console
|
||||
from rich.style import Style
|
||||
@@ -88,8 +88,8 @@ def run_code_checks(continue_on_fail: bool = False):
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(run_code_checks)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(run_code_checks)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -10,9 +10,9 @@ from pathlib import Path
|
||||
from typing import Literal, Optional, Tuple
|
||||
|
||||
import appdirs
|
||||
import dcargs
|
||||
import numpy as np
|
||||
import requests
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
from rich.progress import track
|
||||
|
||||
@@ -488,12 +488,12 @@ def main(
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entrypoint()
|
||||
|
||||
# For sphinx docs
|
||||
get_parser_fn = lambda: dcargs.extras.get_parser(main) # noqa
|
||||
get_parser_fn = lambda: tyro.extras.get_parser(main) # noqa
|
||||
+4
-4
@@ -11,9 +11,9 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
|
||||
import dcargs
|
||||
import mediapy as media
|
||||
import torch
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
from rich.progress import (
|
||||
BarColumn,
|
||||
@@ -148,12 +148,12 @@ class RenderTrajectory:
|
||||
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(RenderTrajectory).main()
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(RenderTrajectory).main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entrypoint()
|
||||
|
||||
# For sphinx docs
|
||||
get_parser_fn = lambda: dcargs.extras.get_parser(RenderTrajectory) # noqa
|
||||
get_parser_fn = lambda: tyro.extras.get_parser(RenderTrajectory) # noqa
|
||||
+3
-3
@@ -12,11 +12,11 @@ import traceback
|
||||
from datetime import timedelta
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
import dcargs
|
||||
import numpy as np
|
||||
import torch
|
||||
import torch.distributed as dist
|
||||
import torch.multiprocessing as mp
|
||||
import tyro
|
||||
import yaml
|
||||
|
||||
from nerfstudio.configs import base_config as cfg
|
||||
@@ -212,8 +212,8 @@ def main(config: cfg.Config) -> None:
|
||||
def entrypoint():
|
||||
"""Entrypoint for use with pyproject scripts."""
|
||||
# Choose a base configuration and override values.
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
main(dcargs.cli(AnnotatedBaseConfigUnion))
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
main(tyro.cli(AnnotatedBaseConfigUnion))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -8,8 +8,8 @@ import time
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
|
||||
import dcargs
|
||||
import torch
|
||||
import tyro
|
||||
|
||||
from nerfstudio.configs import base as cfg
|
||||
from nerfstudio.data.base import AnnotatedDataParserUnion
|
||||
@@ -38,5 +38,5 @@ def main(
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dcargs.extras.set_accent_color("bright_yellow")
|
||||
dcargs.cli(main)
|
||||
tyro.extras.set_accent_color("bright_yellow")
|
||||
tyro.cli(main)
|
||||
Reference in new issue
Block a user