ray/release/golden_notebook_tests/workloads/util.py
Kai Fricke 430ea3e636
[ci/release] Migrate golden notebook tests (#22949)
Migrating golden notebook tests to new release test package.
Tests are passing: https://buildkite.com/ray-project/release-tests-branch/builds/155
2022-03-13 21:39:41 +00:00

17 lines
649 B
Python

import os.path
from pathlib import Path
import importlib.util
def import_and_execute_test_script(relative_path_to_test_script: str):
"""Imports and executes a module from a path relative to Ray repo root."""
# get the ray folder
ray_path = Path(
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
)
notebook_path = ray_path.joinpath(relative_path_to_test_script)
assert notebook_path.exists()
spec = importlib.util.spec_from_file_location("notebook_test", notebook_path)
notebook_test_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(notebook_test_module)