Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI CI 2 #12387

Merged
merged 8 commits into from
Oct 27, 2023
Merged

CLI CI 2 #12387

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ jobs:
shell: bash
run: make test

- name: Install integration dependencies
shell: bash
run: poetry install --with=test_integration

- name: Check integration tests compile
shell: bash
run: poetry run pytest -m compile tests/integration_tests

Comment on lines -47 to -54
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baskaryan to confirm removing this is ok (it's still in _compile_integration_test.yml, which is called for langchain and experimental)

- name: Ensure the tests did not create any additional files
shell: bash
run: |
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/langchain_cli_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: libs/cli CI

on:
push:
branches: [ master ]
pull_request:
paths:
- '.github/actions/poetry_setup/action.yml'
- '.github/tools/**'
- '.github/workflows/_lint.yml'
- '.github/workflows/_test.yml'
- '.github/workflows/_pydantic_compatibility.yml'
- '.github/workflows/langchain_cli_ci.yml'
- 'libs/cli/**'
- 'libs/*'
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
#
# There's no point in testing an outdated version of the code. GitHub only allows
# a limited number of job runners to be active at the same time, so it's better to cancel
# pointless jobs early so that more useful jobs can run sooner.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
POETRY_VERSION: "1.6.1"
WORKDIR: "libs/cli"

jobs:
lint:
uses:
./.github/workflows/_lint.yml
with:
working-directory: libs/cli
secrets: inherit

test:
uses:
./.github/workflows/_test.yml
with:
working-directory: libs/cli
secrets: inherit

pydantic-compatibility:
uses:
./.github/workflows/_pydantic_compatibility.yml
with:
working-directory: libs/cli
secrets: inherit
8 changes: 8 additions & 0 deletions libs/cli/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lint lint_diff:
poetry run poe lint

test:
poetry run poe test

format:
poetry run poe format
6 changes: 3 additions & 3 deletions libs/cli/langchain_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import typer
import subprocess
from typing import Optional

import typer
from typing_extensions import Annotated

from langchain_cli.namespaces import hub
from langchain_cli.namespaces import serve
from langchain_cli.namespaces import hub, serve

app = typer.Typer(no_args_is_help=True, add_completion=False)
app.add_typer(hub.hub, name="hub", help=hub.__doc__)
Expand Down
1 change: 1 addition & 0 deletions libs/cli/langchain_cli/dev_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from fastapi import FastAPI
from langserve.packages import add_package_route

from langchain_cli.utils.packages import get_package_root


Expand Down
11 changes: 6 additions & 5 deletions libs/cli/langchain_cli/namespaces/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Manage installable hub packages.
"""

import typer
from typing import Optional
from typing_extensions import Annotated
from pathlib import Path
import re
import shutil
import subprocess
import re
from pathlib import Path
from typing import Optional

import typer
from typing_extensions import Annotated

hub = typer.Typer(no_args_is_help=True, add_completion=False)

Expand Down
27 changes: 16 additions & 11 deletions libs/cli/langchain_cli/namespaces/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
Manage LangServe application projects.
"""

import typer
from typing import Optional, List
from typing_extensions import Annotated
from pathlib import Path
import shutil
import subprocess
from pathlib import Path
from typing import List, Optional

import tomli
import typer
from langserve.packages import get_langserve_export, list_packages
from typing_extensions import Annotated

from langchain_cli.utils.events import create_events
from langchain_cli.utils.git import (
copy_repo,
update_repo,
parse_dependency_string,
update_repo,
)
from langchain_cli.utils.packages import get_package_root
from langchain_cli.utils.events import create_events
from langserve.packages import list_packages, get_langserve_export
import tomli

REPO_DIR = Path(typer.get_app_dir("langchain")) / "git_repos"

Expand Down Expand Up @@ -101,7 +103,8 @@ def add(
if len(repo) != 0:
if len(dependencies) != 0:
raise typer.BadParameter(
"Cannot specify both repo and dependencies. Please specify one or the other."
"Cannot specify both repo and dependencies. "
"Please specify one or the other."
)
dependencies = [f"git+https://github.com/{r}" for r in repo]

Expand Down Expand Up @@ -144,7 +147,8 @@ def add(
# detect name conflict
if langserve_export["package_name"] in installed_names:
typer.echo(
f"Package with name {langserve_export['package_name']} already installed. Skipping...",
f"Package with name {langserve_export['package_name']} already "
"installed. Skipping...",
)
continue

Expand All @@ -154,7 +158,8 @@ def add(
destination_path = package_dir / inner_api_path
if destination_path.exists():
typer.echo(
f"Endpoint {langserve_export['package_name']} already exists. Skipping...",
f"Endpoint {langserve_export['package_name']} already exists. "
"Skipping...",
)
continue
copy_repo(source_path, destination_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from langchain.prompts import ChatPromptTemplate
from langchain.chat_models import ChatOpenAI

from langchain.prompts import ChatPromptTemplate

_prompt = ChatPromptTemplate.from_messages(
[
Expand Down
5 changes: 3 additions & 2 deletions libs/cli/langchain_cli/utils/events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import urllib3
import json
from typing import List, Dict, Any, Optional, TypedDict
from typing import Any, Dict, List, Optional, TypedDict

import urllib3

WRITE_KEY = "310apTK0HUFl4AOv"

Expand Down
13 changes: 7 additions & 6 deletions libs/cli/langchain_cli/utils/git.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import Optional, TypedDict
import hashlib
import re
import shutil
from pathlib import Path
from typing import Optional, TypedDict

from git import Repo

import shutil
import re
from langchain_cli.constants import (
DEFAULT_GIT_REF,
DEFAULT_GIT_REPO,
DEFAULT_GIT_SUBDIRECTORY,
DEFAULT_GIT_REF,
)
import hashlib
from git import Repo


class DependencySource(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion libs/cli/langchain_cli/utils/packages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Set, Optional
from typing import Optional, Set


def get_package_root(cwd: Optional[Path] = None) -> Path:
Expand Down
38 changes: 32 additions & 6 deletions libs/cli/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion libs/cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@ uvicorn = "^0.23.2"
langchain = "langchain_cli.cli:app"
langchain-cli = "langchain_cli.cli:app"


[tool.poetry.group.dev.dependencies]
poethepoet = "^0.24.1"
pytest = "^7.4.2"
pytest-watch = "^4.2.0"

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.3"

[tool.poetry.group.test.dependencies]

[tool.poetry.group.typing.dependencies]

[tool.ruff]
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # isort
]

[tool.poe.tasks]
test = "poetry run pytest"
watch = "poetry run ptw"
lint = "poetry run ruff ."
format = "poetry run ruff . --fix"


[build-system]
Expand Down
5 changes: 3 additions & 2 deletions libs/cli/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pytest
from langchain_cli.utils.git import parse_dependency_string, DependencySource

from langchain_cli.constants import (
DEFAULT_GIT_REF,
DEFAULT_GIT_REPO,
DEFAULT_GIT_SUBDIRECTORY,
DEFAULT_GIT_REF,
)
from langchain_cli.utils.git import DependencySource, parse_dependency_string


def test_dependency_string() -> None:
Expand Down
Loading