File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,29 @@ from functools import lru_cache, partial
1414@lru_cache(1)
1515def get_op(cloud = False):
1616 # The beauty of this function is that it ensures that the operator class is loaded only once
17+
18+ # first try except is to catch any issues during the import itself
1719 try:
1820 # import user code, add this to the try/except because if the code does not exit and there
1921 # is an infinite loop, there can be a whole bunch of side effects, ex: 100s of LMAO live trackers
2022 from {{ file_name }} import {{ fn_name }}
2123
2224 # we still want to ensure that user initialises `nbox` first so their environment variables are
2325 # always going to hold true
26+ import nbox.utils as U
2427 from nbox import Operator, logger
28+
29+ except Exception as e:
30+ # again import the nbox things so that we can log the traceback and exit the program
2531 import nbox.utils as U
32+ from nbox import Operator, logger
33+
34+ U.log_traceback()
35+ logger.error(f"Failed to load operator: {e}")
36+ U.hard_exit_program(1)
2637
38+ # second is to initialise it as an Operator
39+ try:
2740 # load the operator
2841 obj = {{ init_code }}
2942 if not type(obj) == Operator and {{ load_operator }}:
@@ -36,7 +49,6 @@ def get_op(cloud = False):
3649 obj = Operator.from_fn(obj)
3750 else:
3851 raise ValueError("{{ fn_name }} is not an Operator or class or function")
39-
4052 # at this point there is a guarantee that obj is an Operator
4153 op: Operator = obj
4254 except Exception as e:
Original file line number Diff line number Diff line change 1- __version__ = "0.12.5c13 "
1+ __version__ = "0.12.5c14 "
22_major , _minor , _patch = __version__ .split ("." )
33_major = int (_major )
44_minor = int (_minor )
Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " nbox"
3- version = " 0.12.5c13 "
3+ version = " 0.12.5c14 "
44description = " ML Inference 🥶"
55authors = [
66 " NBX Research <research@nimblebox.ai>" ,
You can’t perform that action at this time.
0 commit comments