4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00
nerfstudio/scripts/debugging/run_actions.py
Ethan Weber 55ebaaf1b5
Hosting the viewer & webrtc logging (#271)
* might fix the stun server issue

* still debugging webrtc

* another turn server

* working on github actions

* updating actions file

* fixing actions

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* ga

* updating viewer

* update docs
2022-08-14 00:15:34 -07:00

85 lines
2.8 KiB
Python

"""Simple yaml debugger"""
import subprocess
import sys
import dcargs
import yaml
LOCAL_TESTS = ["Run license checks", "Run isort", "Run Black", "Python Pylint", "Test with pytest"]
def run_command(command: str, continue_on_fail: bool = False) -> None:
"""Run a command kill actions if it fails
Args:
command: command to run
continue_on_fail: whether to continue running commands if the current one fails. Defaults to False.
"""
ret_code = subprocess.call(command, shell=True)
if not continue_on_fail and ret_code != 0:
print(f"\033[31mError: `{command}` failed. Exiting...\033[0m")
sys.exit(1)
return ret_code == 0
def run_github_actions_file(filename: str, continue_on_fail: bool = False):
"""Run a github actions file locally.
Args:
filename: Which yml github actions file to run.
continue_on_fail: Whether or not to continue running actions commands if the current one fails
"""
with open(filename, "rb") as f:
my_dict = yaml.safe_load(f)
steps = my_dict["jobs"]["build"]["steps"]
print_green = lambda x: print(f"\033[32m{x}\033[0m")
print_red = lambda x: print(f"\033[31m{x}\033[0m")
success = True
for step in steps:
if "name" in step and step["name"] in LOCAL_TESTS:
compressed = step["run"].replace("\n", ";").replace("\\", "")
compressed = compressed.replace("--check", "")
curr_command = f"{compressed}"
print("*" * 100)
print_green(f"Running: {curr_command}")
success = success and run_command(curr_command, continue_on_fail=continue_on_fail)
else:
print("*" * 100)
print(f"Skipping {step}")
# Add checks for building documentation
print_green("Adding notebook documentation metadata")
success = success and run_command("python scripts/docs/add_nb_tags.py")
print_green("Building Documentation")
success = success and run_command("cd docs/; make html SPHINXOPTS='-W;'")
if success:
print("\n")
print_green("=" * 100)
print_green("ALL CHECKS PASSED")
print_green("=" * 100)
else:
print("\n")
print_red("=" * 100)
print_red("ERRORS FOUND")
print_red("=" * 100)
def run_code_checks(continue_on_fail: bool = False):
"""Run a github actions file locally.
Args:
continue_on_fail: Whether or not to continue running actions commands if the current one fails
"""
# core code checks
run_github_actions_file(filename=".github/workflows/core_code_checks.yml", continue_on_fail=continue_on_fail)
# viewer build and deployment
# run_github_actions_file(filename=".github/workflows/viewer_build_deploy.yml", continue_on_fail=continue_on_fail)
if __name__ == "__main__":
dcargs.cli(run_code_checks)