From 02d550e4b9299f6fb91fee5fd7ef368c431a1b71 Mon Sep 17 00:00:00 2001 From: Timothy Willard <9395586+TimothyWillard@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:20:20 -0500 Subject: [PATCH] Add `FLEPI_PATH` to GH action, fix Jinja2 loader * Export `$FLEPI_PATH` in the GH action before running tests to run the unit tests for `get_cluster_info`. * Attempt to fix Jinja2 lader issue by falling back to a file system loader if a package loader fails. --- .github/workflows/gempyor-ci.yml | 1 + flepimop/gempyor_pkg/src/gempyor/_jinja.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gempyor-ci.yml b/.github/workflows/gempyor-ci.yml index d70d19071..451235d8d 100644 --- a/.github/workflows/gempyor-ci.yml +++ b/.github/workflows/gempyor-ci.yml @@ -43,6 +43,7 @@ jobs: shell: bash - name: Run gempyor tests run: | + export FLEPI_PATH=$(pwd) cd flepimop/gempyor_pkg pytest --exitfirst shell: bash diff --git a/flepimop/gempyor_pkg/src/gempyor/_jinja.py b/flepimop/gempyor_pkg/src/gempyor/_jinja.py index 406c8f2ef..9495996f1 100644 --- a/flepimop/gempyor_pkg/src/gempyor/_jinja.py +++ b/flepimop/gempyor_pkg/src/gempyor/_jinja.py @@ -14,11 +14,18 @@ from tempfile import mkstemp from typing import Any -from jinja2 import Environment, PackageLoader, Template +from jinja2 import Environment, FileSystemLoader, PackageLoader, Template # Globals -_jinja_environment = Environment(loader=PackageLoader("gempyor", "templates")) +try: + _jinja_environment = Environment(loader=PackageLoader("gempyor", "templates")) +except ValueError: + from os.path import dirname + + _jinja_environment = Environment( + loader=FileSystemLoader(dirname(__file__) + "/templates") + ) # Functions