How to use the kedro.cli.utils.python_call function in kedro

To help you get started, weā€™ve selected a few kedro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quantumblacklabs / kedro-examples / kedro-tutorial / kedro_cli.py View on Github external
def test(args):
    """Run the test suite."""
    try:
        import pytest  # pylint: disable=unused-import
    except ImportError:
        raise KedroCliError(NO_DEPENDENCY_MESSAGE.format("pytest"))
    else:
        python_call("pytest", args)
github Minyus / causallift / kedro_cli.py View on Github external
def test(args):
    """Run the test suite."""
    try:
        import pytest  # pylint: disable=unused-import
    except ImportError:
        raise KedroCliError(NO_PYTEST_MESSAGE)
    else:
        python_call("pytest", args)
github Minyus / causallift / kedro_cli.py View on Github external
def build_reqs():
    """Build the project dependency requirements."""
    requirements_path = Path.cwd() / "src" / "requirements.in"
    if not requirements_path.is_file():
        secho("No requirements.in found. Copying contents from requirements.txt...")
        contents = (Path.cwd() / "src" / "requirements.txt").read_text()
        requirements_path.write_text(contents)
    python_call("piptools", ["compile", str(requirements_path)])
    secho(
        (
            "Requirements built! Please update requirements.in "
            "if you'd like to make a change in your project's dependencies, "
github Minyus / causallift / kedro_cli.py View on Github external
def install():
    """Install project dependencies from both requirements.txt and environment.yml (optional)."""

    if (Path.cwd() / "src" / "environment.yml").is_file():
        call(["conda", "install", "--file", "src/environment.yml", "--yes"])

    python_call("pip", ["install", "-U", "-r", "src/requirements.txt"])
github tipresias / tipresias / data_science / kedro_cli.py View on Github external
def install():
    """Install project dependencies from requirements.txt."""
    python_call("pip", ["install", "-U", "-r", "requirements.txt"])
github quantumblacklabs / kedro-examples / kedro-tutorial / kedro_cli.py View on Github external
def jupyter_lab(ip, all_kernels, env, idle_timeout, args):
    """Open Jupyter Lab with project specific variables loaded."""
    if "-h" not in args and "--help" not in args:
        ipython_message(all_kernels)

    arguments = _build_jupyter_command(
        "lab", ip=ip, all_kernels=all_kernels, args=args, idle_timeout=idle_timeout
    )

    python_call_kwargs = _build_jupyter_env(env)
    python_call("jupyter", arguments, **python_call_kwargs)
github tipresias / tipresias / data_science / kedro_cli.py View on Github external
def build_docs():
    """Build the project documentation."""
    python_call("pip", ["install", "src/[docs]"])
    python_call("pip", ["install", "-r", "requirements.txt"])
    python_call("ipykernel", ["install", "--user", "--name=machine_learning"])
    if Path("docs/build").exists():
        shutil.rmtree("docs/build")
    call(
        ["sphinx-apidoc", "--module-first", "-o", "docs/source", "src/machine_learning"]
    )
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
github tipresias / tipresias / data_science / kedro_cli.py View on Github external
def build_docs():
    """Build the project documentation."""
    python_call("pip", ["install", "src/[docs]"])
    python_call("pip", ["install", "-r", "requirements.txt"])
    python_call("ipykernel", ["install", "--user", "--name=machine_learning"])
    if Path("docs/build").exists():
        shutil.rmtree("docs/build")
    call(
        ["sphinx-apidoc", "--module-first", "-o", "docs/source", "src/machine_learning"]
    )
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
github quantumblacklabs / kedro / kedro / template / {{ cookiecutter.repo_name }} / kedro_cli.py View on Github external
def install():
    """Install project dependencies from both requirements.txt
    and environment.yml (optional)."""

    if (Path.cwd() / "src" / "environment.yml").is_file():
        call(["conda", "install", "--file", "src/environment.yml", "--yes"])

    pip_command = ["install", "-U", "-r", "src/requirements.txt"]

    if os.name == "posix":
        python_call("pip", pip_command)
    else:
        command = [sys.executable, "-m", "pip"] + pip_command
        subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE)
github quantumblacklabs / kedro / kedro / template / {{ cookiecutter.repo_name }} / kedro_cli.py View on Github external
def lint(files):
    """Run flake8, isort and (on Python >=3.6) black."""
    # pylint: disable=unused-import
    if not files:
        files = ("src/tests", "src/{{ cookiecutter.python_package }}")

    try:
        import flake8
        import isort
    except ImportError as exc:
        raise KedroCliError(NO_DEPENDENCY_MESSAGE.format(exc.name))

    python_call("flake8", ("--max-line-length=88",) + files)
    python_call("isort", ("-rc", "-tc", "-up", "-fgw=0", "-m=3", "-w=88") + files)

    if sys.version_info[:2] >= (3, 6):
        try:
            import black
        except ImportError:
            raise KedroCliError(NO_DEPENDENCY_MESSAGE.format("black"))
        python_call("black", files)