We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Relative data paths result in hidden output directories
Running `ns-train` with a relative path to the data results in an output directory that is hidden because the experiment name includes components of the relative path. For example, running: `ns-train nerfacto --data ../nerf_datasets/tum_fr1desk` results in an output directory `outputs/..-nerf_datasets-tum-fr1desk`.

**To Reproduce**
Steps to reproduce the behavior:
1. Run `ns-train nerfacto --data ../[path to data]`

**Expected behavior**
The expected behavior should probably be to remove any `"../"` from the data path when generating the experiment name.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nerfstudio/configs/base_config.py`
Content:
```
1 # Copyright 2022 The Nerfstudio Team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 """Base Configs"""
16 
17 # pylint: disable=wrong-import-position
18 
19 from __future__ import annotations
20 
21 from dataclasses import dataclass
22 from datetime import datetime
23 from pathlib import Path
24 from typing import Any, Dict, List, Optional, Tuple, Type
25 
26 import yaml
27 from rich.console import Console
28 from typing_extensions import Literal
29 
30 from nerfstudio.configs.config_utils import to_immutable_dict
31 
32 # model instances
33 from nerfstudio.utils import writer
34 
35 CONSOLE = Console(width=120)
36 
37 # Pretty printing class
38 class PrintableConfig:  # pylint: disable=too-few-public-methods
39     """Printable Config defining str function"""
40 
41     def __str__(self):
42         lines = [self.__class__.__name__ + ":"]
43         for key, val in vars(self).items():
44             if isinstance(val, Tuple):
45                 flattened_val = "["
46                 for item in val:
47                     flattened_val += str(item) + "\n"
48                 flattened_val = flattened_val.rstrip("\n")
49                 val = flattened_val + "]"
50             lines += f"{key}: {str(val)}".split("\n")
51         return "\n    ".join(lines)
52 
53 
54 # Base instantiate configs
55 @dataclass
56 class InstantiateConfig(PrintableConfig):  # pylint: disable=too-few-public-methods
57     """Config class for instantiating an the class specified in the _target attribute."""
58 
59     _target: Type
60 
61     def setup(self, **kwargs) -> Any:
62         """Returns the instantiated object using the config."""
63         return self._target(self, **kwargs)
64 
65 
66 # Machine related configs
67 @dataclass
68 class MachineConfig(PrintableConfig):
69     """Configuration of machine setup"""
70 
71     seed: int = 42
72     """random seed initilization"""
73     num_gpus: int = 1
74     """total number of gpus available for train/eval"""
75     num_machines: int = 1
76     """total number of distributed machines available (for DDP)"""
77     machine_rank: int = 0
78     """current machine's rank (for DDP)"""
79     dist_url: str = "auto"
80     """distributed connection point (for DDP)"""
81 
82 
83 @dataclass
84 class LocalWriterConfig(InstantiateConfig):
85     """Local Writer config"""
86 
87     _target: Type = writer.LocalWriter
88     """target class to instantiate"""
89     enable: bool = False
90     """if True enables local logging, else disables"""
91     stats_to_track: Tuple[writer.EventName, ...] = (
92         writer.EventName.ITER_TRAIN_TIME,
93         writer.EventName.TRAIN_RAYS_PER_SEC,
94         writer.EventName.CURR_TEST_PSNR,
95         writer.EventName.VIS_RAYS_PER_SEC,
96         writer.EventName.TEST_RAYS_PER_SEC,
97     )
98     """specifies which stats will be logged/printed to terminal"""
99     max_log_size: int = 10
100     """maximum number of rows to print before wrapping. if 0, will print everything."""
101 
102     def setup(self, banner_messages: Optional[List[str]] = None, **kwargs) -> Any:
103         """Instantiate local writer
104 
105         Args:
106             banner_messages: List of strings that always print at the bottom of screen.
107         """
108         return self._target(self, banner_messages=banner_messages, **kwargs)
109 
110 
111 @dataclass
112 class LoggingConfig(PrintableConfig):
113     """Configuration of loggers and profilers"""
114 
115     relative_log_dir: Path = Path("./")
116     """relative path to save all logged events"""
117     steps_per_log: int = 10
118     """number of steps between logging stats"""
119     max_buffer_size: int = 20
120     """maximum history size to keep for computing running averages of stats.
121      e.g. if 20, averages will be computed over past 20 occurances."""
122     local_writer: LocalWriterConfig = LocalWriterConfig(enable=True)
123     """if provided, will print stats locally. if None, will disable printing"""
124     enable_profiler: bool = True
125     """whether to enable profiling code; prints speed of functions at the end of a program.
126     profiler logs run times of functions and prints at end of training"""
127 
128 
129 # Trainer related configs
130 @dataclass
131 class TrainerConfig(PrintableConfig):
132     """Configuration for training regimen"""
133 
134     steps_per_save: int = 1000
135     """Number of steps between saves."""
136     steps_per_eval_batch: int = 500
137     """Number of steps between randomly sampled batches of rays."""
138     steps_per_eval_image: int = 500
139     """Number of steps between single eval images."""
140     steps_per_eval_all_images: int = 25000
141     """Number of steps between eval all images."""
142     max_num_iterations: int = 1000000
143     """Maximum number of iterations to run."""
144     mixed_precision: bool = False
145     """Whether or not to use mixed precision for training."""
146     relative_model_dir: Path = Path("nerfstudio_models/")
147     """Relative path to save all checkpoints."""
148     save_only_latest_checkpoint: bool = True
149     """Whether to only save the latest checkpoint or all checkpoints."""
150     # optional parameters if we want to resume training
151     load_dir: Optional[Path] = None
152     """Optionally specify a pre-trained model directory to load from."""
153     load_step: Optional[int] = None
154     """Optionally specify model step to load from; if none, will find most recent model in load_dir."""
155     load_config: Optional[Path] = None
156 
157 
158 # Viewer related configs
159 @dataclass
160 class ViewerConfig(PrintableConfig):
161     """Configuration for viewer instantiation"""
162 
163     relative_log_filename: str = "viewer_log_filename.txt"
164     """Filename to use for the log file."""
165     start_train: bool = True
166     """whether to immediately start training upon loading viewer
167     if False, will just visualize dataset but you can toggle training in viewer"""
168     zmq_port: Optional[int] = None
169     """The zmq port to connect to for communication. If None, find an available port."""
170     launch_bridge_server: bool = True
171     """whether or not to launch the bridge server"""
172     websocket_port: Optional[int] = 7007
173     """the default websocket port to connect to"""
174     ip_address: str = "127.0.0.1"
175     """the ip address where the bridge server is running"""
176     num_rays_per_chunk: int = 32768
177     """number of rays per chunk to render with viewer"""
178     max_num_display_images: int = 512
179     """Maximum number of training images to display in the viewer, to avoid lag. This does not change which images are
180     actually used in training/evaluation. If -1, display all."""
181 
182 
183 from nerfstudio.engine.optimizers import OptimizerConfig
184 from nerfstudio.engine.schedulers import SchedulerConfig
185 from nerfstudio.pipelines.base_pipeline import VanillaPipelineConfig
186 
187 
188 @dataclass
189 class Config(PrintableConfig):
190     """Full config contents"""
191 
192     output_dir: Path = Path("outputs")
193     """relative or absolute output directory to save all checkpoints and logging"""
194     method_name: Optional[str] = None
195     """Method name. Required to set in python or via cli"""
196     experiment_name: Optional[str] = None
197     """Experiment name. If None, will automatically be set to dataset name"""
198     timestamp: str = "{timestamp}"
199     """Experiment timestamp."""
200     machine: MachineConfig = MachineConfig()
201     """Machine configuration"""
202     logging: LoggingConfig = LoggingConfig()
203     """Logging configuration"""
204     viewer: ViewerConfig = ViewerConfig()
205     """Viewer configuration"""
206     trainer: TrainerConfig = TrainerConfig()
207     """Trainer configuration"""
208     pipeline: VanillaPipelineConfig = VanillaPipelineConfig()
209     """Pipeline configuration"""
210     optimizers: Dict[str, Any] = to_immutable_dict(
211         {
212             "fields": {
213                 "optimizer": OptimizerConfig(),
214                 "scheduler": SchedulerConfig(),
215             }
216         }
217     )
218     """Dictionary of optimizer groups and their schedulers"""
219     vis: Literal["viewer", "wandb", "tensorboard"] = "wandb"
220     """Which visualizer to use."""
221     data: Optional[Path] = None
222     """Alias for --pipeline.datamanager.dataparser.data"""
223 
224     def is_viewer_enabled(self) -> bool:
225         """Checks if a viewer is enabled."""
226         return "viewer" == self.vis
227 
228     def is_wandb_enabled(self) -> bool:
229         """Checks if wandb is enabled."""
230         return "wandb" == self.vis
231 
232     def is_tensorboard_enabled(self) -> bool:
233         """Checks if tensorboard is enabled."""
234         return "tensorboard" == self.vis
235 
236     def set_timestamp(self) -> None:
237         """Dynamically set the experiment timestamp"""
238         if self.timestamp == "{timestamp}":
239             self.timestamp = datetime.now().strftime("%Y-%m-%d_%H%M%S")
240 
241     def set_experiment_name(self) -> None:
242         """Dynamically set the experiment name"""
243         if self.experiment_name is None:
244             self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace("/", "-")
245 
246     def get_base_dir(self) -> Path:
247         """Retrieve the base directory to set relative paths"""
248         # check the experiment and method names
249         assert self.method_name is not None, "Please set method name in config or via the cli"
250         self.set_experiment_name()
251         return Path(f"{self.output_dir}/{self.experiment_name}/{self.method_name}/{self.timestamp}")
252 
253     def get_checkpoint_dir(self) -> Path:
254         """Retrieve the checkpoint directory"""
255         return Path(self.get_base_dir() / self.trainer.relative_model_dir)
256 
257     def print_to_terminal(self) -> None:
258         """Helper to pretty print config to terminal"""
259         CONSOLE.rule("Config")
260         CONSOLE.print(self)
261         CONSOLE.rule("")
262 
263     def save_config(self) -> None:
264         """Save config to base directory"""
265         base_dir = self.get_base_dir()
266         assert base_dir is not None
267         base_dir.mkdir(parents=True, exist_ok=True)
268         config_yaml_path = base_dir / "config.yml"
269         CONSOLE.log(f"Saving config to: {config_yaml_path}")
270         config_yaml_path.write_text(yaml.dump(self), "utf8")
271
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nerfstudio/configs/base_config.py b/nerfstudio/configs/base_config.py
--- a/nerfstudio/configs/base_config.py
+++ b/nerfstudio/configs/base_config.py
@@ -241,7 +241,7 @@
     def set_experiment_name(self) -> None:
         """Dynamically set the experiment name"""
         if self.experiment_name is None:
-            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace("/", "-")
+            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace("../", "").replace("/", "-")
 
     def get_base_dir(self) -> Path:
         """Retrieve the base directory to set relative paths"""

{"golden_diff": "diff --git a/nerfstudio/configs/base_config.py b/nerfstudio/configs/base_config.py\n--- a/nerfstudio/configs/base_config.py\n+++ b/nerfstudio/configs/base_config.py\n@@ -241,7 +241,7 @@\n     def set_experiment_name(self) -> None:\n         \"\"\"Dynamically set the experiment name\"\"\"\n         if self.experiment_name is None:\n-            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace(\"/\", \"-\")\n+            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace(\"../\", \"\").replace(\"/\", \"-\")\n \n     def get_base_dir(self) -> Path:\n         \"\"\"Retrieve the base directory to set relative paths\"\"\"\n", "issue": "Relative data paths result in hidden output directories\nRunning `ns-train` with a relative path to the data results in an output directory that is hidden because the experiment name includes components of the relative path. For example, running: `ns-train nerfacto --data ../nerf_datasets/tum_fr1desk` results in an output directory `outputs/..-nerf_datasets-tum-fr1desk`.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Run `ns-train nerfacto --data ../[path to data]`\r\n\r\n**Expected behavior**\r\nThe expected behavior should probably be to remove any `\"../\"` from the data path when generating the experiment name.\r\n\n", "before_files": [{"content": "# Copyright 2022 The Nerfstudio Team. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Base Configs\"\"\"\n\n# pylint: disable=wrong-import-position\n\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom datetime import datetime\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional, Tuple, Type\n\nimport yaml\nfrom rich.console import Console\nfrom typing_extensions import Literal\n\nfrom nerfstudio.configs.config_utils import to_immutable_dict\n\n# model instances\nfrom nerfstudio.utils import writer\n\nCONSOLE = Console(width=120)\n\n# Pretty printing class\nclass PrintableConfig:  # pylint: disable=too-few-public-methods\n    \"\"\"Printable Config defining str function\"\"\"\n\n    def __str__(self):\n        lines = [self.__class__.__name__ + \":\"]\n        for key, val in vars(self).items():\n            if isinstance(val, Tuple):\n                flattened_val = \"[\"\n                for item in val:\n                    flattened_val += str(item) + \"\\n\"\n                flattened_val = flattened_val.rstrip(\"\\n\")\n                val = flattened_val + \"]\"\n            lines += f\"{key}: {str(val)}\".split(\"\\n\")\n        return \"\\n    \".join(lines)\n\n\n# Base instantiate configs\n@dataclass\nclass InstantiateConfig(PrintableConfig):  # pylint: disable=too-few-public-methods\n    \"\"\"Config class for instantiating an the class specified in the _target attribute.\"\"\"\n\n    _target: Type\n\n    def setup(self, **kwargs) -> Any:\n        \"\"\"Returns the instantiated object using the config.\"\"\"\n        return self._target(self, **kwargs)\n\n\n# Machine related configs\n@dataclass\nclass MachineConfig(PrintableConfig):\n    \"\"\"Configuration of machine setup\"\"\"\n\n    seed: int = 42\n    \"\"\"random seed initilization\"\"\"\n    num_gpus: int = 1\n    \"\"\"total number of gpus available for train/eval\"\"\"\n    num_machines: int = 1\n    \"\"\"total number of distributed machines available (for DDP)\"\"\"\n    machine_rank: int = 0\n    \"\"\"current machine's rank (for DDP)\"\"\"\n    dist_url: str = \"auto\"\n    \"\"\"distributed connection point (for DDP)\"\"\"\n\n\n@dataclass\nclass LocalWriterConfig(InstantiateConfig):\n    \"\"\"Local Writer config\"\"\"\n\n    _target: Type = writer.LocalWriter\n    \"\"\"target class to instantiate\"\"\"\n    enable: bool = False\n    \"\"\"if True enables local logging, else disables\"\"\"\n    stats_to_track: Tuple[writer.EventName, ...] = (\n        writer.EventName.ITER_TRAIN_TIME,\n        writer.EventName.TRAIN_RAYS_PER_SEC,\n        writer.EventName.CURR_TEST_PSNR,\n        writer.EventName.VIS_RAYS_PER_SEC,\n        writer.EventName.TEST_RAYS_PER_SEC,\n    )\n    \"\"\"specifies which stats will be logged/printed to terminal\"\"\"\n    max_log_size: int = 10\n    \"\"\"maximum number of rows to print before wrapping. if 0, will print everything.\"\"\"\n\n    def setup(self, banner_messages: Optional[List[str]] = None, **kwargs) -> Any:\n        \"\"\"Instantiate local writer\n\n        Args:\n            banner_messages: List of strings that always print at the bottom of screen.\n        \"\"\"\n        return self._target(self, banner_messages=banner_messages, **kwargs)\n\n\n@dataclass\nclass LoggingConfig(PrintableConfig):\n    \"\"\"Configuration of loggers and profilers\"\"\"\n\n    relative_log_dir: Path = Path(\"./\")\n    \"\"\"relative path to save all logged events\"\"\"\n    steps_per_log: int = 10\n    \"\"\"number of steps between logging stats\"\"\"\n    max_buffer_size: int = 20\n    \"\"\"maximum history size to keep for computing running averages of stats.\n     e.g. if 20, averages will be computed over past 20 occurances.\"\"\"\n    local_writer: LocalWriterConfig = LocalWriterConfig(enable=True)\n    \"\"\"if provided, will print stats locally. if None, will disable printing\"\"\"\n    enable_profiler: bool = True\n    \"\"\"whether to enable profiling code; prints speed of functions at the end of a program.\n    profiler logs run times of functions and prints at end of training\"\"\"\n\n\n# Trainer related configs\n@dataclass\nclass TrainerConfig(PrintableConfig):\n    \"\"\"Configuration for training regimen\"\"\"\n\n    steps_per_save: int = 1000\n    \"\"\"Number of steps between saves.\"\"\"\n    steps_per_eval_batch: int = 500\n    \"\"\"Number of steps between randomly sampled batches of rays.\"\"\"\n    steps_per_eval_image: int = 500\n    \"\"\"Number of steps between single eval images.\"\"\"\n    steps_per_eval_all_images: int = 25000\n    \"\"\"Number of steps between eval all images.\"\"\"\n    max_num_iterations: int = 1000000\n    \"\"\"Maximum number of iterations to run.\"\"\"\n    mixed_precision: bool = False\n    \"\"\"Whether or not to use mixed precision for training.\"\"\"\n    relative_model_dir: Path = Path(\"nerfstudio_models/\")\n    \"\"\"Relative path to save all checkpoints.\"\"\"\n    save_only_latest_checkpoint: bool = True\n    \"\"\"Whether to only save the latest checkpoint or all checkpoints.\"\"\"\n    # optional parameters if we want to resume training\n    load_dir: Optional[Path] = None\n    \"\"\"Optionally specify a pre-trained model directory to load from.\"\"\"\n    load_step: Optional[int] = None\n    \"\"\"Optionally specify model step to load from; if none, will find most recent model in load_dir.\"\"\"\n    load_config: Optional[Path] = None\n\n\n# Viewer related configs\n@dataclass\nclass ViewerConfig(PrintableConfig):\n    \"\"\"Configuration for viewer instantiation\"\"\"\n\n    relative_log_filename: str = \"viewer_log_filename.txt\"\n    \"\"\"Filename to use for the log file.\"\"\"\n    start_train: bool = True\n    \"\"\"whether to immediately start training upon loading viewer\n    if False, will just visualize dataset but you can toggle training in viewer\"\"\"\n    zmq_port: Optional[int] = None\n    \"\"\"The zmq port to connect to for communication. If None, find an available port.\"\"\"\n    launch_bridge_server: bool = True\n    \"\"\"whether or not to launch the bridge server\"\"\"\n    websocket_port: Optional[int] = 7007\n    \"\"\"the default websocket port to connect to\"\"\"\n    ip_address: str = \"127.0.0.1\"\n    \"\"\"the ip address where the bridge server is running\"\"\"\n    num_rays_per_chunk: int = 32768\n    \"\"\"number of rays per chunk to render with viewer\"\"\"\n    max_num_display_images: int = 512\n    \"\"\"Maximum number of training images to display in the viewer, to avoid lag. This does not change which images are\n    actually used in training/evaluation. If -1, display all.\"\"\"\n\n\nfrom nerfstudio.engine.optimizers import OptimizerConfig\nfrom nerfstudio.engine.schedulers import SchedulerConfig\nfrom nerfstudio.pipelines.base_pipeline import VanillaPipelineConfig\n\n\n@dataclass\nclass Config(PrintableConfig):\n    \"\"\"Full config contents\"\"\"\n\n    output_dir: Path = Path(\"outputs\")\n    \"\"\"relative or absolute output directory to save all checkpoints and logging\"\"\"\n    method_name: Optional[str] = None\n    \"\"\"Method name. Required to set in python or via cli\"\"\"\n    experiment_name: Optional[str] = None\n    \"\"\"Experiment name. If None, will automatically be set to dataset name\"\"\"\n    timestamp: str = \"{timestamp}\"\n    \"\"\"Experiment timestamp.\"\"\"\n    machine: MachineConfig = MachineConfig()\n    \"\"\"Machine configuration\"\"\"\n    logging: LoggingConfig = LoggingConfig()\n    \"\"\"Logging configuration\"\"\"\n    viewer: ViewerConfig = ViewerConfig()\n    \"\"\"Viewer configuration\"\"\"\n    trainer: TrainerConfig = TrainerConfig()\n    \"\"\"Trainer configuration\"\"\"\n    pipeline: VanillaPipelineConfig = VanillaPipelineConfig()\n    \"\"\"Pipeline configuration\"\"\"\n    optimizers: Dict[str, Any] = to_immutable_dict(\n        {\n            \"fields\": {\n                \"optimizer\": OptimizerConfig(),\n                \"scheduler\": SchedulerConfig(),\n            }\n        }\n    )\n    \"\"\"Dictionary of optimizer groups and their schedulers\"\"\"\n    vis: Literal[\"viewer\", \"wandb\", \"tensorboard\"] = \"wandb\"\n    \"\"\"Which visualizer to use.\"\"\"\n    data: Optional[Path] = None\n    \"\"\"Alias for --pipeline.datamanager.dataparser.data\"\"\"\n\n    def is_viewer_enabled(self) -> bool:\n        \"\"\"Checks if a viewer is enabled.\"\"\"\n        return \"viewer\" == self.vis\n\n    def is_wandb_enabled(self) -> bool:\n        \"\"\"Checks if wandb is enabled.\"\"\"\n        return \"wandb\" == self.vis\n\n    def is_tensorboard_enabled(self) -> bool:\n        \"\"\"Checks if tensorboard is enabled.\"\"\"\n        return \"tensorboard\" == self.vis\n\n    def set_timestamp(self) -> None:\n        \"\"\"Dynamically set the experiment timestamp\"\"\"\n        if self.timestamp == \"{timestamp}\":\n            self.timestamp = datetime.now().strftime(\"%Y-%m-%d_%H%M%S\")\n\n    def set_experiment_name(self) -> None:\n        \"\"\"Dynamically set the experiment name\"\"\"\n        if self.experiment_name is None:\n            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace(\"/\", \"-\")\n\n    def get_base_dir(self) -> Path:\n        \"\"\"Retrieve the base directory to set relative paths\"\"\"\n        # check the experiment and method names\n        assert self.method_name is not None, \"Please set method name in config or via the cli\"\n        self.set_experiment_name()\n        return Path(f\"{self.output_dir}/{self.experiment_name}/{self.method_name}/{self.timestamp}\")\n\n    def get_checkpoint_dir(self) -> Path:\n        \"\"\"Retrieve the checkpoint directory\"\"\"\n        return Path(self.get_base_dir() / self.trainer.relative_model_dir)\n\n    def print_to_terminal(self) -> None:\n        \"\"\"Helper to pretty print config to terminal\"\"\"\n        CONSOLE.rule(\"Config\")\n        CONSOLE.print(self)\n        CONSOLE.rule(\"\")\n\n    def save_config(self) -> None:\n        \"\"\"Save config to base directory\"\"\"\n        base_dir = self.get_base_dir()\n        assert base_dir is not None\n        base_dir.mkdir(parents=True, exist_ok=True)\n        config_yaml_path = base_dir / \"config.yml\"\n        CONSOLE.log(f\"Saving config to: {config_yaml_path}\")\n        config_yaml_path.write_text(yaml.dump(self), \"utf8\")\n", "path": "nerfstudio/configs/base_config.py"}], "after_files": [{"content": "# Copyright 2022 The Nerfstudio Team. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Base Configs\"\"\"\n\n# pylint: disable=wrong-import-position\n\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom datetime import datetime\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional, Tuple, Type\n\nimport yaml\nfrom rich.console import Console\nfrom typing_extensions import Literal\n\nfrom nerfstudio.configs.config_utils import to_immutable_dict\n\n# model instances\nfrom nerfstudio.utils import writer\n\nCONSOLE = Console(width=120)\n\n# Pretty printing class\nclass PrintableConfig:  # pylint: disable=too-few-public-methods\n    \"\"\"Printable Config defining str function\"\"\"\n\n    def __str__(self):\n        lines = [self.__class__.__name__ + \":\"]\n        for key, val in vars(self).items():\n            if isinstance(val, Tuple):\n                flattened_val = \"[\"\n                for item in val:\n                    flattened_val += str(item) + \"\\n\"\n                flattened_val = flattened_val.rstrip(\"\\n\")\n                val = flattened_val + \"]\"\n            lines += f\"{key}: {str(val)}\".split(\"\\n\")\n        return \"\\n    \".join(lines)\n\n\n# Base instantiate configs\n@dataclass\nclass InstantiateConfig(PrintableConfig):  # pylint: disable=too-few-public-methods\n    \"\"\"Config class for instantiating an the class specified in the _target attribute.\"\"\"\n\n    _target: Type\n\n    def setup(self, **kwargs) -> Any:\n        \"\"\"Returns the instantiated object using the config.\"\"\"\n        return self._target(self, **kwargs)\n\n\n# Machine related configs\n@dataclass\nclass MachineConfig(PrintableConfig):\n    \"\"\"Configuration of machine setup\"\"\"\n\n    seed: int = 42\n    \"\"\"random seed initilization\"\"\"\n    num_gpus: int = 1\n    \"\"\"total number of gpus available for train/eval\"\"\"\n    num_machines: int = 1\n    \"\"\"total number of distributed machines available (for DDP)\"\"\"\n    machine_rank: int = 0\n    \"\"\"current machine's rank (for DDP)\"\"\"\n    dist_url: str = \"auto\"\n    \"\"\"distributed connection point (for DDP)\"\"\"\n\n\n@dataclass\nclass LocalWriterConfig(InstantiateConfig):\n    \"\"\"Local Writer config\"\"\"\n\n    _target: Type = writer.LocalWriter\n    \"\"\"target class to instantiate\"\"\"\n    enable: bool = False\n    \"\"\"if True enables local logging, else disables\"\"\"\n    stats_to_track: Tuple[writer.EventName, ...] = (\n        writer.EventName.ITER_TRAIN_TIME,\n        writer.EventName.TRAIN_RAYS_PER_SEC,\n        writer.EventName.CURR_TEST_PSNR,\n        writer.EventName.VIS_RAYS_PER_SEC,\n        writer.EventName.TEST_RAYS_PER_SEC,\n    )\n    \"\"\"specifies which stats will be logged/printed to terminal\"\"\"\n    max_log_size: int = 10\n    \"\"\"maximum number of rows to print before wrapping. if 0, will print everything.\"\"\"\n\n    def setup(self, banner_messages: Optional[List[str]] = None, **kwargs) -> Any:\n        \"\"\"Instantiate local writer\n\n        Args:\n            banner_messages: List of strings that always print at the bottom of screen.\n        \"\"\"\n        return self._target(self, banner_messages=banner_messages, **kwargs)\n\n\n@dataclass\nclass LoggingConfig(PrintableConfig):\n    \"\"\"Configuration of loggers and profilers\"\"\"\n\n    relative_log_dir: Path = Path(\"./\")\n    \"\"\"relative path to save all logged events\"\"\"\n    steps_per_log: int = 10\n    \"\"\"number of steps between logging stats\"\"\"\n    max_buffer_size: int = 20\n    \"\"\"maximum history size to keep for computing running averages of stats.\n     e.g. if 20, averages will be computed over past 20 occurances.\"\"\"\n    local_writer: LocalWriterConfig = LocalWriterConfig(enable=True)\n    \"\"\"if provided, will print stats locally. if None, will disable printing\"\"\"\n    enable_profiler: bool = True\n    \"\"\"whether to enable profiling code; prints speed of functions at the end of a program.\n    profiler logs run times of functions and prints at end of training\"\"\"\n\n\n# Trainer related configs\n@dataclass\nclass TrainerConfig(PrintableConfig):\n    \"\"\"Configuration for training regimen\"\"\"\n\n    steps_per_save: int = 1000\n    \"\"\"Number of steps between saves.\"\"\"\n    steps_per_eval_batch: int = 500\n    \"\"\"Number of steps between randomly sampled batches of rays.\"\"\"\n    steps_per_eval_image: int = 500\n    \"\"\"Number of steps between single eval images.\"\"\"\n    steps_per_eval_all_images: int = 25000\n    \"\"\"Number of steps between eval all images.\"\"\"\n    max_num_iterations: int = 1000000\n    \"\"\"Maximum number of iterations to run.\"\"\"\n    mixed_precision: bool = False\n    \"\"\"Whether or not to use mixed precision for training.\"\"\"\n    relative_model_dir: Path = Path(\"nerfstudio_models/\")\n    \"\"\"Relative path to save all checkpoints.\"\"\"\n    save_only_latest_checkpoint: bool = True\n    \"\"\"Whether to only save the latest checkpoint or all checkpoints.\"\"\"\n    # optional parameters if we want to resume training\n    load_dir: Optional[Path] = None\n    \"\"\"Optionally specify a pre-trained model directory to load from.\"\"\"\n    load_step: Optional[int] = None\n    \"\"\"Optionally specify model step to load from; if none, will find most recent model in load_dir.\"\"\"\n    load_config: Optional[Path] = None\n\n\n# Viewer related configs\n@dataclass\nclass ViewerConfig(PrintableConfig):\n    \"\"\"Configuration for viewer instantiation\"\"\"\n\n    relative_log_filename: str = \"viewer_log_filename.txt\"\n    \"\"\"Filename to use for the log file.\"\"\"\n    start_train: bool = True\n    \"\"\"whether to immediately start training upon loading viewer\n    if False, will just visualize dataset but you can toggle training in viewer\"\"\"\n    zmq_port: Optional[int] = None\n    \"\"\"The zmq port to connect to for communication. If None, find an available port.\"\"\"\n    launch_bridge_server: bool = True\n    \"\"\"whether or not to launch the bridge server\"\"\"\n    websocket_port: Optional[int] = 7007\n    \"\"\"the default websocket port to connect to\"\"\"\n    ip_address: str = \"127.0.0.1\"\n    \"\"\"the ip address where the bridge server is running\"\"\"\n    num_rays_per_chunk: int = 32768\n    \"\"\"number of rays per chunk to render with viewer\"\"\"\n    max_num_display_images: int = 512\n    \"\"\"Maximum number of training images to display in the viewer, to avoid lag. This does not change which images are\n    actually used in training/evaluation. If -1, display all.\"\"\"\n\n\nfrom nerfstudio.engine.optimizers import OptimizerConfig\nfrom nerfstudio.engine.schedulers import SchedulerConfig\nfrom nerfstudio.pipelines.base_pipeline import VanillaPipelineConfig\n\n\n@dataclass\nclass Config(PrintableConfig):\n    \"\"\"Full config contents\"\"\"\n\n    output_dir: Path = Path(\"outputs\")\n    \"\"\"relative or absolute output directory to save all checkpoints and logging\"\"\"\n    method_name: Optional[str] = None\n    \"\"\"Method name. Required to set in python or via cli\"\"\"\n    experiment_name: Optional[str] = None\n    \"\"\"Experiment name. If None, will automatically be set to dataset name\"\"\"\n    timestamp: str = \"{timestamp}\"\n    \"\"\"Experiment timestamp.\"\"\"\n    machine: MachineConfig = MachineConfig()\n    \"\"\"Machine configuration\"\"\"\n    logging: LoggingConfig = LoggingConfig()\n    \"\"\"Logging configuration\"\"\"\n    viewer: ViewerConfig = ViewerConfig()\n    \"\"\"Viewer configuration\"\"\"\n    trainer: TrainerConfig = TrainerConfig()\n    \"\"\"Trainer configuration\"\"\"\n    pipeline: VanillaPipelineConfig = VanillaPipelineConfig()\n    \"\"\"Pipeline configuration\"\"\"\n    optimizers: Dict[str, Any] = to_immutable_dict(\n        {\n            \"fields\": {\n                \"optimizer\": OptimizerConfig(),\n                \"scheduler\": SchedulerConfig(),\n            }\n        }\n    )\n    \"\"\"Dictionary of optimizer groups and their schedulers\"\"\"\n    vis: Literal[\"viewer\", \"wandb\", \"tensorboard\"] = \"wandb\"\n    \"\"\"Which visualizer to use.\"\"\"\n    data: Optional[Path] = None\n    \"\"\"Alias for --pipeline.datamanager.dataparser.data\"\"\"\n\n    def is_viewer_enabled(self) -> bool:\n        \"\"\"Checks if a viewer is enabled.\"\"\"\n        return \"viewer\" == self.vis\n\n    def is_wandb_enabled(self) -> bool:\n        \"\"\"Checks if wandb is enabled.\"\"\"\n        return \"wandb\" == self.vis\n\n    def is_tensorboard_enabled(self) -> bool:\n        \"\"\"Checks if tensorboard is enabled.\"\"\"\n        return \"tensorboard\" == self.vis\n\n    def set_timestamp(self) -> None:\n        \"\"\"Dynamically set the experiment timestamp\"\"\"\n        if self.timestamp == \"{timestamp}\":\n            self.timestamp = datetime.now().strftime(\"%Y-%m-%d_%H%M%S\")\n\n    def set_experiment_name(self) -> None:\n        \"\"\"Dynamically set the experiment name\"\"\"\n        if self.experiment_name is None:\n            self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace(\"../\", \"\").replace(\"/\", \"-\")\n\n    def get_base_dir(self) -> Path:\n        \"\"\"Retrieve the base directory to set relative paths\"\"\"\n        # check the experiment and method names\n        assert self.method_name is not None, \"Please set method name in config or via the cli\"\n        self.set_experiment_name()\n        return Path(f\"{self.output_dir}/{self.experiment_name}/{self.method_name}/{self.timestamp}\")\n\n    def get_checkpoint_dir(self) -> Path:\n        \"\"\"Retrieve the checkpoint directory\"\"\"\n        return Path(self.get_base_dir() / self.trainer.relative_model_dir)\n\n    def print_to_terminal(self) -> None:\n        \"\"\"Helper to pretty print config to terminal\"\"\"\n        CONSOLE.rule(\"Config\")\n        CONSOLE.print(self)\n        CONSOLE.rule(\"\")\n\n    def save_config(self) -> None:\n        \"\"\"Save config to base directory\"\"\"\n        base_dir = self.get_base_dir()\n        assert base_dir is not None\n        base_dir.mkdir(parents=True, exist_ok=True)\n        config_yaml_path = base_dir / \"config.yml\"\n        CONSOLE.log(f\"Saving config to: {config_yaml_path}\")\n        config_yaml_path.write_text(yaml.dump(self), \"utf8\")\n", "path": "nerfstudio/configs/base_config.py"}]}