Ejemplo n.º 1
0
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"])
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def jupyter_lab(ip, all_kernels, env, 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)

    python_call_kwargs = _build_jupyter_env(env)
    python_call("jupyter", arguments, **python_call_kwargs)
Ejemplo n.º 5
0
def jupyter_notebook(ip, all_kernels, env, idle_timeout, args):
    """Open Jupyter Notebook with project specific variables loaded."""
    if "-h" not in args and "--help" not in args:
        ipython_message(all_kernels)

    arguments = _build_jupyter_command(
        "notebook", 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)
Ejemplo n.º 6
0
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, "
           "and re-run build-reqs to generate the new requirements.txt."))
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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"])
    hostname = socket.gethostname()
    print(hostname)
    if hostname.startswith('spiro'):
        pip_command = [
            "install", "-U", "-r", "src/requirements.txt", "--proxy",
            'http://proxy.onera:80'
        ]
    else:
        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)
def build_docs():
    """Build the project documentation."""
    python_call("pip", ["install", "src/[docs]"])
    python_call("pip", ["install", "-r", "src/requirements.txt"])
    python_call("ipykernel", ["install", "--user", "--name=twa_assignment"])
    if Path("docs/build").exists():
        shutil.rmtree("docs/build")
    call(["sphinx-apidoc", "--module-first", "-o", "docs/source", "src/twa_assignment"])
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
Ejemplo n.º 10
0
def build_docs():
    """Build the project documentation."""
    python_call("pip", ["install", "src/[docs]"])
    python_call("pip", ["install", "-r", "src/requirements.txt"])
    python_call("ipykernel", ["install", "--user", "--name=fraud"])
    shutil.rmtree("docs/build", ignore_errors=True)
    call([
        "sphinx-apidoc",
        "--module-first",
        "-o",
        "docs/source",
        "src/fraud",
    ])
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
Ejemplo n.º 11
0
def build_docs(open_docs):
    """Build the project documentation."""
    python_call("pip", ["install", "src/[docs]"])
    python_call("pip", ["install", "-r", "src/requirements.txt"])
    python_call("ipykernel", ["install", "--user", "--name=kedro_tutorial"])
    shutil.rmtree("docs/build", ignore_errors=True)
    call([
        "sphinx-apidoc", "--module-first", "-o", "docs/source",
        "src/kedro_tutorial"
    ])
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
    if open_docs:
        docs_page = (Path.cwd() / "docs" / "build" / "html" /
                     "index.html").as_uri()
        secho("Opening {}".format(docs_page))
        webbrowser.open(docs_page)
Ejemplo n.º 12
0
def lint(files):
    """Run flake8, isort and (on Python >=3.6) black."""
    # pylint: disable=unused-import
    if not files:
        files = ("src/tests", "src/kedro_code_forensics")

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

    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)
    python_call("flake8", ("--max-line-length=88", ) + files)
Ejemplo n.º 13
0
def lint(files, check_only):
    """Run flake8, isort and (on Python >=3.6) black."""
    files = files or (str(
        SOURCE_PATH / "tests"), str(SOURCE_PATH / KEDRO_PACKAGE_NAME))

    try:
        import flake8
        import isort
        import black
    except ImportError as exc:
        raise KedroCliError(
            NO_DEPENDENCY_MESSAGE.format(module=exc.name,
                                         src=str(SOURCE_PATH)))

    python_call("black", ("--check", ) + files if check_only else files)
    python_call("flake8", ("--max-line-length=88", ) + files)

    check_flag = ("-c", ) if check_only else ()
    python_call("isort",
                (*check_flag, "-rc", "-tc", "-up", "-fgw=0", "-m=3", "-w=88") +
                files)
Ejemplo n.º 14
0
def build_docs(open_docs):
    """Build the project documentation."""
    python_call("pip", ["install", str(SOURCE_PATH / "[docs]")])
    python_call("pip",
                ["install", "-r",
                 str(SOURCE_PATH / "requirements.txt")])
    python_call("ipykernel",
                ["install", "--user", f"--name={KEDRO_PACKAGE_NAME}"])
    shutil.rmtree("docs/build", ignore_errors=True)
    call([
        "sphinx-apidoc",
        "--module-first",
        "-o",
        "docs/source",
        str(SOURCE_PATH / KEDRO_PACKAGE_NAME),
    ])
    call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
    if open_docs:
        docs_page = (Path.cwd() / "docs" / "build" / "html" /
                     "index.html").as_uri()
        secho("Opening {}".format(docs_page))
        webbrowser.open(docs_page)
def install():
    """Install project dependencies from requirements.txt."""
    python_call("pip", ["install", "-U", "-r", "src/requirements.txt"])
Ejemplo n.º 16
0
def lint(files):
    """Run flake8, isort and (on Python >=3.6) black."""
    # pylint: disable=unused-import
    if not files:
        files = ("src/tests", "src/hintech")

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

    python_call("isort", ("-q", "-y", "-rc", "-sl") + files)
    python_call(
        "autoflake",
        ("--remove-all-unused-imports", "--recursive",
         "--remove-unused-variables", "--in-place", "--exclude=__init__.py") +
        files)

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

    python_call(
        "isort",
        ("-q", "-y", "-ca", "-rc", "-tc", "-up", "-fgw=0", "-m=3", "-w=120") +
        files)
    python_call("mypy", ("src/hintech", ))
    python_call("vulture", ("--min-confidence=70", ) + files)