Skip to content

Commit 7e722bd

Browse files
authored
Initial commit
0 parents  commit 7e722bd

26 files changed

+1483
-0
lines changed

.codespellignore

Whitespace-only changes.

.env.example

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# To separate your traces from other application
2+
LANGSMITH_PROJECT=memory-graph
3+
4+
# The following depend on your selected configuration
5+
6+
## LLM choice:
7+
# ANTHROPIC_API_KEY=....
8+
# FIREWORKS_API_KEY=...
9+
# OPENAI_API_KEY=...
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will run integration tests for the current project once per day
2+
3+
name: Integration Tests
4+
5+
on:
6+
schedule:
7+
- cron: "37 14 * * *" # Run at 7:37 AM Pacific Time (14:37 UTC) every day
8+
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI
9+
10+
# If another scheduled run starts while this workflow is still running,
11+
# cancel the earlier run in favor of the next run.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
integration-tests:
18+
name: Integration Tests
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest]
22+
python-version: ["3.11", "3.12"]
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install dependencies
31+
run: |
32+
curl -LsSf https://astral.sh/uv/install.sh | sh
33+
uv venv
34+
uv pip install -r pyproject.toml --extra dev
35+
uv pip install -U pytest-asyncio vcrpy
36+
- name: Run integration tests
37+
env:
38+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
39+
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
40+
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
41+
LANGSMITH_TRACING: true
42+
run: |
43+
uv run pytest tests/integration_tests

.github/workflows/unit-tests.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow will run unit tests for the current project
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: ["main"]
8+
pull_request:
9+
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI
10+
11+
# If another push to the same PR or branch happens while this workflow is still running,
12+
# cancel the earlier run in favor of the next run.
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
unit-tests:
19+
name: Unit Tests
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest]
23+
python-version: ["3.11", "3.12"]
24+
runs-on: ${{ matrix.os }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
- name: Install dependencies
32+
run: |
33+
curl -LsSf https://astral.sh/uv/install.sh | sh
34+
uv venv
35+
uv pip install -r pyproject.toml
36+
- name: Lint with ruff
37+
run: |
38+
uv pip install ruff
39+
uv run ruff check .
40+
- name: Lint with mypy
41+
run: |
42+
uv pip install mypy
43+
uv run mypy --strict src/
44+
- name: Check README spelling
45+
uses: codespell-project/actions-codespell@v2
46+
with:
47+
ignore_words_file: .codespellignore
48+
path: README.md
49+
- name: Check code spelling
50+
uses: codespell-project/actions-codespell@v2
51+
with:
52+
ignore_words_file: .codespellignore
53+
path: src/
54+
- name: Run tests with pytest
55+
run: |
56+
uv pip install pytest
57+
uv run pytest tests/unit_tests

.gitignore

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110+
.pdm.toml
111+
.pdm-python
112+
.pdm-build/
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# PyCharm
158+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160+
# and can be added to the global gitignore or merged into this file. For a more nuclear
161+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162+
#.idea/
163+
.DS_Store
164+
uv.lock

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 LangChain
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.PHONY: all 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+
# Define a variable for the test file path.
7+
TEST_FILE ?= tests/unit_tests/
8+
9+
test:
10+
python -m pytest $(TEST_FILE)
11+
12+
test_watch:
13+
python -m ptw --snapshot-update --now . -- -vv tests/unit_tests
14+
15+
test_profile:
16+
python -m pytest -vv tests/unit_tests/ --profile-svg
17+
18+
extended_tests:
19+
python -m pytest --only-extended $(TEST_FILE)
20+
21+
22+
######################
23+
# LINTING AND FORMATTING
24+
######################
25+
26+
# Define a variable for Python and notebook files.
27+
PYTHON_FILES=src/
28+
MYPY_CACHE=.mypy_cache
29+
lint: PYTHON_FILES=src
30+
format: PYTHON_FILES=.
31+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d main | grep -E '\.py$$|\.ipynb$$')
32+
lint_package: PYTHON_FILES=src
33+
lint_tests: PYTHON_FILES=tests
34+
lint_tests: MYPY_CACHE=.mypy_cache_test
35+
36+
lint lint_diff lint_package lint_tests:
37+
python -m ruff check .
38+
[ "$(PYTHON_FILES)" = "" ] || python -m ruff format $(PYTHON_FILES) --diff
39+
[ "$(PYTHON_FILES)" = "" ] || python -m ruff check --select I $(PYTHON_FILES)
40+
[ "$(PYTHON_FILES)" = "" ] || python -m mypy --strict $(PYTHON_FILES)
41+
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && python -m mypy --strict $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
42+
43+
format format_diff:
44+
ruff format $(PYTHON_FILES)
45+
ruff check --select I --fix $(PYTHON_FILES)
46+
47+
spell_check:
48+
codespell --toml pyproject.toml
49+
50+
spell_fix:
51+
codespell --toml pyproject.toml -w
52+
53+
######################
54+
# HELP
55+
######################
56+
57+
help:
58+
@echo '----'
59+
@echo 'format - run code formatters'
60+
@echo 'lint - run linters'
61+
@echo 'test - run unit tests'
62+
@echo 'tests - run unit tests'
63+
@echo 'test TEST_FILE=<test_file> - run all tests in file'
64+
@echo 'test_watch - run unit tests in watch mode'
65+

0 commit comments

Comments
 (0)