2022-03-13 21:39:41 +00:00
|
|
|
import os.path
|
2021-10-05 09:17:33 -07:00
|
|
|
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
|
2022-03-13 21:39:41 +00:00
|
|
|
ray_path = Path(
|
|
|
|
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
|
2022-01-29 18:41:57 -08:00
|
|
|
)
|
2021-10-05 09:17:33 -07:00
|
|
|
notebook_path = ray_path.joinpath(relative_path_to_test_script)
|
|
|
|
assert notebook_path.exists()
|
|
|
|
|
2022-01-29 18:41:57 -08:00
|
|
|
spec = importlib.util.spec_from_file_location("notebook_test", notebook_path)
|
2021-10-05 09:17:33 -07:00
|
|
|
notebook_test_module = importlib.util.module_from_spec(spec)
|
|
|
|
spec.loader.exec_module(notebook_test_module)
|