Commit c6456d1f authored by Lucas Bourneuf's avatar Lucas Bourneuf

savage fix for non-importable python scripts

parent 899821ea
...@@ -120,11 +120,20 @@ def topological_sort_by_io(inputs:dict, outputs:dict) -> iter: ...@@ -120,11 +120,20 @@ def topological_sort_by_io(inputs:dict, outputs:dict) -> iter:
def build_python_script_from_name(module_name) -> Script: def build_python_script_from_name(module_name) -> Script:
path = module_name.replace('/', '.') path = module_name.replace('/', '.')
module = importlib.import_module(path) import_as_module = True
# Reload needed because the module itself is try:
# modified by build_script_from_module module = importlib.import_module(path)
module = importlib.reload(module) except TypeError:
return build_script_from_module(module) import_as_module = False
if import_as_module:
# Reload needed because the module itself is
# modified by build_script_from_module
module = importlib.reload(module)
return build_script_from_module(module)
else: # just load it savagely
# module_name is not importable directly
return build_script_from_json({'python file': module_name + '.py'})
def build_asp_script_from_name(fname:str) -> str: def build_asp_script_from_name(fname:str) -> str:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment