From de0ec8f2c57e5e807efa3699ab4fc0172ceec58a Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Thu, 18 Jan 2024 01:22:53 -0800 Subject: [PATCH 1/3] Use github output format for ruff in CI --- .github/workflows/core_code_checks.yml | 4 ++-- nerfstudio/scripts/github/run_actions.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/core_code_checks.yml b/.github/workflows/core_code_checks.yml index 0f1fcf0caf..23d6a1df19 100644 --- a/.github/workflows/core_code_checks.yml +++ b/.github/workflows/core_code_checks.yml @@ -33,9 +33,9 @@ jobs: run: | python ./nerfstudio/scripts/docs/add_nb_tags.py --check - name: Run Ruff Linter - run: ruff check docs/ nerfstudio/ tests/ + run: ruff check docs/ nerfstudio/ tests/ --output-format=github - name: Run Ruff Formatter - run: ruff format docs/ nerfstudio/ tests/ --check + run: ruff format docs/ nerfstudio/ tests/ --check --output-format=github - name: Run Pyright run: | pyright diff --git a/nerfstudio/scripts/github/run_actions.py b/nerfstudio/scripts/github/run_actions.py index 5a966338c1..71becd5cf4 100644 --- a/nerfstudio/scripts/github/run_actions.py +++ b/nerfstudio/scripts/github/run_actions.py @@ -56,11 +56,13 @@ def run_github_actions_file(filename: str, continue_on_fail: bool = False): for step in steps: if "name" in step and step["name"] in LOCAL_TESTS: - compressed = step["run"].replace("\n", ";").replace("\\", "") - if "ruff check" in compressed: - curr_command = f"{compressed} --fix" - else: - curr_command = compressed.replace("--check", "") + curr_command = step["run"].replace("\n", ";").replace("\\", "") + if curr_command.startswith("ruff"): + if "ruff check" in curr_command: + curr_command = f"{curr_command} --fix" + else: + curr_command = curr_command.replace("--check", "") + curr_command = curr_command.replace(" --output-format=github", "") CONSOLE.line() CONSOLE.rule(f"[bold green]Running: {curr_command}") From cb21fb97af5526b8005d554829c8bb0b21a8a84a Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Thu, 18 Jan 2024 12:09:17 -0800 Subject: [PATCH 2/3] Fix --- .github/workflows/core_code_checks.yml | 2 +- nerfstudio/scripts/github/run_actions.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/core_code_checks.yml b/.github/workflows/core_code_checks.yml index 23d6a1df19..556432bfc2 100644 --- a/.github/workflows/core_code_checks.yml +++ b/.github/workflows/core_code_checks.yml @@ -35,7 +35,7 @@ jobs: - name: Run Ruff Linter run: ruff check docs/ nerfstudio/ tests/ --output-format=github - name: Run Ruff Formatter - run: ruff format docs/ nerfstudio/ tests/ --check --output-format=github + run: ruff format docs/ nerfstudio/ tests/ --diff - name: Run Pyright run: | pyright diff --git a/nerfstudio/scripts/github/run_actions.py b/nerfstudio/scripts/github/run_actions.py index 71becd5cf4..c758d23b66 100644 --- a/nerfstudio/scripts/github/run_actions.py +++ b/nerfstudio/scripts/github/run_actions.py @@ -60,9 +60,10 @@ def run_github_actions_file(filename: str, continue_on_fail: bool = False): if curr_command.startswith("ruff"): if "ruff check" in curr_command: curr_command = f"{curr_command} --fix" - else: - curr_command = curr_command.replace("--check", "") - curr_command = curr_command.replace(" --output-format=github", "") + + curr_command = curr_command.replace(" --check", "") + curr_command = curr_command.replace(" --diff", "") + curr_command = curr_command.replace(" --output-format=github", "") CONSOLE.line() CONSOLE.rule(f"[bold green]Running: {curr_command}") From 2832b20627c56c2ec1b50878bb714c2557a0b2fa Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Fri, 19 Jan 2024 00:15:10 -0800 Subject: [PATCH 3/3] Hotfix non-colmap nerfstudio datasets --- .../data/dataparsers/nerfstudio_dataparser.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py index c13efbfe7a..b569508523 100644 --- a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py @@ -311,16 +311,20 @@ def _generate_dataparser_outputs(self, split="train"): # - transform_matrix contains the transformation to dataparser output coordinates from saved coordinates. # - dataparser_transform_matrix contains the transformation to dataparser output coordinates from original data coordinates. # - applied_transform contains the transformation to saved coordinates from original data coordinates. - if "applied_transform" not in meta: + applied_transform = None + colmap_path = self.config.data / "colmap/sparse/0" + if "applied_transform" not in meta and colmap_path.exists(): # For converting from colmap, this was the effective value of applied_transform that was being # used before we added the applied_transform field to the output dataformat. meta["applied_transform"] = [[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, -1, 0]] + applied_transform = torch.tensor(meta["applied_transform"], dtype=transform_matrix.dtype) - applied_transform = torch.tensor(meta["applied_transform"], dtype=transform_matrix.dtype) - - dataparser_transform_matrix = transform_matrix @ torch.cat( - [applied_transform, torch.tensor([[0, 0, 0, 1]], dtype=transform_matrix.dtype)], 0 - ) + if applied_transform is not None: + dataparser_transform_matrix = transform_matrix @ torch.cat( + [applied_transform, torch.tensor([[0, 0, 0, 1]], dtype=transform_matrix.dtype)], 0 + ) + else: + dataparser_transform_matrix = transform_matrix if "applied_scale" in meta: applied_scale = float(meta["applied_scale"]) @@ -337,8 +341,6 @@ def _generate_dataparser_outputs(self, split="train"): # Load 3D points if self.config.load_3D_points: - colmap_path = self.config.data / "colmap/sparse/0" - if "ply_file_path" in meta: ply_file_path = data_dir / meta["ply_file_path"]