Repository: nerfstudio-project/nerfstudio

Issue:
Minor arg improvements
Minor TODOs, I can do these in the next day or two:
- All of the fixed args can be suppressed via `dcargs.conf.SuppressFixed[]`, this will remove all of the unnecessary `_type` args from the usage + helptext
- Formatting in the base config descriptions, https://github.com/nerfstudio-project/nerfstudio/blob/5a76b955cdd833fd59b90edff33875fa05894847/nerfstudio/configs/model_configs.py#L46-L56, currently exploits a bug in `dcargs`, which will be patched in the next release. The tags will need to be manually converted to ANSI sequences in nerfstudio


Discussion:

Resolving patch:
diff --git a/nerfstudio/configs/config_utils.py b/nerfstudio/configs/config_utils.py
--- a/nerfstudio/configs/config_utils.py
+++ b/nerfstudio/configs/config_utils.py
@@ -21,6 +21,8 @@
 from dataclasses import field
 from typing import Any, Dict
 
+from rich.console import Console
+
 # pylint: disable=import-outside-toplevel
 
 # cannot use mutable types directly within dataclass; abstracting default factory calls
@@ -31,3 +33,18 @@ def to_immutable_dict(d: Dict[str, Any]):
         d: dictionary to convert into default factory dict for dataclass
     """
     return field(default_factory=lambda: dict(d))
+
+
+def convert_markup_to_ansi(markup_string: str) -> str:
+    """Convert rich-style markup to ANSI sequences for command-line formatting.
+
+    Args:
+        markup_string: Text with rich-style markup.
+
+    Returns:
+        Text formatted via ANSI sequences.
+    """
+    console = Console()
+    with console.capture() as out:
+        console.print(markup_string, soft_wrap=True)
+    return out.get()
diff --git a/nerfstudio/configs/method_configs.py b/nerfstudio/configs/method_configs.py
--- a/nerfstudio/configs/method_configs.py
+++ b/nerfstudio/configs/method_configs.py
@@ -21,8 +21,10 @@
 from typing import Dict
 
 import dcargs
+from rich.console import Console
 
 from nerfstudio.configs.base_config import Config, TrainerConfig, ViewerConfig
+from nerfstudio.configs.config_utils import convert_markup_to_ansi
 from nerfstudio.data.datamanagers import VanillaDataManagerConfig
 from nerfstudio.data.dataparsers.blender_dataparser import BlenderDataParserConfig
 from nerfstudio.data.dataparsers.friends_dataparser import FriendsDataParserConfig
@@ -46,6 +48,8 @@
     "semantic-nerfw": "Predicts semantic segmentations and filters out transient objects.",
     "vanilla-nerf": "Original NeRF model. [red]*slow*",
 }
+descriptions = {k: convert_markup_to_ansi(v) for k, v in descriptions.items()}
+
 
 method_configs["nerfacto"] = Config(
     method_name="nerfacto",
@@ -147,9 +151,9 @@
 )
 
 
-AnnotatedBaseConfigUnion = dcargs.extras.subcommand_type_from_defaults(
-    defaults=method_configs, descriptions=descriptions
-)
+AnnotatedBaseConfigUnion = dcargs.conf.SuppressFixed[  # Don't show unparseable (fixed) arguments in helptext.
+    dcargs.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
 then override values in it."""


Test patch: