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

#578 Feature/sg 516 support head replacement for local pretrained weights unknown dataset

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-516_support_head_replacement_for_local_pretrained_weights_unknown_dataset
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
51
52
53
54
55
56
57
58
59
60
61
62
  1. import os
  2. import logging
  3. import atexit
  4. from super_gradients.common.environment.ddp_utils import multi_process_safe, is_distributed
  5. from super_gradients.common.crash_handler.exception import ExceptionInfo
  6. from super_gradients.common.auto_logging.console_logging import ConsoleSink
  7. try:
  8. from deci_lab_client.client import DeciPlatformClient
  9. from deci_lab_client.types import S3SignedUrl
  10. _imported_deci_lab_failure = None
  11. except (ImportError, NameError, ModuleNotFoundError) as _import_err:
  12. _imported_deci_lab_failure = _import_err
  13. logger = logging.getLogger(__name__)
  14. logger.setLevel(logging.INFO)
  15. @multi_process_safe
  16. def exception_upload_handler(platform_client):
  17. """Upload the log file to the deci platform if an error was raised"""
  18. # Make sure that the sink is flushed
  19. ConsoleSink.flush()
  20. if not is_distributed() and ExceptionInfo.is_exception_raised():
  21. logger.info("Uploading console log to deci platform ...")
  22. try:
  23. data = platform_client.upload_log_url(tag="SuperGradients", level="error")
  24. signed_url = S3SignedUrl(**data.data)
  25. platform_client.upload_file_to_s3(from_path=ConsoleSink.get_filename(), s3_signed_url=signed_url)
  26. logger.info("Exception was uploaded to deci platform!")
  27. except Exception as e: # We don't want the code to break at exit because of the client (whatever the reason might be)
  28. logger.warning(f"Exception could not be uploaded to platform with exception: {e}")
  29. @multi_process_safe
  30. def setup_pro_user_monitoring() -> bool:
  31. """Setup the pro user environment for error logging and monitoring"""
  32. if _imported_deci_lab_failure is None:
  33. upload_console_logs = os.getenv("UPLOAD_LOGS", "TRUE") == "TRUE"
  34. if upload_console_logs:
  35. logger.info("deci-lab-client package detected. activating automatic log uploading")
  36. 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")
  37. # This prevents hydra.main to catch errors that happen in the decorated function
  38. # (which leads sys.excepthook to never be called)
  39. os.environ["HYDRA_FULL_ERROR"] = "1"
  40. logger.info("Connecting to the deci platform ...")
  41. platform_client = DeciPlatformClient()
  42. platform_client.login(token=os.getenv("DECI_PLATFORM_TOKEN"))
  43. logger.info("Connection to the deci platform successful!")
  44. atexit.register(exception_upload_handler, platform_client)
  45. return True
  46. else:
  47. logger.info("Automatic log upload was disabled. To enable it please set the env variable UPLOAD_LOGS=TRUE")
  48. return False
Discard
Tip!

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