diff --git a/bluepymm/prepare_combos/prepare_emodel_dirs.py b/bluepymm/prepare_combos/prepare_emodel_dirs.py index 60a4651..cd90726 100644 --- a/bluepymm/prepare_combos/prepare_emodel_dirs.py +++ b/bluepymm/prepare_combos/prepare_emodel_dirs.py @@ -141,7 +141,9 @@ def create_and_write_hoc_file(emodel, emodel_dir, hoc_dir, emodel_params, model_name: used to name the .hoc file. If None, the e-model name is used. Default is None. """ - setup = tools.load_module('setup', emodel_dir) + setup = tools.load_module( + 'setup', os.path.join(emodel_dir, 'setup/__init__.py') + ) with open(os.devnull, 'w') as devnull: old_stdout = sys.stdout diff --git a/bluepymm/run_combos/calculate_scores.py b/bluepymm/run_combos/calculate_scores.py index 181cf4a..e13b507 100644 --- a/bluepymm/run_combos/calculate_scores.py +++ b/bluepymm/run_combos/calculate_scores.py @@ -129,7 +129,9 @@ def run_emodel_morph( print('Running e-model %s on morphology %s in %s' % (emodel, morph_path, emodel_dir)) - setup = tools.load_module('setup', os.path.join(emodel_dir, 'setup/__init__.py')) + setup = tools.load_module( + 'setup', os.path.join(emodel_dir, 'setup/__init__.py') + ) print("Changing path to %s" % emodel_dir) with tools.cd(emodel_dir): diff --git a/bluepymm/tools.py b/bluepymm/tools.py index 9bb83f6..cae3557 100644 --- a/bluepymm/tools.py +++ b/bluepymm/tools.py @@ -103,7 +103,7 @@ def check_all_combos_have_run(database, description): def load_module(name, path): """Try and load module `name` but *only* in `path` - from https://docs.python.org/3.6/library/importlib.html#importing-a-source-file-directly + from https://docs.python.org/3.6/library/importlib.html """ # Fast path: see if the module has already been imported. try: diff --git a/tests/test_tools.py b/tests/test_tools.py index 1634eda..14d7f1e 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -120,13 +120,17 @@ def test_load_module(): """bluepymm.tools: test load_module""" # load module module_dir = os.path.join(EXAMPLES, 'simple1/data/emodels_dir/subdir/') - setup = tools.load_module('setup', os.path.join(module_dir, 'setup/__init__.py')) + setup = tools.load_module( + 'setup', os.path.join(module_dir, 'setup/__init__.py') + ) # try and execute something from loaded module setup.evaluator.create('emodel1') # load as file setup_dir = os.path.join(module_dir, 'setup') - evaluator = tools.load_module('evaluator', os.path.join(setup_dir, 'evaluator.py')) + evaluator = tools.load_module( + 'evaluator', os.path.join(setup_dir, 'evaluator.py') + ) evaluator.create('emodel1')