Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/amici/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def import_petab_problem(
os.makedirs(model_output_dir)

# check if compilation necessary
if not _can_import_model(model_name) or force_compile:
if force_compile or not _can_import_model(model_name, model_output_dir):
# check if folder exists
if os.listdir(model_output_dir) and not force_compile:
raise ValueError(
Expand Down Expand Up @@ -353,13 +353,14 @@ def _create_model_name(folder: str) -> str:
return os.path.split(os.path.normpath(folder))[-1]


def _can_import_model(model_name: str) -> bool:
def _can_import_model(model_name: str, model_output_dir: str) -> bool:
"""
Check whether a module of that name can already be imported.
"""
# try to import (in particular checks version)
try:
model_module = importlib.import_module(model_name)
with amici.add_path(model_output_dir):
model_module = importlib.import_module(model_name)
except ModuleNotFoundError:
return False

Expand Down