Skip to content

Commit f898ca8

Browse files
committed
fix: issue with incorrect imports in exe.py
1 parent 7085e04 commit f898ca8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

nbox/assets/exe.jinja

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@ from functools import lru_cache, partial
1414
@lru_cache(1)
1515
def 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:

nbox/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.12.5c13"
1+
__version__ = "0.12.5c14"
22
_major, _minor, _patch = __version__.split(".")
33
_major = int(_major)
44
_minor = int(_minor)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nbox"
3-
version = "0.12.5c13"
3+
version = "0.12.5c14"
44
description = "ML Inference 🥶"
55
authors = [
66
"NBX Research <research@nimblebox.ai>",

0 commit comments

Comments
 (0)