Skip to content

Commit

Permalink
fix: issue with incorrect imports in exe.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbonde committed Apr 21, 2023
1 parent 7085e04 commit f898ca8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion nbox/assets/exe.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,29 @@ from functools import lru_cache, partial
@lru_cache(1)
def get_op(cloud = False):
# The beauty of this function is that it ensures that the operator class is loaded only once

# first try except is to catch any issues during the import itself
try:
# import user code, add this to the try/except because if the code does not exit and there
# is an infinite loop, there can be a whole bunch of side effects, ex: 100s of LMAO live trackers
from {{ file_name }} import {{ fn_name }}

# we still want to ensure that user initialises `nbox` first so their environment variables are
# always going to hold true
import nbox.utils as U
from nbox import Operator, logger

except Exception as e:
# again import the nbox things so that we can log the traceback and exit the program
import nbox.utils as U
from nbox import Operator, logger

U.log_traceback()
logger.error(f"Failed to load operator: {e}")
U.hard_exit_program(1)

# second is to initialise it as an Operator
try:
# load the operator
obj = {{ init_code }}
if not type(obj) == Operator and {{ load_operator }}:
Expand All @@ -36,7 +49,6 @@ def get_op(cloud = False):
obj = Operator.from_fn(obj)
else:
raise ValueError("{{ fn_name }} is not an Operator or class or function")

# at this point there is a guarantee that obj is an Operator
op: Operator = obj
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion nbox/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.12.5c13"
__version__ = "0.12.5c14"
_major, _minor, _patch = __version__.split(".")
_major = int(_major)
_minor = int(_minor)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nbox"
version = "0.12.5c13"
version = "0.12.5c14"
description = "ML Inference 🥶"
authors = [
"NBX Research <[email protected]>",
Expand Down

0 comments on commit f898ca8

Please sign in to comment.