Skip to content

Commit

Permalink
Merge pull request #562 from StanfordVL/fix/prune-logging
Browse files Browse the repository at this point in the history
Fix/prune logging
  • Loading branch information
cremebrule authored Jan 26, 2024
2 parents bafb734 + 2d81b6f commit 681ab24
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 62 deletions.
4 changes: 2 additions & 2 deletions omnigibson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def cleanup(*args, **kwargs):
shutil.rmtree(tempdir)
except PermissionError:
log.info("Permission error when removing temp files. Ignoring")
from omnigibson.utils.ui_utils import suppress_omni_log
log.info(f"{'-' * 10} Shutting Down OmniGibson {'-' * 10}")
from omnigibson.simulator import logo_small
log.info(f"{'-' * 10} Shutting Down {logo_small()} {'-' * 10}")

def shutdown(due_to_signal=False):
if app is not None:
Expand Down
13 changes: 8 additions & 5 deletions omnigibson/objects/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,14 @@ def _post_load(self):
# If the object is fixed_base but kinematic only is false, create the joint
if self.fixed_base and not self.kinematic_only:
# Create fixed joint, and set Body0 to be this object's root prim
create_joint(
prim_path=f"{self._prim_path}/rootJoint",
joint_type="FixedJoint",
body1=f"{self._prim_path}/{self._root_link_name}",
)
# This renders, which causes a material lookup error since we're creating a temp file, so we suppress
# the error explicitly here
with suppress_omni_log(channels=["omni.hydra"]):
create_joint(
prim_path=f"{self._prim_path}/rootJoint",
joint_type="FixedJoint",
body1=f"{self._prim_path}/{self._root_link_name}",
)

# Set visibility
if "visible" in self._load_config and self._load_config["visible"] is not None:
Expand Down
4 changes: 2 additions & 2 deletions omnigibson/prims/entity_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _initialize(self):
super()._initialize()

# Force populate inputs and outputs of the shaders of all materials
# We suppress errors from omni.hydra if we're using encrypted assets, because we're loading from tmp location,
# We suppress errors from omni.usd if we're using encrypted assets, because we're loading from tmp location,
# not the original location
with suppress_omni_log(channels=["omni.hydra"]):
with suppress_omni_log(channels=["omni.usd"]):
for material in self.materials:
material.shader_force_populate(render=False)

Expand Down
65 changes: 18 additions & 47 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import os
import socket
from pathlib import Path
from termcolor import colored
import atexit
import signal
from contextlib import nullcontext

import numpy as np
import json
Expand All @@ -20,7 +20,8 @@
from omnigibson.utils.python_utils import clear as clear_pu, create_object_from_init_info, Serializable
from omnigibson.utils.sim_utils import meets_minimum_isaac_version
from omnigibson.utils.usd_utils import clear as clear_uu, BoundingBoxAPI, FlatcacheAPI, RigidContactAPI
from omnigibson.utils.ui_utils import CameraMover, disclaimer, create_module_logger, suppress_omni_log
from omnigibson.utils.ui_utils import (CameraMover, disclaimer, create_module_logger, suppress_omni_log,
print_icon, print_logo, logo_small)
from omnigibson.scenes import Scene
from omnigibson.objects.object_base import BaseObject
from omnigibson.objects.stateful_object import StatefulObject
Expand All @@ -45,50 +46,6 @@ def print_save_usd_warning(_):
log.warning("Exporting individual USDs has been disabled in OG due to copyrights.")


def print_icon():
raw_texts = [
# Lgrey, grey, lgrey, grey, red, lgrey, red
(" ___________", "", "", "", "", "", "_"),
(" / ", "", "", "", "", "", "/ \\"),
(" / ", "", "", "", "/ /", "__", ""),
(" / ", "", "", "", "", "", "/ / /\\"),
(" /", "__________", "", "", "/ /", "__", "/ \\"),
(" ", "\\ _____ ", "", "", "\\ \\", "__", "\\ /"),
(" ", "\\ \\ ", "/ ", "\\ ", "", "", "\\ \\_/ /"),
(" ", "\\ \\", "/", "___\\ ", "", "", "\\ /"),
(" ", "\\__________", "", "", "", "", "\\_/ "),
]
for (lgrey_text0, grey_text0, lgrey_text1, grey_text1, red_text0, lgrey_text2, red_text1) in raw_texts:
lgrey_text0 = colored(lgrey_text0, "light_grey", attrs=["bold"])
grey_text0 = colored(grey_text0, "light_grey", attrs=["bold", "dark"])
lgrey_text1 = colored(lgrey_text1, "light_grey", attrs=["bold"])
grey_text1 = colored(grey_text1, "light_grey", attrs=["bold", "dark"])
red_text0 = colored(red_text0, "light_red", attrs=["bold"])
lgrey_text2 = colored(lgrey_text2, "light_grey", attrs=["bold"])
red_text1 = colored(red_text1, "light_red", attrs=["bold"])
print(lgrey_text0 + grey_text0 + lgrey_text1 + grey_text1 + red_text0 + lgrey_text2 + red_text1)


def print_logo():
raw_texts = [
(" ___ _", " ____ _ _ "),
(" / _ \ _ __ ___ _ __ (_)", "/ ___(_) |__ ___ ___ _ __ "),
(" | | | | '_ ` _ \| '_ \| |", " | _| | '_ \/ __|/ _ \| '_ \ "),
(" | |_| | | | | | | | | | |", " |_| | | |_) \__ \ (_) | | | |"),
(" \___/|_| |_| |_|_| |_|_|", "\____|_|_.__/|___/\___/|_| |_|"),
]
for (grey_text, red_text) in raw_texts:
grey_text = colored(grey_text, "light_grey", attrs=["bold", "dark"])
red_text = colored(red_text, "light_red", attrs=["bold"])
print(grey_text + red_text)


def logo_small():
grey_text = colored("Omni", "light_grey", attrs=["bold", "dark"])
red_text = colored("Gibson", "light_red", attrs=["bold"])
return grey_text + red_text


def _launch_app():
log.info(f"{'-' * 5} Starting {logo_small()}. This will take 10-30 seconds... {'-' * 5}")

Expand All @@ -99,7 +56,21 @@ def _launch_app():
if gpu_id is not None:
config_kwargs["active_gpu"] = gpu_id
config_kwargs["physics_gpu"] = gpu_id
app = lazy.omni.isaac.kit.SimulationApp(config_kwargs)

# Omni's logging is super annoying and overly verbose, so suppress it by modifying the logging levels
if not gm.DEBUG:
import sys
from numba.core.errors import NumbaPerformanceWarning
import warnings
# TODO: Find a more elegant way to prune omni logging
# sys.argv.append("--/log/level=warning")
# sys.argv.append("--/log/fileLogLevel=warning")
# sys.argv.append("--/log/outputStreamLevel=error")
warnings.simplefilter("ignore", category=NumbaPerformanceWarning)

launch_context = nullcontext if gm.DEBUG else suppress_omni_log
with launch_context(None):
app = lazy.omni.isaac.kit.SimulationApp(config_kwargs)

# Omni overrides the global logger to be DEBUG, which is very annoying, so we re-override it to the default WARN
# TODO: Remove this once omniverse fixes it
Expand Down
52 changes: 46 additions & 6 deletions omnigibson/utils/ui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,63 @@
import datetime
from pathlib import Path
from PIL import Image
from termcolor import colored
import omnigibson as og
from omnigibson.macros import gm
import omnigibson.utils.transform_utils as T
import omnigibson.lazy as lazy
from scipy.spatial.transform import Rotation as R
from scipy.interpolate import CubicSpline
from scipy.integrate import quad

# Attempt to import omni, it may not always be necessary here (e.g: when we download datasets) so we catch the import failure explicitly
try:
import omnigibson.lazy as lazy
except ModuleNotFoundError:
print("Could not find omni or carb, skipping import")
import random
import imageio
from IPython import embed


def print_icon():
raw_texts = [
# Lgrey, grey, lgrey, grey, red, lgrey, red
(" ___________", "", "", "", "", "", "_"),
(" / ", "", "", "", "", "", "/ \\"),
(" / ", "", "", "", "/ /", "__", ""),
(" / ", "", "", "", "", "", "/ / /\\"),
(" /", "__________", "", "", "/ /", "__", "/ \\"),
(" ", "\\ _____ ", "", "", "\\ \\", "__", "\\ /"),
(" ", "\\ \\ ", "/ ", "\\ ", "", "", "\\ \\_/ /"),
(" ", "\\ \\", "/", "___\\ ", "", "", "\\ /"),
(" ", "\\__________", "", "", "", "", "\\_/ "),
]
for (lgrey_text0, grey_text0, lgrey_text1, grey_text1, red_text0, lgrey_text2, red_text1) in raw_texts:
lgrey_text0 = colored(lgrey_text0, "light_grey", attrs=["bold"])
grey_text0 = colored(grey_text0, "light_grey", attrs=["bold", "dark"])
lgrey_text1 = colored(lgrey_text1, "light_grey", attrs=["bold"])
grey_text1 = colored(grey_text1, "light_grey", attrs=["bold", "dark"])
red_text0 = colored(red_text0, "light_red", attrs=["bold"])
lgrey_text2 = colored(lgrey_text2, "light_grey", attrs=["bold"])
red_text1 = colored(red_text1, "light_red", attrs=["bold"])
print(lgrey_text0 + grey_text0 + lgrey_text1 + grey_text1 + red_text0 + lgrey_text2 + red_text1)


def print_logo():
raw_texts = [
(" ___ _", " ____ _ _ "),
(" / _ \ _ __ ___ _ __ (_)", "/ ___(_) |__ ___ ___ _ __ "),
(" | | | | '_ ` _ \| '_ \| |", " | _| | '_ \/ __|/ _ \| '_ \ "),
(" | |_| | | | | | | | | | |", " |_| | | |_) \__ \ (_) | | | |"),
(" \___/|_| |_| |_|_| |_|_|", "\____|_|_.__/|___/\___/|_| |_|"),
]
for (grey_text, red_text) in raw_texts:
grey_text = colored(grey_text, "light_grey", attrs=["bold", "dark"])
red_text = colored(red_text, "light_red", attrs=["bold"])
print(grey_text + red_text)


def logo_small():
grey_text = colored("Omni", "light_grey", attrs=["bold", "dark"])
red_text = colored("Gibson", "light_red", attrs=["bold"])
return grey_text + red_text


def dock_window(space, name, location, ratio=0.5):
"""
Method for docking a specific GUI window in a specified location within the workspace
Expand Down

0 comments on commit 681ab24

Please sign in to comment.