Skip to content

Commit

Permalink
docs(pgai): improve the development docs for the pgai library (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgpruitt authored Feb 20, 2025
1 parent 2fb399b commit 52952f0
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions projects/pgai/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
## Working on the pgai library


Note: We try to somewhat follow the python release schedule for supported versions to allow more users to use our library.
Therefore, we are about a year behind the latest python release.

### Set up your environment

The experience of working on the pgai library is like developing most Python
libraries and applications. We use [uv](https://docs.astral.sh/uv/getting-started/installation/) to manage dependencies and python versions. Once you have uv installed it's easy to get started.

Note: We try to somewhat follow the python release schedule for supported versions to allow more users to use our library.
Therefore we are about a year behind the latest python release.
Make sure your uv version is at least `0.5.x`.

```bash
uv --version
```

If not, upgrade it with this command.

```bash
uv self update
```

Change directory into the [projects/pgai](/projects/pgai) directory and create a
virtual environment. Then, activate it.

```bash
cd projects/pgai
uv venv
source .venv/bin/activate
```

Install the project's dependencies into the virtual environment.

```bash
uv sync --all-extras
```

The vectorizer worker and some tests use environment variables and can make use
of a `.env` file. Creating one may make your life easier. Include the variables
below as you see fit.

```text
OLLAMA_HOST=""
OPENAI_API_KEY=""
VOYAGE_API_KEY=""
MISTRAL_API_KEY=""
COHERE_API_KEY=""
HUGGINGFACE_API_KEY=""
AZURE_OPENAI_API_KEY=""
AZURE_OPENAI_API_BASE=""
AZURE_OPENAI_API_VERSION=""
ENABLE_VECTORIZER_TOOL_TESTS=1
```

Run the tests to verify you have a working environment.

```bash
just test
```

### Manage Python Dependencies

Uv syncs the dependencies of all developers working on the project via the uv.lock file. If you want to add a new dependency make use of the uv add command:

Expand All @@ -18,14 +73,19 @@ If it is a development dependency and not needed at runtime, you can add the --d
uv add --directory projects/pgai --dev <package-name>
```

Uv installs all dependencies inside a virtual environment by default you can either activate this via the `uv shell` command or run commands directly via `uv run`.
### Working with the project

For the most common commands use the just recipes.
We use [just](https://just.systems/man/en/) to define and run commands to work
with the project. These include tasks like building, installation, linting,
and running tests. To see a list of the available commands, run the following
from the root of the repo:

```bash
just -l pgai
```

### Testing the pgai library

Be sure to add unit tests to the [tests](./projects/pgai/tests) directory when
you add or modify code. Use the following commands to check your work before
submitting a PR.
Expand Down

0 comments on commit 52952f0

Please sign in to comment.