Skip to content

Commit

Permalink
Edited Makefile to use poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
willtai committed May 22, 2024
1 parent 0006408 commit 742c306
Show file tree
Hide file tree
Showing 7 changed files with 2,357 additions and 320 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: local
hooks:
- id: ruff-lint
name: Ruff Lint Check
entry: poetry run ruff format --check
language: system
types: [ python ]
stages: [ commit, push ]
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
VERSION = 0.1.2
PRODUCT = neo4j-genai-python
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXBUILD = poetry run sphinx-build
PAPER =
BUILDDIR = build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://www.sphinx-doc.org/)
# User-friendly check for sphinx-build via Poetry
ifeq ($(shell poetry run which sphinx-build >/dev/null 2>&1; echo $$?), 1)
$(error The 'sphinx-build' command was not found within the Poetry environment. Make sure Sphinx is installed in your project dependencies.)
endif

# Internal variables.
Expand Down
16 changes: 16 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Sphinx Documentation

Building the docs requires Python 3.8.1+

Ensure the dev dependencies in `pyproject.toml` are installed.

From the root directory, run the Makefile:

```
make -C docs html
```

You can now view your build locally.

When you open a PR, a TeamCity build will trigger when it's ready and someone from Neo4j
can then preview this.
14 changes: 0 additions & 14 deletions docs/source/README.md

This file was deleted.

42 changes: 41 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Performing a similarity search
from neo4j import GraphDatabase
from neo4j_genai import VectorRetriever
from langchain_openai import OpenAIEmbeddings
URI = "neo4j://localhost:7687"
AUTH = ("neo4j", "password")
Expand All @@ -71,8 +72,11 @@ Performing a similarity search
# Connect to Neo4j database
driver = GraphDatabase.driver(URI, auth=AUTH)
# Create Embedder object
embedder = OpenAIEmbeddings(model="text-embedding-3-large")
# Initialize the retriever
retriever = VectorRetriever(driver, INDEX_NAME)
retriever = VectorRetriever(driver, INDEX_NAME, embedder)
# Run the similarity search
query_text = "How do I do similarity search in Neo4j?"
Expand Down Expand Up @@ -219,6 +223,42 @@ Open a new virtual environment and then run the tests.
poetry shell
pytest
~~~~~~~~~~
Unit tests
~~~~~~~~~~

This should run out of the box once the dependencies are installed.

.. code:: bash
poetry run pytest tests/unit
~~~~~~~~~
E2E tests
~~~~~~~~~

To run e2e tests you'd need to have some services running locally:

- neo4j
- weaviate
- weaviate-text2vec-transformers

The easiest way to get it up and running is via Docker compose:

.. code:: bash
docker compose -f tests/e2e/docker-compose.yml up
.. note::

If you suspect something in the databases are cached, run `docker compose -f tests/e2e/docker-compose.yml down` to remove them completely

Once the services are running, execute the following command to run the e2e tests.

.. code:: bash
poetry run pytest tests/e2e
*******************
Further information
Expand Down
Loading

0 comments on commit 742c306

Please sign in to comment.