Example #1
0
    def test_invalid_source_path(self, tmp_path, source_dir):
        source_dir = Path(source_dir).expanduser()
        source_path = (tmp_path / source_dir).resolve()
        source_path.mkdir(parents=True, exist_ok=True)

        pattern = re.escape(
            f"Source path '{source_path}' has to be relative to your project root "
            f"'{tmp_path.resolve()}'")
        with pytest.raises(KedroContextError, match=pattern):
            validate_source_path(source_path, tmp_path.resolve())
Example #2
0
from kedro.context import load_context, validate_source_path

from kedro.utils import load_obj

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])

# get our package onto the python path
PROJ_PATH = Path(__file__).resolve().parent
os.environ["IPYTHONDIR"] = str(PROJ_PATH / ".ipython")

with (PROJ_PATH / ".kedro.yml").open("r") as kedro_yml:
    kedro_yaml = yaml.safe_load(kedro_yml)

SOURCE_DIR = Path(kedro_yaml.get("source_dir", "src")).expanduser()
SOURCE_PATH = (PROJ_PATH / SOURCE_DIR).resolve()
validate_source_path(SOURCE_PATH, PROJ_PATH)

KEDRO_PACKAGE_NAME = "kedro_new_project"

NO_DEPENDENCY_MESSAGE = """{module} is not installed. Please make sure {module} is in
{src}/requirements.txt and run `kedro install`."""

TAG_ARG_HELP = """Construct the pipeline using only nodes which have this tag
attached. Option can be used multiple times, what results in a
pipeline constructed from nodes having any of those tags."""

PIPELINE_ARG_HELP = """Name of the modular pipeline to run.
If not set, the project pipeline is run by default."""

ENV_ARG_HELP = """Run the pipeline in a configured environment. If not specified,
pipeline will run using environment `local`."""
Example #3
0
    def test_non_existent_source_path(self, tmp_path):
        source_path = (tmp_path / "non_existent").resolve()

        pattern = f"Source path '{source_path}' cannot be found."
        with pytest.raises(KedroContextError, match=pattern):
            validate_source_path(source_path, tmp_path.resolve())
Example #4
0
 def test_valid_source_path(self, tmp_path, source_dir):
     source_path = (tmp_path / source_dir).resolve()
     source_path.mkdir(parents=True, exist_ok=True)
     validate_source_path(source_path, tmp_path.resolve())