Skip to content

Commit f35db9f

Browse files
authored
(WIP) set up experimental (#7959)
1 parent 623b321 commit f35db9f

File tree

1,540 files changed

+2399
-2180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,540 files changed

+2399
-2180
lines changed

.devcontainer/docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22
services:
33
langchain:
44
build:
5-
dockerfile: dev.Dockerfile
5+
dockerfile: libs/langchain/dev.Dockerfile
66
context: ..
77
volumes:
88
# Update this to wherever you want VS Code to mount the folder of your project

.github/actions/poetry_setup/action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ runs:
5252

5353
- name: Check Poetry File
5454
shell: bash
55+
working-directory: ${{ inputs.working-directory }}
5556
run: |
5657
poetry check
5758
5859
- name: Check lock file
5960
shell: bash
61+
working-directory: ${{ inputs.working-directory }}
6062
run: |
6163
poetry lock --check
6264

.github/workflows/lint.yml renamed to .github/workflows/_lint.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
name: lint
22

33
on:
4-
push:
5-
branches: [master]
6-
pull_request:
4+
workflow_call:
5+
inputs:
6+
working-directory:
7+
required: true
8+
type: string
9+
description: "From which folder this pipeline executes"
710

811
env:
912
POETRY_VERSION: "1.4.2"
1013

1114
jobs:
1215
build:
16+
defaults:
17+
run:
18+
working-directory: ${{ inputs.working-directory }}
1319
runs-on: ubuntu-latest
1420
strategy:
1521
matrix:

.github/workflows/release.yml renamed to .github/workflows/_release.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: release
22

33
on:
4-
pull_request:
5-
types:
6-
- closed
7-
branches:
8-
- master
9-
paths:
10-
- 'pyproject.toml'
4+
workflow_call:
5+
inputs:
6+
working-directory:
7+
required: true
8+
type: string
9+
description: "From which folder this pipeline executes"
1110

1211
env:
1312
POETRY_VERSION: "1.4.2"
@@ -18,6 +17,9 @@ jobs:
1817
${{ github.event.pull_request.merged == true }}
1918
&& ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
2019
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
working-directory: ${{ inputs.working-directory }}
2123
steps:
2224
- uses: actions/checkout@v3
2325
- name: Install poetry

.github/workflows/test.yml renamed to .github/workflows/_test.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
name: test
22

33
on:
4-
push:
5-
branches: [master]
6-
pull_request:
7-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
working-directory:
7+
required: true
8+
type: string
9+
description: "From which folder this pipeline executes"
810

911
env:
1012
POETRY_VERSION: "1.4.2"
1113

1214
jobs:
1315
build:
16+
defaults:
17+
run:
18+
working-directory: ${{ inputs.working-directory }}
1419
runs-on: ubuntu-latest
1520
strategy:
1621
matrix:
@@ -29,6 +34,7 @@ jobs:
2934
uses: "./.github/actions/poetry_setup"
3035
with:
3136
python-version: ${{ matrix.python-version }}
37+
working-directory: ${{ inputs.working-directory }}
3238
poetry-version: "1.4.2"
3339
cache-key: ${{ matrix.test_type }}
3440
install-command: |

.github/workflows/langchain_ci.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: libs/langchain CI
3+
4+
on:
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
paths:
9+
- '.github/workflows/_lint.yml'
10+
- '.github/workflows/_test.yml'
11+
- '.github/workflows/langchain_ci.yml'
12+
- 'libs/langchain/**'
13+
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
14+
15+
jobs:
16+
lint:
17+
uses:
18+
./.github/workflows/_lint.yml
19+
with:
20+
working-directory: libs/langchain
21+
secrets: inherit
22+
test:
23+
uses:
24+
./.github/workflows/_test.yml
25+
with:
26+
working-directory: libs/langchain
27+
secrets: inherit
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: libs/langchain Release
3+
4+
on:
5+
pull_request:
6+
types:
7+
- closed
8+
branches:
9+
- master
10+
paths:
11+
- 'libs/langchain/pyproject.toml'
12+
13+
jobs:
14+
release:
15+
uses:
16+
./.github/workflows/_release.yml
17+
with:
18+
working-directory: libs/langchain
19+
secrets: inherit

Makefile

+1-59
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck format lint test tests test_watch integration_tests docker_tests help extended_tests
1+
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck
22

33
# Default target executed when no arguments are given to make.
44
all: help
55

6-
######################
7-
# TESTING AND COVERAGE
8-
######################
9-
10-
# Run unit tests and generate a coverage report.
11-
coverage:
12-
poetry run pytest --cov \
13-
--cov-config=.coveragerc \
14-
--cov-report xml \
15-
--cov-report term-missing:skip-covered
166

177
######################
188
# DOCUMENTATION
@@ -41,45 +31,6 @@ api_docs_clean:
4131
api_docs_linkcheck:
4232
poetry run linkchecker docs/api_reference/_build/html/index.html
4333

44-
# Define a variable for the test file path.
45-
TEST_FILE ?= tests/unit_tests/
46-
47-
test:
48-
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
49-
50-
tests:
51-
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
52-
53-
extended_tests:
54-
poetry run pytest --disable-socket --allow-unix-socket --only-extended tests/unit_tests
55-
56-
test_watch:
57-
poetry run ptw --now . -- tests/unit_tests
58-
59-
integration_tests:
60-
poetry run pytest tests/integration_tests
61-
62-
docker_tests:
63-
docker build -t my-langchain-image:test .
64-
docker run --rm my-langchain-image:test
65-
66-
######################
67-
# LINTING AND FORMATTING
68-
######################
69-
70-
# Define a variable for Python and notebook files.
71-
PYTHON_FILES=.
72-
lint format: PYTHON_FILES=.
73-
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
74-
75-
lint lint_diff:
76-
poetry run mypy $(PYTHON_FILES)
77-
poetry run black $(PYTHON_FILES) --check
78-
poetry run ruff .
79-
80-
format format_diff:
81-
poetry run black $(PYTHON_FILES)
82-
poetry run ruff --select I --fix $(PYTHON_FILES)
8334

8435
spell_check:
8536
poetry run codespell --toml pyproject.toml
@@ -97,12 +48,3 @@ help:
9748
@echo 'docs_build - build the documentation'
9849
@echo 'docs_clean - clean the documentation build artifacts'
9950
@echo 'docs_linkcheck - run linkchecker on the documentation'
100-
@echo 'format - run code formatters'
101-
@echo 'lint - run linters'
102-
@echo 'test - run unit tests'
103-
@echo 'tests - run unit tests'
104-
@echo 'test TEST_FILE=<test_file> - run all tests in file'
105-
@echo 'extended_tests - run only extended unit tests'
106-
@echo 'test_watch - run unit tests in watch mode'
107-
@echo 'integration_tests - run integration tests'
108-
@echo 'docker_tests - run unit tests in docker'

docs/api_reference/create_api_rst.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
ROOT_DIR = Path(__file__).parents[2].absolute()
7-
PKG_DIR = ROOT_DIR / "langchain"
7+
PKG_DIR = ROOT_DIR / "libs" / "langchain"
88
WRITE_FILE = Path(__file__).parent / "api_reference.rst"
99

1010

File renamed without changes.
File renamed without changes.
File renamed without changes.

libs/langchain/Makefile

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck format lint test tests test_watch integration_tests docker_tests help extended_tests
2+
3+
# Default target executed when no arguments are given to make.
4+
all: help
5+
6+
######################
7+
# TESTING AND COVERAGE
8+
######################
9+
10+
# Run unit tests and generate a coverage report.
11+
coverage:
12+
poetry run pytest --cov \
13+
--cov-config=.coveragerc \
14+
--cov-report xml \
15+
--cov-report term-missing:skip-covered
16+
17+
######################
18+
# DOCUMENTATION
19+
######################
20+
21+
clean: docs_clean api_docs_clean
22+
23+
24+
docs_build:
25+
docs/.local_build.sh
26+
27+
docs_clean:
28+
rm -r docs/_dist
29+
30+
docs_linkcheck:
31+
poetry run linkchecker docs/_dist/docs_skeleton/ --ignore-url node_modules
32+
33+
api_docs_build:
34+
poetry run python docs/api_reference/create_api_rst.py
35+
cd docs/api_reference && poetry run make html
36+
37+
api_docs_clean:
38+
rm -f docs/api_reference/api_reference.rst
39+
cd docs/api_reference && poetry run make clean
40+
41+
api_docs_linkcheck:
42+
poetry run linkchecker docs/api_reference/_build/html/index.html
43+
44+
# Define a variable for the test file path.
45+
TEST_FILE ?= tests/unit_tests/
46+
47+
test:
48+
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
49+
50+
tests:
51+
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
52+
53+
extended_tests:
54+
poetry run pytest --disable-socket --allow-unix-socket --only-extended tests/unit_tests
55+
56+
test_watch:
57+
poetry run ptw --now . -- tests/unit_tests
58+
59+
integration_tests:
60+
poetry run pytest tests/integration_tests
61+
62+
docker_tests:
63+
docker build -t my-langchain-image:test .
64+
docker run --rm my-langchain-image:test
65+
66+
######################
67+
# LINTING AND FORMATTING
68+
######################
69+
70+
# Define a variable for Python and notebook files.
71+
PYTHON_FILES=.
72+
lint format: PYTHON_FILES=.
73+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
74+
75+
lint lint_diff:
76+
poetry run mypy $(PYTHON_FILES)
77+
poetry run black $(PYTHON_FILES) --check
78+
poetry run ruff .
79+
80+
format format_diff:
81+
poetry run black $(PYTHON_FILES)
82+
poetry run ruff --select I --fix $(PYTHON_FILES)
83+
84+
spell_check:
85+
poetry run codespell --toml pyproject.toml
86+
87+
spell_fix:
88+
poetry run codespell --toml pyproject.toml -w
89+
90+
######################
91+
# HELP
92+
######################
93+
94+
help:
95+
@echo '----'
96+
@echo 'coverage - run unit tests and generate coverage report'
97+
@echo 'docs_build - build the documentation'
98+
@echo 'docs_clean - clean the documentation build artifacts'
99+
@echo 'docs_linkcheck - run linkchecker on the documentation'
100+
@echo 'format - run code formatters'
101+
@echo 'lint - run linters'
102+
@echo 'test - run unit tests'
103+
@echo 'tests - run unit tests'
104+
@echo 'test TEST_FILE=<test_file> - run all tests in file'
105+
@echo 'extended_tests - run only extended unit tests'
106+
@echo 'test_watch - run unit tests in watch mode'
107+
@echo 'integration_tests - run integration tests'
108+
@echo 'docker_tests - run unit tests in docker'

0 commit comments

Comments
 (0)