Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#661 documentation on using configuration files

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-608_configuration_files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  1. import os
  2. import logging
  3. import atexit
  4. from super_gradients.common.environment.env_variables import env_variables
  5. from super_gradients.common.environment.ddp_utils import multi_process_safe, is_distributed
  6. from super_gradients.common.crash_handler.exception import ExceptionInfo
  7. from super_gradients.common.auto_logging.console_logging import ConsoleSink
  8. from super_gradients.common.plugins.deci_client import DeciClient, client_enabled
  9. logger = logging.getLogger(__name__)
  10. logger.setLevel(logging.INFO)
  11. @multi_process_safe
  12. def exception_upload_handler(platform_client):
  13. """Upload the log file to the deci platform if an error was raised"""
  14. # Make sure that the sink is flushed
  15. ConsoleSink.flush()
  16. if not is_distributed() and ExceptionInfo.is_exception_raised():
  17. logger.info("Uploading console log to deci platform ...")
  18. try:
  19. platform_client.upload_file_to_s3(tag="SuperGradients", level="error", from_path=ConsoleSink.get_filename())
  20. logger.info("Exception was uploaded to deci platform!")
  21. except Exception as e: # We don't want the code to break at exit because of the client (whatever the reason might be)
  22. logger.warning(f"Exception could not be uploaded to platform with exception: {e}")
  23. @multi_process_safe
  24. def setup_pro_user_monitoring() -> bool:
  25. """Setup the pro user environment for error logging and monitoring"""
  26. if client_enabled:
  27. if env_variables.UPLOAD_LOGS:
  28. logger.info("deci-lab-client package detected. activating automatic log uploading")
  29. logger.info("If you do not have a deci-lab-client credentials or you wish to disable this feature, please set the env variable UPLOAD_LOGS=FALSE")
  30. # This prevents hydra.main to catch errors that happen in the decorated function
  31. # (which leads sys.excepthook to never be called)
  32. os.environ["HYDRA_FULL_ERROR"] = "1"
  33. logger.info("Connecting to the deci platform ...")
  34. platform_client = DeciClient()
  35. logger.info("Connection to the deci platform successful!")
  36. atexit.register(exception_upload_handler, platform_client)
  37. return True
  38. else:
  39. logger.info("Automatic log upload was disabled. To enable it please set the env variable UPLOAD_LOGS=TRUE")
  40. return False
Discard
Tip!

Press p or to see the previous file or, n or to see the next file