Add viewer version function (#801)

version function

Co-authored-by: Matthew Tancik <tancik@berkeley.edu>
This commit is contained in:
Ethan WeberandMatthew Tancik authored and GitHub committed 2022-10-19 08:54:27 -07:00
1 parent 21eddc4b17
commit 7a8f29f623
1 file changed
+8 -2
+8 -2
View File
@@ -55,6 +55,13 @@ warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)
CONSOLE = Console(width=120) CONSOLE = Console(width=120)
def get_viewer_version() -> str:
"""Get the version of the viewer."""
json_filename = os.path.join(os.path.dirname(__file__), "../app/package.json")
version = load_from_json(Path(json_filename))["version"]
return version
@check_main_thread @check_main_thread
def setup_viewer(config: cfg.ViewerConfig, log_filename: Path): def setup_viewer(config: cfg.ViewerConfig, log_filename: Path):
"""Sets up the viewer if enabled """Sets up the viewer if enabled
@@ -230,8 +237,7 @@ class ViewerState:
) )
# TODO(ethan): log the output of the viewer bridge server in a file where the training logs go # TODO(ethan): log the output of the viewer bridge server in a file where the training logs go
CONSOLE.line() CONSOLE.line()
json_filename = os.path.join(os.path.dirname(__file__), "../app/package.json") version = get_viewer_version()
version = load_from_json(Path(json_filename))["version"]
websocket_url = f"ws://localhost:{self.config.websocket_port}" websocket_url = f"ws://localhost:{self.config.websocket_port}"
self.viewer_url = f"https://viewer.nerf.studio/versions/{version}/?websocket_url={websocket_url}" self.viewer_url = f"https://viewer.nerf.studio/versions/{version}/?websocket_url={websocket_url}"
CONSOLE.rule(characters="=") CONSOLE.rule(characters="=")