earthmover
earthmover copied to clipboard
Make YAML parser use config file path to render Jinja
Potential fix for #177, which documents the case where
- Jinja is imported in an earthmover config YAML, but installing that package via
earthmover depsbreaks, because the relative imports cannot be found from the root directory of the importing project (e.g. student_id_wrapper). - Jinja is imported in an earthmover destination template, but running that package under project composition breaks (assuming you get past the install issues above), because the relative imports cannot be found from the root directory of the importing project.
To fix these, this commit:
- Adds an optional parameter to
util.build_jinja_templatethat gets passed tojinja2.FileSystemLoaderto control where templates are searched for. This replaces the original behavior, whereFileSystemLoaderwas always initialized with the current working directory of the root earthmover.yaml. - Modifies
JinjaEnvironmentLoader.load_config_fileto pass the parent directory of the config file being rendered toutil.build_jinja_template. Deps thus runs succesasfully. - Modifies
Destinationnodes to pass the directory of the associated config file toutil.build_jinja_template.
Open to other fixes, but this seems like an easy minimal fix to me that doesn't require changing the working directory. Could write out tests for the desired behavior if needed.