Skip to content

Commit

Permalink
Merge pull request trueagi-io#555 from trueagi-io/exts
Browse files Browse the repository at this point in the history
support for loading extensions from exts
  • Loading branch information
Necr0x0Der authored Jan 31, 2024
2 parents 66e81e0 + 6b67c04 commit 5aa9e93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/hyperon/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,16 @@ def load_py_module_from_mod_or_file(self, mod_name):
if not isinstance(mod_name, str):
mod_name = repr(mod_name)
mod = MeTTa.load_py_module(self, mod_name)
if mod is None:
# NOTE: this is a hot fix, which could be done via env_builder as well, but
# this is a more direct loading of Python modules than via module_from_spec
mod = MeTTa.load_py_module(self, "hyperon.exts." + mod_name)
if mod is None:
# If that failed, try and load the module from a file
# mod_name should either be a path to py file (with / delimiters)
# or a module path (with . delimiters)
file_name = mod_name if ".py" in mod_name else \
mod_name.replace('.', os.sep) + ".py"
mod_name.replace('.', os.sep) + os.sep + "__init__.py"

# Check each search path directory in order, until we find the module we're looking for
num_search_paths = hp.metta_search_path_cnt(self.cmetta)
Expand Down

0 comments on commit 5aa9e93

Please sign in to comment.