Skip to content
Snippets Groups Projects
Commit 16a6ad54 authored by Karl-Hermann Wieners's avatar Karl-Hermann Wieners
Browse files

Templates: load user template also if user dir is not in mkexp path

parent 104fc0e7
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,14 @@ Make Experiments!
Release Changes
---------------
Release 1.4.1
=============
Templates
---------
* Load user template also if user dir is not in mkexp path
Release 1.4.0
=============
......
......@@ -286,11 +286,15 @@ if args.path:
config_roots = args.path.split(':')
experiment_config_name = args.config
experiment_config_id = os.path.splitext(os.path.basename(args.config))[0]
if not os.path.exists(experiment_config_name):
feedback.die("config file '{0}' does not exist".format(experiment_config_name))
(experiment_config_dir,
experiment_config_base) = os.path.split(experiment_config_name)
(experiment_config_id,
experiment_config_format) = os.path.splitext(experiment_config_base)
# Overrides
invalid_args = [x for x in args.assigns if not x.find('=')+1]
......@@ -300,8 +304,11 @@ if invalid_args:
# Setup templating environment
template_roots = config_roots
if experiment_config_dir not in template_roots:
template_roots.append(experiment_config_dir)
template_env = Environment(
loader = ChoiceLoader(list(map(FileSystemLoader, config_roots))),
loader = ChoiceLoader(list(map(FileSystemLoader, template_roots))),
variable_start_string = '%{',
variable_end_string = '}',
line_statement_prefix = '#%',
......
......@@ -160,6 +160,15 @@ class RunningTestCase(MkexpTestCase):
self.assertTrue(is_exec('test/experiments/test0001/test0001.run'))
self.assertFalse(is_exec('test/experiments/test0001/test0001.nox'))
def test_template_not_in_path(self):
expected = align(u"""
Script directory: 'experiments/test0001'
Data directory: 'experiments/test0001' (already exists)
Work directory: 'experiments/test0001' (already exists)
""")
result = output(script("mkexp -p does_not_exist test0001.config"))
self.assertMultiLineEqual(expected, result)
class CommandLineTestCase(MkexpTestCase):
def test_pass_section_variables(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment