Skip to content

Commit 79e756d

Browse files
authored
chore: switch to uv packaging (#10)
2 parents 6ed4b17 + 81e7974 commit 79e756d

Some content is hidden

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

62 files changed

+2923
-264
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ jobs:
1616
contents: read
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/setup-python@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v2
22+
with:
23+
version: "0.4.10"
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
2027
with:
2128
python-version: "3.10"
2229

@@ -26,11 +33,13 @@ jobs:
2633
path: ~/.cache/pre-commit
2734
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
2835

29-
- name: Install pre-commit
30-
run: pip3 install pre-commit
36+
- name: Install Dependencies
37+
run: source ./setup_dev_env.sh
3138

3239
- name: Run pre-commit checks
33-
run: pre-commit run --all-files --show-diff-on-failure --color always
40+
run: |
41+
source .venv/bin/activate
42+
pre-commit run --all-files --show-diff-on-failure --color always
3443
3544
- name: Run Trivy vulnerability scanner
3645
uses: aquasecurity/trivy-action@master
@@ -57,17 +66,14 @@ jobs:
5766
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5867
comment_tag: trivy
5968

60-
- name: Create venv
61-
run: . ./setup_dev_env.sh
62-
6369
- name: Check licenses
6470
run: |
65-
source venv/bin/activate
71+
source .venv/bin/activate
6672
./check_licenses.sh
6773
6874
- name: Generate pip freeze
6975
run: |
70-
source venv/bin/activate
76+
source .venv/bin/activate
7177
pip freeze > requirements-freeze.txt
7278
7379
- name: Publish Artefacts
@@ -93,9 +99,8 @@ jobs:
9399

94100
- name: Validate package build
95101
run: |
96-
source venv/bin/activate
97-
python -m pip install -U build
98-
for dir in packages/*/; do python -m build "$dir"; done
102+
source .venv/bin/activate
103+
for dir in packages/*/; do uv build "$dir" --out-dir dist; done
99104
100105
- name: Publish Package
101106
uses: actions/upload-artifact@v3
@@ -121,6 +126,12 @@ jobs:
121126
- python-version: "3.10"
122127
steps:
123128
- uses: actions/checkout@v4
129+
130+
- name: Install uv
131+
uses: astral-sh/setup-uv@v2
132+
with:
133+
version: "0.4.10"
134+
124135
- name: Set up Python ${{ matrix.python-version }}
125136
uses: actions/setup-python@v4
126137
with:
@@ -129,18 +140,18 @@ jobs:
129140
- name: Cache Dependencies
130141
uses: actions/cache@v3
131142
with:
132-
path: ~/.cache/pip
133-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }}-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/pyproject.toml') }}
143+
path: ~/.cache/uv
144+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
134145
restore-keys: |
135146
${{ runner.os }}-pip-
136147
137148
- name: Install Dependencies
138-
run: . ./setup_dev_env.sh
149+
run: source ./setup_dev_env.sh
139150

140151
- name: Run Tests With Coverage
141152
run: |
142153
# run with coverage to not execute tests twice
143-
source venv/bin/activate
154+
source .venv/bin/activate
144155
coverage run -m pytest -v -p no:warnings --junitxml=report.xml
145156
coverage report
146157
coverage xml

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
# ragbits
1+
# Ragbits
22

33
Repository for internal experiment with our upcoming LLM framework.
44

5+
# Installation
56

6-
# Setup developer environment
7+
## Build from source
78

8-
To start, you need to setup your local machine.
9+
To build and run Ragbits from the source code:
910

10-
## Setup venv
11-
12-
You need to setup virtual environment, simplest way is to run from project root directory:
11+
1. Requirements: [**uv**](https://docs.astral.sh/uv/getting-started/installation/) & [**python**](https://docs.astral.sh/uv/guides/install-python/) 3.10 or higher
12+
2. Install dependencies and run venv in editable mode:
1313

1414
```bash
15-
$ . ./setup_dev_env.sh
16-
$ source venv/bin/activate
15+
$ source ./setup_dev_env.sh
1716
```
18-
This will create a new venv and install all packages from this repository in editable mode.
19-
It will also intall their dependencies and the dev dependencies from `requirements-dev.txt`.
2017

2118
## Install pre-commit
2219

check_licenses.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -e
33

4-
. venv/bin/activate
4+
source .venv/bin/activate
55

6-
pip-licenses --from=mixed --ignore-packages `cat .libraries-whitelist.txt`> licenses.txt
6+
uv run pip-licenses --from=mixed --ignore-packages `cat .libraries-whitelist.txt`> licenses.txt
77
cat licenses.txt
88

99
FOUND=$(tail -n +2 licenses.txt | grep -v -f .license-whitelist.txt | wc -l)

docker/precommit/Dockerfile

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/ragbits-common/pyproject.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/ragbits-common/setup.cfg

Lines changed: 0 additions & 53 deletions
This file was deleted.

packages/ragbits-common/src/ragbits/common/prompt/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/ragbits-core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ragbits Core

packages/ragbits-common/examples/llm_example.py renamed to packages/ragbits-core/examples/llm_example.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "ragbits[litellm]",
5+
# ]
6+
# ///
17
import asyncio
28

39
from pydantic import BaseModel
410

5-
from ragbits.common.llms.litellm import LiteLLM
6-
from ragbits.common.prompt import Prompt
11+
from ragbits.core.llms.litellm import LiteLLM
12+
from ragbits.core.prompt import Prompt
713

814

915
class LoremPromptInput(BaseModel):

packages/ragbits-common/examples/prompt_example.py renamed to packages/ragbits-core/examples/prompt_example.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "ragbits",
5+
# ]
6+
# ///
17
from pydantic import BaseModel
28

3-
from ragbits.common.prompt import Prompt
9+
from ragbits.core.prompt import Prompt
410

511

612
class LoremPromptInput(BaseModel):

packages/ragbits-core/pyproject.toml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[project]
2+
name = "ragbits"
3+
version = "0.1.0"
4+
description = "Building blocks for rapid development of GenAI applications"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
license = "MIT"
8+
authors = [
9+
{ name = "deepsense.ai", email = "contact@deepsense.ai"}
10+
]
11+
keywords = [
12+
"Retrieval Augmented Generation",
13+
"RAG",
14+
"Large Language Models",
15+
"LLMs",
16+
"Generative AI",
17+
"GenAI",
18+
"Prompt Management"
19+
]
20+
classifiers = [
21+
"Development Status :: 1 - Planning",
22+
"Environment :: Console",
23+
"Intended Audience :: Science/Research",
24+
"License :: OSI Approved :: MIT License",
25+
"Natural Language :: English",
26+
"Operating System :: OS Independent",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
31+
"Topic :: Software Development :: Libraries :: Python Modules",
32+
"Private :: Do Not Upload"
33+
]
34+
dependencies = [
35+
"jinja2>=3.1.4",
36+
"pydantic>=2.9.1"
37+
]
38+
39+
[project.optional-dependencies]
40+
litellm = [
41+
"litellm~=1.46.0",
42+
]
43+
local = [
44+
"torch~=2.2.1",
45+
"transformers~=4.44.2",
46+
"numpy~=1.24.0"
47+
]
48+
49+
[tool.uv]
50+
dev-dependencies = [
51+
"pre-commit~=3.8.0",
52+
"pytest~=8.3.3",
53+
"pytest-cov~=5.0.0",
54+
"pytest-asyncio~=0.24.0",
55+
"pip-licenses>=4.0.0,<5.0.0"
56+
]
57+
58+
[build-system]
59+
requires = ["hatchling"]
60+
build-backend = "hatchling.build"
61+
62+
[tool.hatch.metadata]
63+
allow-direct-references = true
64+
65+
[tool.hatch.build.targets.wheel]
66+
packages = ["src/ragbits"]
67+
68+
[tool.pytest.ini_options]
69+
asyncio_mode = "auto"

packages/ragbits-common/src/ragbits/common/embeddings/litellm.py renamed to packages/ragbits-core/src/ragbits/core/embeddings/litellm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
except ImportError:
88
HAS_LITELLM = False
99

10-
from ragbits.common.embeddings.base import Embeddings
11-
from ragbits.common.embeddings.exceptions import EmbeddingConnectionError, EmbeddingResponseError, EmbeddingStatusError
10+
from ragbits.core.embeddings.base import Embeddings
11+
from ragbits.core.embeddings.exceptions import EmbeddingConnectionError, EmbeddingResponseError, EmbeddingStatusError
1212

1313

1414
class LiteLLMEmbeddings(Embeddings):

packages/ragbits-common/src/ragbits/common/llms/base.py renamed to packages/ragbits-core/src/ragbits/core/llms/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from functools import cached_property
33
from typing import Generic, Optional, Type, cast, overload
44

5-
from ragbits.common.prompt.base import BasePrompt, BasePromptWithParser, OutputT
5+
from ragbits.core.prompt.base import BasePrompt, BasePromptWithParser, OutputT
66

77
from .clients.base import LLMClient, LLMClientOptions, LLMOptions
88

packages/ragbits-common/src/ragbits/common/llms/clients/base.py renamed to packages/ragbits-core/src/ragbits/core/llms/clients/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pydantic import BaseModel
66

7-
from ragbits.common.prompt import ChatFormat
7+
from ragbits.core.prompt import ChatFormat
88

99
from ..types import NotGiven
1010

packages/ragbits-common/src/ragbits/common/llms/clients/litellm.py renamed to packages/ragbits-core/src/ragbits/core/llms/clients/litellm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
HAS_LITELLM = False
1212

1313

14-
from ragbits.common.prompt import ChatFormat
14+
from ragbits.core.prompt import ChatFormat
1515

1616
from ..types import NOT_GIVEN, NotGiven
1717
from .base import LLMClient, LLMOptions

packages/ragbits-common/src/ragbits/common/llms/clients/local.py renamed to packages/ragbits-core/src/ragbits/core/llms/clients/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
except ImportError:
1212
HAS_LOCAL_LLM = False
1313

14-
from ragbits.common.prompt import ChatFormat
14+
from ragbits.core.prompt import ChatFormat
1515

1616
from ..types import NOT_GIVEN, NotGiven
1717
from .base import LLMClient, LLMOptions

packages/ragbits-common/src/ragbits/common/llms/litellm.py renamed to packages/ragbits-core/src/ragbits/core/llms/litellm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
HAS_LITELLM = False
1010

11-
from ragbits.common.prompt.base import BasePrompt
11+
from ragbits.core.prompt.base import BasePrompt
1212

1313
from .base import LLM
1414
from .clients.litellm import LiteLLMClient, LiteLLMOptions

packages/ragbits-common/src/ragbits/common/llms/local.py renamed to packages/ragbits-core/src/ragbits/core/llms/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
HAS_LOCAL_LLM = False
1010

11-
from ragbits.common.prompt.base import BasePrompt
11+
from ragbits.core.prompt.base import BasePrompt
1212

1313
from .base import LLM
1414
from .clients.local import LocalLLMClient, LocalLLMOptions

0 commit comments

Comments
 (0)