Rename: dcargs -> tyro (#702)

Rename `dcargs` to `tyro`
This commit is contained in:
Brent Yi authored and GitHub committed 2022-10-05 22:26:06 -07:00
1 parent ea591246cb
commit edbfccccfe
19 files changed
+68 -68

No files matched your search

+2 -2
View File
@@ -219,9 +219,9 @@ We provide the following support strucutures to make life easier for getting sta
# Built On
#### [dcargs](https://github.com/brentyi/dcargs)
#### [tyro](https://github.com/brentyi/tyro)
- Easy to use config system
- Easy-to-use config system
- Developed by [Brent Yi](https://brentyi.com/)
#### [nerfacc](https://www.nerfacc.com/en/latest/)
+2 -2
View File
@@ -1,7 +1,7 @@
# Customizable configs
Our python dataclass configs allow you to easily plug in different permutations of models, dataloaders, modules, etc.
and modify all parameters from a typed CLI supported by [dcargs](https://pypi.org/project/dcargs/).
Our dataclass configs allow you to easily plug in different permutations of models, dataloaders, modules, etc.
and modify all parameters from a typed CLI supported by [tyro](https://pypi.org/project/tyro/).
### Base components
+1 -1
View File
@@ -109,7 +109,7 @@ We'll be constantly growing this list! So make sure to check back in to see our
## Built On
[**dcargs**](https://github.com/brentyi/dcargs)
[**tyro**](https://github.com/brentyi/tyro)
- Easy to use config system
- Developed by [Brent Yi](https://brentyi.com/)
+4 -4
View File
@@ -20,7 +20,7 @@ from __future__ import annotations
from typing import Dict
import dcargs
import tyro
from nerfstudio.configs.base_config import Config, TrainerConfig, ViewerConfig
from nerfstudio.configs.config_utils import convert_markup_to_ansi
@@ -150,9 +150,9 @@ method_configs["vanilla-nerf"] = Config(
)
AnnotatedBaseConfigUnion = dcargs.conf.SuppressFixed[ # Don't show unparseable (fixed) arguments in helptext.
dcargs.extras.subcommand_type_from_defaults(defaults=method_configs, descriptions=descriptions)
AnnotatedBaseConfigUnion = tyro.conf.SuppressFixed[ # Don't show unparseable (fixed) arguments in helptext.
tyro.extras.subcommand_type_from_defaults(defaults=method_configs, descriptions=descriptions)
]
"""Union[] type over config types, annotated with default instances for use with
dcargs.cli(). Allows the user to pick between one of several base configurations, and
tyro.cli(). Allows the user to pick between one of several base configurations, and
then override values in it."""
+4 -4
View File
@@ -21,8 +21,8 @@ from abc import abstractmethod
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple, Type, Union
import dcargs
import torch
import tyro
from torch import nn
from torch.nn import Parameter
from torch.utils.data import Dataset
@@ -49,8 +49,8 @@ from nerfstudio.engine.callbacks import TrainingCallback, TrainingCallbackAttrib
from nerfstudio.model_components.ray_generators import RayGenerator
from nerfstudio.utils.misc import IterableWrapper
AnnotatedDataParserUnion = dcargs.conf.OmitSubcommandPrefixes[ # Omit prefixes of flags in subcommands.
dcargs.extras.subcommand_type_from_defaults(
AnnotatedDataParserUnion = tyro.conf.OmitSubcommandPrefixes[ # Omit prefixes of flags in subcommands.
tyro.extras.subcommand_type_from_defaults(
{
"nerfstudio-data": NerfstudioDataParserConfig(),
"blender-data": BlenderDataParserConfig(),
@@ -61,7 +61,7 @@ AnnotatedDataParserUnion = dcargs.conf.OmitSubcommandPrefixes[ # Omit prefixes
prefix_names=False, # Omit prefixes in subcommands themselves.
)
]
"""Union over possible dataparser types, annotated with metadata for dcargs. This is the
"""Union over possible dataparser types, annotated with metadata for tyro. This is the
same as the vanilla union, but results in shorter subcommand names."""
+2 -2
View File
@@ -1,2 +1,2 @@
dcargs>=0.2.6
sshconf==0.2.5
tyro>=0.3.22
sshconf==0.2.5
+3 -3
View File
@@ -23,7 +23,7 @@ from os.path import expanduser
from pathlib import Path
from typing import Optional
import dcargs
import tyro
from sshconf import empty_ssh_config_file, read_ssh_config
@@ -135,5 +135,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)
+3 -3
View File
@@ -17,13 +17,13 @@
import sys
from typing import List, Optional, Tuple
import dcargs
import msgpack
import msgpack_numpy
import tornado.gen
import tornado.ioloop
import tornado.web
import tornado.websocket
import tyro
import umsgpack
import zmq
import zmq.eventloop.ioloop
@@ -266,8 +266,8 @@ def run_viewer_bridge_server(zmq_port: int = 6000, websocket_port: int = 7007):
def main():
"""The main entrypoint."""
dcargs.extras.set_accent_color("bright_yellow")
dcargs.cli(run_viewer_bridge_server)
tyro.extras.set_accent_color("bright_yellow")
tyro.cli(run_viewer_bridge_server)
if __name__ == "__main__":
+1 -1
View File
@@ -18,7 +18,7 @@ dependencies = [
"aiortc==1.3.2",
"appdirs>=1.4",
"av==9.2.0",
"dcargs>=0.3.21",
"tyro>=0.3.22",
"gdown==4.5.1",
"ninja==1.10.2.3",
"functorch==0.2.1",
+14 -14
View File
@@ -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 -3
View File
@@ -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 -3
View File
@@ -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)
+5 -5
View File
@@ -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
View File
@@ -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 -3
View File
@@ -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__":
+4 -4
View File
@@ -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
View File
@@ -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
View File
@@ -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__":
+3 -3
View File
@@ -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)