From f898ca8c8ef7c70c3d5c0b493dfa07411ab45f35 Mon Sep 17 00:00:00 2001 From: yashbonde Date: Fri, 21 Apr 2023 19:52:48 +0530 Subject: [PATCH] fix: issue with incorrect imports in exe.py --- nbox/assets/exe.jinja | 14 +++++++++++++- nbox/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/nbox/assets/exe.jinja b/nbox/assets/exe.jinja index 6061219..ddf85c0 100644 --- a/nbox/assets/exe.jinja +++ b/nbox/assets/exe.jinja @@ -14,6 +14,8 @@ 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 @@ -21,9 +23,20 @@ def get_op(cloud = False): # 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 }}: @@ -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: diff --git a/nbox/version.py b/nbox/version.py index 8a0ed53..df6ab7d 100644 --- a/nbox/version.py +++ b/nbox/version.py @@ -1,4 +1,4 @@ -__version__ = "0.12.5c13" +__version__ = "0.12.5c14" _major, _minor, _patch = __version__.split(".") _major = int(_major) _minor = int(_minor) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7d729e3..bc62d57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nbox" -version = "0.12.5c13" +version = "0.12.5c14" description = "ML Inference 🥶" authors = [ "NBX Research ",