Skip to content

Commit f26ed25

Browse files
committed
Merge branch '45-bump-to-4.0.0' into dev
2 parents 17fb62a + ff05853 commit f26ed25

File tree

9 files changed

+114
-122
lines changed

9 files changed

+114
-122
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ jobs:
1111
matrix:
1212
os: ["ubuntu", "windows", "macos"]
1313
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] # https://devguide.python.org/versions/#versions
14-
14+
exclude:
15+
- os: "macos"
16+
python: "3.7" # Prevent "The version '3.7' with architecture 'arm64' was not found for macOS 14.4.1"
1517
runs-on: ${{ matrix.os }}-latest
1618

1719
steps:

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ObjectBox Python ChangeLog
2+
==========================
3+
4+
4.0.0 (2024-05-16)
5+
------------------
6+
7+
* ObjectBox now supports vector search ("vector database") to enable efficient similarity searches.
8+
This is particularly useful for AI/ML/RAG applications, e.g. image, audio, or text similarity.
9+
Other use cases include sematic search or recommendation engines.
10+
See https://docs.objectbox.io/ann-vector-search for details.
11+
* Queries: support for Property-based conditions and logic combinations
12+
* Convenient "Store" API deprecates ObjectBox and Builder API
13+
* New examples added, illustrating an VectorSearch and AI/RAG application
14+
* Dependency flatbuffers: Updated to 24.3.50
15+
* Adjusting the version number to match the core version (4.0); we will be aligning on major versions from now on.
16+
17+
Older Versions
18+
--------------
19+
Please check https://github.com/objectbox/objectbox-python/releases for details.

README.md

Lines changed: 64 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,56 @@
1-
ObjectBox Python API
2-
====================
3-
[ObjectBox](https://objectbox.io) is a superfast database for objects, now also available for Python (3.4+) with a simple CRUD API.
1+
ObjectBox Python
2+
================
3+
[ObjectBox](https://objectbox.io) Python is a lightweight yet powerful on-device database & vector database.
4+
Store Python objects and vectors directly with an easy-to-use CRUD API while enjoying exceptional speed and efficiency.
45
And because it's an embedded database, there's no setup required.
5-
6-
## Table of Contents:
7-
- [Getting Started](#getting-started)
8-
- [Model IDs and UIDs](#model-ids-and-uids)
9-
- [model.py](#modelpy)
10-
- [Using ObjectBox](#using-objectbox)
11-
- [Some features](#some-features)
12-
- [Coming in the future](#coming-in-the-future)
13-
- [Help wanted](#help-wanted)
14-
- [Feedback](#feedback)
15-
- [License](#license)
166

17-
---
7+
Its advanced vector search empowers AI for a variety of applications, including RAG AI, generative AI,
8+
and similarity searches.
189

19-
Getting started
20-
---------------
21-
First of all, install the latest version:
10+
Designed for high performance, the ObjectBox database runs locally on-device.
11+
As an offline-first solution, ObjectBox makes sure your app reliably works offline as well as online
12+
(via [Sync](https://objectbox.io/sync/)).
2213

23-
```bash
24-
pip install --upgrade objectbox
25-
```
26-
27-
To start using ObjectBox as a storage for your data, you need to define your model first.
28-
The model consists of Python classes annotated with `@Entity` decorator.
29-
30-
### Model IDs and UIDs
14+
_Table of Contents_
3115

32-
Each Entity has to have an ID (unique among entities).
33-
Properties need an ID as well (unique inside one Entity).
34-
Both Entities and Properties must also have an UID, which is a globally unique identifier.
35-
36-
For other ObjectBox supported languages, the binding takes care of assigning these IDs/UIDs but this feature is not yet implemented for Python.
37-
To learn more, see [ObjectBox Java documentation](https://docs.objectbox.io/advanced/meta-model-ids-and-uids)
38-
39-
#### model.py
16+
- [Feature Highlights](#feature-highlights)
17+
- [Code Example (CRUD - Create, Read, Update, Delete)](#code-example-crud---create-read-update-delete)
18+
- [Getting Started](#getting-started)
19+
- [Alpha Notes](#alpha-notes)
20+
- [Help wanted](#help-wanted)
21+
- [Feedback](#feedback)
22+
- [License](#license)
4023

41-
```python
42-
from objectbox.model import *
43-
44-
@Entity(id=1, uid=1)
45-
class Person:
46-
id = Id(id=1, uid=1001)
47-
name = Property(str, id=2, uid=1002)
48-
is_enabled = Property(bool, id=3, uid=1003)
49-
# int can be stored with 64 (default), 32, 16 or 8 bit precision.
50-
int64 = Property(int, id=4, uid=1004)
51-
int32 = Property(int, type=PropertyType.int, id=5, uid=1005)
52-
int16 = Property(int, type=PropertyType.short, id=6, uid=1006)
53-
int8 = Property(int, type=PropertyType.byte, id=7, uid=1007)
54-
# float can be stored with 64 or 32 (default) bit precision.
55-
float64 = Property(float, id=8, uid=1008)
56-
float32 = Property(float, type=PropertyType.float, id=9, uid=1009)
57-
byte_array = Property(bytes, id=10, uid=1010)
58-
# Regular properties are not stored.
59-
transient = ""
60-
```
24+
Feature Highlights
25+
------------------
6126

62-
### Using ObjectBox
27+
🏁 **On-device vector database** - for AI apps that work any place.\
28+
🏁 **High performance** - superfast response rates enabling real-time applications.\
29+
🪂 **ACID compliant** - Atomic, Consistent, Isolated, Durable.\
30+
🌱 **Scalable** - grows with your app, handling millions of objects with ease.\
31+
💚 **Sustainable** - frugal on CPU, Memory and battery / power use, reducing CO2 emissions.\
32+
💐 **[Queries](https://docs.objectbox.io/queries)** - filter data as needed, even across relations.\
33+
💻 **Multiplatform** - Get native speed on your favorite platforms.\
34+
* Linux x86-64 (64-bit)
35+
* Linux ARMv6hf (e.g. Raspberry PI Zero)
36+
* Linux ARMv7hf (e.g. Raspberry PI 3)
37+
* Linux ARMv8 (e.g. Raspberry PI 4, 5, etc.)
38+
* MacOS x86-64 and arm64 (Intel 64-bit and Apple Silicon)
39+
* Windows x86-64 (64-bit)
6340

64-
To actually use the database, you create a Store with the model you've just defined.
65-
Afterwards, you can reuse the instance (`store` in the example below) and use it to access "Entity Boxes" which hold your objects.
41+
#### Code Example (CRUD - Create, Read, Update, Delete)
6642

67-
#### program.py
43+
What does using ObjectBox in Python look like?
6844

6945
```python
7046
import objectbox
47+
7148
# from mypackage.model import Person
7249

73-
# Configure ObjectBox: should be done only once in the whole program and the "store" variable should be kept around
74-
model = objectbox.Model()
75-
model.entity(Person, last_property_id=objectbox.model.IdUid(10, 1010))
76-
model.last_entity_id = objectbox.model.IdUid(1, 1)
50+
# The ObjectBox Store represents a database; keep it around...
7751
store = objectbox.Store(model=model)
7852

79-
# Open the box of "Person" entity. This can be called many times but you can also pass the variable around
53+
# Get a box for the "Person" entity; a Box is the main interaction point with objects and the database.
8054
box = store.box(Person)
8155

8256
person = Person()
@@ -88,65 +62,46 @@ box.put(person) # Update
8862
box.remove(person) # Delete
8963
```
9064

91-
Additionally, see the [TaskList example app](https://github.com/objectbox/objectbox-python/tree/main/example). After checking out this repository to run the example:
65+
Getting started
66+
---------------
67+
Latest version: 4.0.0a0 (2024-05-15)
68+
69+
To install or update the latest version of ObjectBox, run this:
70+
71+
```bash
72+
pip install --upgrade --pre objectbox # "--pre" because you want to get the 4.0.0 alpha version
9273
```
93-
// Set up virtual environment, download ObjectBox libraries
94-
make depend
74+
Now you are ready to use ObjectBox in your Python project.
9575

96-
// Activate virtual environment...
97-
// ...on Linux
98-
source .venv/bin/activate
99-
// ...on Windows
100-
.venv\Scripts\activate
76+
Head over to the **[ObjectBox documentation](https://docs.objectbox.io)**
77+
and learn how to setup your first entity classes.
10178

102-
// Run the example
103-
python3 -m example
79+
### Examples
10480

105-
// Once done, leave the virtual environment
106-
deactivate
107-
```
81+
Do you prefer to dive right into working examples?
82+
We have you covered in the [example](example/) folder.
83+
It comes with a task list application and a vector search example using cities.
84+
Additionally, for AI enthusiasts, we provide an "ollama" example,
85+
which integrates a local LLM (via [ollama](https://ollama.com))
86+
with ObjectBox to manage and search embeddings effectively.
10887

109-
For more information and code examples, see the tests folder. The docs for other languages may also help you understand the basics.
110-
111-
* ObjectBox Java/Dart/Flutter - https://docs.objectbox.io
112-
* ObjectBox Go - https://golang.objectbox.io
113-
* ObjectBox Swift - https://swift.objectbox.io
114-
115-
Some features
116-
-------------
117-
* Automatic transactions (ACID compliant)
118-
* Bulk operations
119-
* Vector types, e.g. for AI vector embeddings
120-
* Platforms supported with native speed:
121-
* Linux x86-64 (64-bit)
122-
* Linux ARMv6hf (e.g. Raspberry PI Zero)
123-
* Linux ARMv7hf (e.g. Raspberry PI 3; available only on request)
124-
* Linux ARMv8 (e.g. Raspberry PI 4)
125-
* MacOS x86-64 and arm64 (Intel 64-bit and Apple Silicon)
126-
* Windows x86-64 (64-bit)
127-
128-
Coming in the future
129-
--------------------
130-
The goodness you know from the other ObjectBox language-bindings, e.g.,
131-
132-
* model management (no need to manually set id/uid)
133-
* automatic model migration (no schema upgrade scripts etc.)
134-
* powerful queries
135-
* relations (to-one, to-many)
136-
* asynchronous operations
137-
* secondary indexes
88+
Alpha Notes
89+
-----------
90+
While ObjectBox Python is powered by a rock stable core written in C/C++, we label our Python binding still "alpha."
91+
We do this to manage expectations as some quality of life improvements are yet to come to our Python binding.
92+
This is mostly about "model management," which still requires you to do some manual coding setup, e.g. for model IDs.
93+
The final release will take care of this for you automatically.
13894

13995
Help wanted
14096
-----------
141-
ObjectBox for Python is still in an early stage with limited feature set (compared to our other supported languages).
142-
To bring all these features to Python, we're asking the community to help out. PRs are more than welcome!
97+
ObjectBox for Python is open to contributions.
14398
The ObjectBox team will try its best to guide you and answer questions.
14499
See [CONTRIBUTING.md](https://github.com/objectbox/objectbox-python/blob/main/CONTRIBUTING.md) to get started.
145100

146101
Feedback
147102
--------
148-
Also, please let us know your feedback by opening an issue: for example, if you experience errors or if you have ideas
149-
for how to improve the API. Thanks!
103+
We are looking for your feedback!
104+
Please let us know what you think about ObjectBox for Python and how we can improve it.
150105

151106
License
152107
-------

download-c-lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Script used to download objectbox-c shared libraries for all supported platforms. Execute by running `make get-lib`
77
# on first checkout of this repo and any time after changing the objectbox-c lib version.
88

9-
version = "v0.21.1-alpha5" # see objectbox/c.py required_version
9+
version = "v4.0.0" # see objectbox/c.py required_version
1010
variant = 'objectbox' # or 'objectbox-sync'
1111

1212
base_url = "https://github.com/objectbox/objectbox-c/releases/download/"

example/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
# ObjectBox-Python Examples
22

3-
The following examples are available from this repository.
3+
This directory contains a couple of examples that demonstrate capabilities of ObjectBox using the Python API.
4+
5+
As we are currently short before releasing 4.0 version, please install the pre-release version of `objectbox` from PyPI via `pip`; for example, on UN*X-flavour platforms:
6+
7+
```shell
8+
cd example # assuming you are in project root dir
9+
python3 -m venv venv
10+
source venv/bin/activate
11+
pip install --pre objectbox
12+
```
13+
14+
The following examples are available from this directory:
15+
16+
- `tasks`: CRUD Application Example (see below for details)
17+
- `vectorsearch-cities`: VectorSearch Application Example (see below for details)
18+
- `ollama`: LLM + VectorSearch Embeddings Script Example (See [ollama/README.md](./ollama/README.md) for details)
19+
420

521
## Application Example: Tasks
622

723
This is our classic Tasks application using a CLI.
824

925
```
10-
cd example
11-
python -m tasks
26+
$ python -m tasks
1227
1328
Welcome to the ObjectBox tasks-list app example. Type help or ? for a list of commands.
1429
> new buy oat
@@ -36,7 +51,8 @@ This example application starts with a pre-defined set of capital cities and the
3651
It allows to search for nearest neighbors of a city (`city_neighbors`) or by coordinates (`neighbors`) as well as adding more locations (`add`).
3752

3853
```
39-
python -m vectorsearch-cities
54+
$ python -m vectorsearch-cities
55+
4056
Welcome to the ObjectBox vectorsearch-cities example. Type help or ? for a list of commands.
4157
> ls
4258
ID Name Latitude Longitude

example/vectorsearch-cities/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, *args):
2424
dbdir = "cities-db"
2525
new_db = not os.path.exists(dbdir)
2626
self._store = objectbox.Store(model=get_objectbox_model(),directory=dbdir)
27-
self._box = _store.box(City)
27+
self._box = self._store.box(City)
2828
self._name_prop: Property = City.get_property("name")
2929
self._location_prop: Property = City.get_property("location")
3030
if new_db:

objectbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
]
3535

3636
# Python binding version
37-
version = Version(0, 7, 0, alpha=14)
37+
version = Version(4, 0, 0, alpha=0)
3838

3939

4040
def version_info():

objectbox/c.py

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

2828
# Version of the library used by the binding. This version is checked at runtime to ensure binary compatibility.
2929
# Don't forget to update download-c-lib.py when upgrading to a newer version.
30-
required_version = "0.21.0"
30+
required_version = "4.0.0"
3131

3232

3333
def shlib_name(library: str) -> str:

tests/test_basics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717

1818
def test_version():
19-
assert objectbox.version.major == 0 # update for major version changes
20-
assert objectbox.version.minor >= 6
19+
assert objectbox.version.major == 4 # update for major version changes
20+
assert objectbox.version.minor >= 0
2121

22-
assert objectbox.version_core.major == 0 # update for major version changes
23-
assert objectbox.version_core.minor >= 21
22+
assert objectbox.version_core.major == 4 # update for major version changes
23+
assert objectbox.version_core.minor >= 0
2424

2525
info = objectbox.version_info()
2626
print("\nVersion found:", info)

0 commit comments

Comments
 (0)