Skip to content

Commit

Permalink
Adapt e2e tests for new project structure
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
  • Loading branch information
astrojuanlu committed May 23, 2023
1 parent 54e34ae commit 093000e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
39 changes: 32 additions & 7 deletions features/environment.py
Expand Up @@ -8,6 +8,11 @@
import venv
from pathlib import Path

try:
import tomllib
except ImportError:
import tomli as tomllib # type: ignore

from features.steps.sh_run import run

_PATHS_TO_REMOVE: set[Path] = set()
Expand Down Expand Up @@ -115,13 +120,33 @@ def _setup_minimal_env(context):


def _install_project_requirements(context):
install_reqs = (
Path(
"kedro/templates/project/{{ cookiecutter.repo_name }}/dev-requirements.txt"
)
.read_text(encoding="utf-8")
.splitlines()
)
# HACK: Dev requirements of the project are stored in pyproject.toml,
# but the file cannot be directly loaded because it's a cookicutter template,
# so we read only the part that we need
with open(
"kedro/templates/project/{{ cookiecutter.repo_name }}/pyproject.toml",
encoding="utf-8",
) as pyproject_fh:
_buffer = []
while True:
try:
line = next(pyproject_fh)
except StopIteration as exc:
raise RuntimeError("Error while reading project dependencies") from exc

if line.startswith("[project.optional-dependencies]"):
_buffer.append(line)
for line in pyproject_fh:
if line.startswith("["):
break

_buffer.append(line)
break

_meta = tomllib.loads("\n".join(_buffer))
install_reqs = _meta["project"]["optional-dependencies"]["dev"]
# EOH

install_reqs = [req for req in install_reqs if "{" not in req]
install_reqs.append(".[pandas.CSVDataSet]")
call([context.pip, "install", *install_reqs], env=context.env)
Expand Down
1 change: 1 addition & 0 deletions test_requirements.txt
Expand Up @@ -59,6 +59,7 @@ SQLAlchemy~=1.2
tables~=3.6.0; platform_system == "Windows" and python_version<'3.9'
tables~=3.6; platform_system != "Windows"
tensorflow~=2.0
tomli~=2.0.1; python_version < '3.11'
triad>=0.6.7, <1.0
trufflehog~=2.1
xlsxwriter~=1.0

0 comments on commit 093000e

Please sign in to comment.