Skip to content

Commit

Permalink
set HYDRA_FULL_ERROR (#1291)
Browse files Browse the repository at this point in the history
* set HYDRA_FULL_ERROR

* undo
  • Loading branch information
Louis-Dupont committed Jul 23, 2023
1 parent 8bfdedf commit cd39aee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/super_gradients/common/crash_handler/crash_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
from super_gradients.common.crash_handler.crash_tips_setup import setup_crash_tips
from super_gradients.common.crash_handler.exception_monitoring_setup import setup_pro_user_monitoring
from super_gradients.common.crash_handler.exception import register_exceptions
from super_gradients.common.environment.env_variables import env_variables


def setup_crash_handler():
"""Setup the environment to handle crashes, with crash tips and more."""
is_setup_crash_tips = setup_crash_tips()
is_setup_pro_user_monitoring = setup_pro_user_monitoring()
if is_setup_crash_tips or is_setup_pro_user_monitoring: # We don't want to wrap sys.excepthook when not required

# This prevents hydra.main to catch errors that happen in the decorated function
# (which leads sys.excepthook to never be called)
env_variables.HYDRA_FULL_ERROR = "1"

sys.excepthook = register_exceptions(sys.excepthook)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import logging
import atexit

Expand Down Expand Up @@ -37,10 +36,6 @@ def setup_pro_user_monitoring() -> bool:
"If you do not have a deci-platform-client credentials or you wish to disable this feature, please set the env variable UPLOAD_LOGS=FALSE"
)

# This prevents hydra.main to catch errors that happen in the decorated function
# (which leads sys.excepthook to never be called)
os.environ["HYDRA_FULL_ERROR"] = "1"

logger.info("Connecting to the deci platform ...")
platform_client = DeciClient()
logger.info("Connection to the deci platform successful!")
Expand Down
9 changes: 9 additions & 0 deletions src/super_gradients/common/environment/env_variables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Optional


class EnvironmentVariables:
Expand Down Expand Up @@ -36,5 +37,13 @@ def FILE_LOG_LEVEL(self) -> str:
def CONSOLE_LOG_LEVEL(self) -> str:
return os.getenv("CONSOLE_LOG_LEVEL", default="INFO").upper()

@property
def HYDRA_FULL_ERROR(self) -> Optional[str]:
return os.getenv("HYDRA_FULL_ERROR")

@HYDRA_FULL_ERROR.setter
def HYDRA_FULL_ERROR(self, value: str):
os.environ["HYDRA_FULL_ERROR"] = value


env_variables = EnvironmentVariables()

0 comments on commit cd39aee

Please sign in to comment.