roboml 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roboml-0.2.0/LICENSE +21 -0
- roboml-0.2.0/PKG-INFO +125 -0
- roboml-0.2.0/README.md +85 -0
- roboml-0.2.0/pyproject.toml +104 -0
- roboml-0.2.0/setup.cfg +4 -0
- roboml-0.2.0/src/roboml/__init__.py +0 -0
- roboml-0.2.0/src/roboml/databases/__init__.py +5 -0
- roboml-0.2.0/src/roboml/databases/_base.py +166 -0
- roboml-0.2.0/src/roboml/databases/chroma.py +189 -0
- roboml-0.2.0/src/roboml/interfaces.py +137 -0
- roboml-0.2.0/src/roboml/main.py +62 -0
- roboml-0.2.0/src/roboml/models/__init__.py +13 -0
- roboml-0.2.0/src/roboml/models/_base.py +86 -0
- roboml-0.2.0/src/roboml/models/_encoding.py +70 -0
- roboml-0.2.0/src/roboml/models/llm.py +93 -0
- roboml-0.2.0/src/roboml/models/mllm.py +220 -0
- roboml-0.2.0/src/roboml/models/speech_to_text.py +72 -0
- roboml-0.2.0/src/roboml/models/text_to_speech.py +132 -0
- roboml-0.2.0/src/roboml/models/vision.py +165 -0
- roboml-0.2.0/src/roboml/ray/__init__.py +6 -0
- roboml-0.2.0/src/roboml/ray/app_factory.py +118 -0
- roboml-0.2.0/src/roboml/resp_server/server.py +278 -0
- roboml-0.2.0/src/roboml/resp_server/stream.py +63 -0
- roboml-0.2.0/src/roboml/tools/__init__.py +0 -0
- roboml-0.2.0/src/roboml/tools/download.py +103 -0
- roboml-0.2.0/src/roboml/utils.py +331 -0
- roboml-0.2.0/src/roboml.egg-info/PKG-INFO +125 -0
- roboml-0.2.0/src/roboml.egg-info/SOURCES.txt +35 -0
- roboml-0.2.0/src/roboml.egg-info/dependency_links.txt +1 -0
- roboml-0.2.0/src/roboml.egg-info/entry_points.txt +3 -0
- roboml-0.2.0/src/roboml.egg-info/requires.txt +28 -0
- roboml-0.2.0/src/roboml.egg-info/top_level.txt +1 -0
- roboml-0.2.0/tests/test_dbs.py +91 -0
- roboml-0.2.0/tests/test_download.py +41 -0
- roboml-0.2.0/tests/test_models.py +110 -0
- roboml-0.2.0/tests/test_ray.py +94 -0
- roboml-0.2.0/tests/test_resp.py +101 -0
roboml-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Automatika Robotics
|
|
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.
|
roboml-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: roboml
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Machine learning models optimized for robotics experimentation and deployment
|
|
5
|
+
Author-email: Automatika Robotics <contact@automatikarobotics.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/automatika-robotics/roboml
|
|
7
|
+
Keywords: robots,robotics,machine learning,multimodal,deep learning
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: accelerate
|
|
15
|
+
Requires-Dist: transformers
|
|
16
|
+
Requires-Dist: bitsandbytes
|
|
17
|
+
Requires-Dist: pillow
|
|
18
|
+
Requires-Dist: msgpack
|
|
19
|
+
Requires-Dist: msgpack_numpy
|
|
20
|
+
Requires-Dist: hiredis
|
|
21
|
+
Requires-Dist: ray[serve]
|
|
22
|
+
Requires-Dist: sentencepiece
|
|
23
|
+
Requires-Dist: datasets
|
|
24
|
+
Requires-Dist: scipy
|
|
25
|
+
Requires-Dist: sentence-transformers
|
|
26
|
+
Requires-Dist: chromadb
|
|
27
|
+
Requires-Dist: ninja
|
|
28
|
+
Requires-Dist: packaging
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: httpx; extra == "dev"
|
|
31
|
+
Requires-Dist: pip-tools; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest; extra == "dev"
|
|
33
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
34
|
+
Requires-Dist: black; extra == "dev"
|
|
35
|
+
Requires-Dist: redis; extra == "dev"
|
|
36
|
+
Provides-Extra: vision
|
|
37
|
+
Requires-Dist: mmengine; extra == "vision"
|
|
38
|
+
Requires-Dist: platformdirs; extra == "vision"
|
|
39
|
+
Requires-Dist: norfair; extra == "vision"
|
|
40
|
+
|
|
41
|
+
# RoboML 🤖
|
|
42
|
+
|
|
43
|
+
RoboML is an aggregator package written for quickly deploying open source ML models for robots. It is designed to cover two basic use cases.
|
|
44
|
+
|
|
45
|
+
- __Readily deploy various useful models:__ The package provides a wrapper around the 🤗 [**Transformers**](https://github.com/huggingface/transformers) and [**SentenceTransformers**](https://www.sbert.net/) libraries. Pretty much all relevant open source models from these libraries can be quickly deployed behind a highly scalable server endpoint.
|
|
46
|
+
- __Deploy Detection Models with Tracking__: With RoboML one can deploy all detection models available in [**MMDetection**](https://github.com/open-mmlab/mmdetection). An open source vision model aggregation library. These detection models can also be seemlesly used for tracking.
|
|
47
|
+
- __Use Open Source Vector DBs__: RoboML provides a unified interface for deploying Vector DBs along with ML models. Currently it is packaged with [**ChromaDB**](https://www.trychroma.com/) an open source multimodal vector database.
|
|
48
|
+
- __Aggregate robot specific ML models from the Robotics community__: RoboML aims to be an aggregator package of models trained by the robotics community. These models can range from Multimodal LLMs, vision models, or robot action models, and can be used with ROS based functional components. See the usage in [ROS Agents](https://automatika-robotics.github.io/ros-agents)
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
RoboML has been tested on Ubuntu 20.04 and later. It should ideally be installed on a system with a GPU and CUDA 12.1. However, it should work without a GPU. If you encounter any installation problems, please open an issue.
|
|
53
|
+
|
|
54
|
+
### From Source
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
git clone https://github.com/automatika-robotics/roboml.git && cd roboml
|
|
58
|
+
virtualenv venv && source venv/bin/activate
|
|
59
|
+
pip install pip-tools
|
|
60
|
+
pip install .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### For vision model support
|
|
64
|
+
|
|
65
|
+
If you want to utilize detection and tracking using Vision models from the MMDetection library, you will need to install a couple of dependancies as follows:
|
|
66
|
+
|
|
67
|
+
- Install roboml using the vision flag:
|
|
68
|
+
`pip install roboml[vision]`
|
|
69
|
+
- Install mmcv using the installation instructions provided [here](https://mmcv.readthedocs.io/en/latest/get_started/installation.html). For installation with pip, simply pick PyTorch and CUDA version that you have installed and copy the pip installation command generated.
|
|
70
|
+
- Install mmdetection as follows:
|
|
71
|
+
```shell
|
|
72
|
+
git clone https://github.com/open-mmlab/mmdetection.git
|
|
73
|
+
cd mmdetection
|
|
74
|
+
pip install -v -e .
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Build in a Docker container (Recommended)
|
|
78
|
+
|
|
79
|
+
- Install docker desktop.
|
|
80
|
+
- Install [NVIDIA toolkit for Docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
|
|
81
|
+
```shell
|
|
82
|
+
git clone https://github.com/automatika-robotics/roboml.git && cd roboml
|
|
83
|
+
docker build --tag=automatika:roboml .
|
|
84
|
+
docker run --runtime=nvidia --gpus all --rm -p 8000:8000 automatika:roboml
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Servers
|
|
88
|
+
|
|
89
|
+
By default roboml starts models as [ray serve](https://docs.ray.io/en/latest/serve/index.html) apps. Making the models scalable accross multiple infrastructure configurations. See [ray serve](https://docs.ray.io/en/latest/serve/index.html) for details.
|
|
90
|
+
|
|
91
|
+
### An Experimental Server based on RESP
|
|
92
|
+
|
|
93
|
+
When using ML models on robots, latency is a major consideration. When models are deployed on distributed infrastructure (and not on the edge, due to compute limitations), latency depends on both the model inference time and server communication time. Therefore, RoboML also implements an experimental server built using [RESP](https://github.com/antirez/RESP3) which can be accessed using any redis client. RESP is a human readable binary safe protocol, which is very simple to parse and thus can be used to implement servers significatly faster than HTTP, specially when the payloads are also packaged binary data (for example images, audio or video data). The RESP server uses msgpack a cross-platform library available in over 50 languages, to package data instead of JSON. Work on the server was inspired by earlier work of [@hansonkd](https://github.com/hansonkd) and his [Tino](https://github.com/hansonkd/Tino) project.
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
To run an HTTP server simply run the following in the terminal
|
|
98
|
+
|
|
99
|
+
`roboml`
|
|
100
|
+
|
|
101
|
+
To run an RESP based server, run
|
|
102
|
+
|
|
103
|
+
`roboml-resp`
|
|
104
|
+
|
|
105
|
+
In order to see how these servers are called from a ROS package that implements its clients, please refer to [ROS Agents](https://automatika-robotics.github.io/ros-agents) documentation.
|
|
106
|
+
|
|
107
|
+
## Running Tests
|
|
108
|
+
|
|
109
|
+
To run tests, install with:
|
|
110
|
+
|
|
111
|
+
`pip install ".[dev]"`
|
|
112
|
+
|
|
113
|
+
And run the following in the root directory
|
|
114
|
+
|
|
115
|
+
`python -m pytest`
|
|
116
|
+
|
|
117
|
+
## Copyright
|
|
118
|
+
|
|
119
|
+
The code in this distribution is Copyright (c) 2024 Automatika Robotics unless explicitly indicated otherwise.
|
|
120
|
+
|
|
121
|
+
ROS Agents is made available under the MIT license. Details can be found in the [LICENSE](LICENSE) file.
|
|
122
|
+
|
|
123
|
+
## Contributions
|
|
124
|
+
|
|
125
|
+
ROS Agents has been developed in collaboration betweeen [Automatika Robotics](https://automatikarobotics.com/) and [Inria](https://inria.fr/). Contributions from the community are most welcome.
|
roboml-0.2.0/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# RoboML 🤖
|
|
2
|
+
|
|
3
|
+
RoboML is an aggregator package written for quickly deploying open source ML models for robots. It is designed to cover two basic use cases.
|
|
4
|
+
|
|
5
|
+
- __Readily deploy various useful models:__ The package provides a wrapper around the 🤗 [**Transformers**](https://github.com/huggingface/transformers) and [**SentenceTransformers**](https://www.sbert.net/) libraries. Pretty much all relevant open source models from these libraries can be quickly deployed behind a highly scalable server endpoint.
|
|
6
|
+
- __Deploy Detection Models with Tracking__: With RoboML one can deploy all detection models available in [**MMDetection**](https://github.com/open-mmlab/mmdetection). An open source vision model aggregation library. These detection models can also be seemlesly used for tracking.
|
|
7
|
+
- __Use Open Source Vector DBs__: RoboML provides a unified interface for deploying Vector DBs along with ML models. Currently it is packaged with [**ChromaDB**](https://www.trychroma.com/) an open source multimodal vector database.
|
|
8
|
+
- __Aggregate robot specific ML models from the Robotics community__: RoboML aims to be an aggregator package of models trained by the robotics community. These models can range from Multimodal LLMs, vision models, or robot action models, and can be used with ROS based functional components. See the usage in [ROS Agents](https://automatika-robotics.github.io/ros-agents)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
RoboML has been tested on Ubuntu 20.04 and later. It should ideally be installed on a system with a GPU and CUDA 12.1. However, it should work without a GPU. If you encounter any installation problems, please open an issue.
|
|
13
|
+
|
|
14
|
+
### From Source
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
git clone https://github.com/automatika-robotics/roboml.git && cd roboml
|
|
18
|
+
virtualenv venv && source venv/bin/activate
|
|
19
|
+
pip install pip-tools
|
|
20
|
+
pip install .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### For vision model support
|
|
24
|
+
|
|
25
|
+
If you want to utilize detection and tracking using Vision models from the MMDetection library, you will need to install a couple of dependancies as follows:
|
|
26
|
+
|
|
27
|
+
- Install roboml using the vision flag:
|
|
28
|
+
`pip install roboml[vision]`
|
|
29
|
+
- Install mmcv using the installation instructions provided [here](https://mmcv.readthedocs.io/en/latest/get_started/installation.html). For installation with pip, simply pick PyTorch and CUDA version that you have installed and copy the pip installation command generated.
|
|
30
|
+
- Install mmdetection as follows:
|
|
31
|
+
```shell
|
|
32
|
+
git clone https://github.com/open-mmlab/mmdetection.git
|
|
33
|
+
cd mmdetection
|
|
34
|
+
pip install -v -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Build in a Docker container (Recommended)
|
|
38
|
+
|
|
39
|
+
- Install docker desktop.
|
|
40
|
+
- Install [NVIDIA toolkit for Docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
|
|
41
|
+
```shell
|
|
42
|
+
git clone https://github.com/automatika-robotics/roboml.git && cd roboml
|
|
43
|
+
docker build --tag=automatika:roboml .
|
|
44
|
+
docker run --runtime=nvidia --gpus all --rm -p 8000:8000 automatika:roboml
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Servers
|
|
48
|
+
|
|
49
|
+
By default roboml starts models as [ray serve](https://docs.ray.io/en/latest/serve/index.html) apps. Making the models scalable accross multiple infrastructure configurations. See [ray serve](https://docs.ray.io/en/latest/serve/index.html) for details.
|
|
50
|
+
|
|
51
|
+
### An Experimental Server based on RESP
|
|
52
|
+
|
|
53
|
+
When using ML models on robots, latency is a major consideration. When models are deployed on distributed infrastructure (and not on the edge, due to compute limitations), latency depends on both the model inference time and server communication time. Therefore, RoboML also implements an experimental server built using [RESP](https://github.com/antirez/RESP3) which can be accessed using any redis client. RESP is a human readable binary safe protocol, which is very simple to parse and thus can be used to implement servers significatly faster than HTTP, specially when the payloads are also packaged binary data (for example images, audio or video data). The RESP server uses msgpack a cross-platform library available in over 50 languages, to package data instead of JSON. Work on the server was inspired by earlier work of [@hansonkd](https://github.com/hansonkd) and his [Tino](https://github.com/hansonkd/Tino) project.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
To run an HTTP server simply run the following in the terminal
|
|
58
|
+
|
|
59
|
+
`roboml`
|
|
60
|
+
|
|
61
|
+
To run an RESP based server, run
|
|
62
|
+
|
|
63
|
+
`roboml-resp`
|
|
64
|
+
|
|
65
|
+
In order to see how these servers are called from a ROS package that implements its clients, please refer to [ROS Agents](https://automatika-robotics.github.io/ros-agents) documentation.
|
|
66
|
+
|
|
67
|
+
## Running Tests
|
|
68
|
+
|
|
69
|
+
To run tests, install with:
|
|
70
|
+
|
|
71
|
+
`pip install ".[dev]"`
|
|
72
|
+
|
|
73
|
+
And run the following in the root directory
|
|
74
|
+
|
|
75
|
+
`python -m pytest`
|
|
76
|
+
|
|
77
|
+
## Copyright
|
|
78
|
+
|
|
79
|
+
The code in this distribution is Copyright (c) 2024 Automatika Robotics unless explicitly indicated otherwise.
|
|
80
|
+
|
|
81
|
+
ROS Agents is made available under the MIT license. Details can be found in the [LICENSE](LICENSE) file.
|
|
82
|
+
|
|
83
|
+
## Contributions
|
|
84
|
+
|
|
85
|
+
ROS Agents has been developed in collaboration betweeen [Automatika Robotics](https://automatikarobotics.com/) and [Inria](https://inria.fr/). Contributions from the community are most welcome.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "roboml"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Machine learning models optimized for robotics experimentation and deployment"
|
|
9
|
+
authors = [{ name = "Automatika Robotics", email = "contact@automatikarobotics.com" }]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
]
|
|
16
|
+
keywords = ["robots", "robotics", "machine learning", "multimodal", "deep learning"]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"accelerate",
|
|
19
|
+
"transformers",
|
|
20
|
+
"bitsandbytes",
|
|
21
|
+
"pillow",
|
|
22
|
+
"msgpack",
|
|
23
|
+
"msgpack_numpy",
|
|
24
|
+
"hiredis",
|
|
25
|
+
"ray[serve]",
|
|
26
|
+
"sentencepiece",
|
|
27
|
+
"datasets",
|
|
28
|
+
"scipy",
|
|
29
|
+
"sentence-transformers",
|
|
30
|
+
"chromadb",
|
|
31
|
+
"ninja",
|
|
32
|
+
"packaging",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
requires-python = ">=3.10"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = ["httpx", "pip-tools", "pytest", "pre-commit", "black", "redis"]
|
|
39
|
+
vision = ["mmengine", "platformdirs", "norfair"]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
roboml = "roboml.main:ray"
|
|
43
|
+
roboml-resp = "roboml.main:resp"
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/automatika-robotics/roboml"
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
minversion = "6.0"
|
|
50
|
+
addopts = "-ra -q"
|
|
51
|
+
log_cli = true
|
|
52
|
+
log_cli_level = "INFO"
|
|
53
|
+
log_cli_format="[%(levelname)s] [%(asctime)s] [%(name)s] [%(process)d-%(thread)d] %(message)s"
|
|
54
|
+
testpaths = [
|
|
55
|
+
"tests"
|
|
56
|
+
]
|
|
57
|
+
markers = ["module(module_name): mark test to pass module name to fixture"]
|
|
58
|
+
|
|
59
|
+
[tool.interrogate]
|
|
60
|
+
ignore-init-method = true
|
|
61
|
+
ignore-init-module = false
|
|
62
|
+
ignore-magic = false
|
|
63
|
+
ignore-semiprivate = false
|
|
64
|
+
ignore-private = false
|
|
65
|
+
ignore-property-decorators = false
|
|
66
|
+
ignore-module = true
|
|
67
|
+
ignore-nested-functions = false
|
|
68
|
+
ignore-nested-classes = true
|
|
69
|
+
ignore-setters = false
|
|
70
|
+
exclude = ["setup.py", "docs", "build"]
|
|
71
|
+
ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"]
|
|
72
|
+
quiet = false
|
|
73
|
+
whitelist-regex = []
|
|
74
|
+
color = true
|
|
75
|
+
generate-badge = "."
|
|
76
|
+
badge-format = "svg"
|
|
77
|
+
|
|
78
|
+
[tool.ruff]
|
|
79
|
+
extend-exclude = [".mypy_cache", ".tox", ".venv", "buck-out", "build", ".pytest_cache"]
|
|
80
|
+
fix = true
|
|
81
|
+
line-length = 88
|
|
82
|
+
preview = true
|
|
83
|
+
[tool.ruff.lint]
|
|
84
|
+
ignore = ["E203", "E266", "E501", "F403", "F401"]
|
|
85
|
+
select = ["B","C","E","F","W","B9"]
|
|
86
|
+
[tool.ruff.lint.mccabe]
|
|
87
|
+
max-complexity = 10
|
|
88
|
+
|
|
89
|
+
[tool.bumpver]
|
|
90
|
+
current_version = "0.2.0"
|
|
91
|
+
version_pattern = "MAJOR.MINOR.PATCH"
|
|
92
|
+
commit_message = "(chore) bump version {old_version} -> {new_version}"
|
|
93
|
+
tag_message = "{new_version}"
|
|
94
|
+
tag_scope = "default"
|
|
95
|
+
pre_commit_hook = ""
|
|
96
|
+
post_commit_hook = ""
|
|
97
|
+
commit = true
|
|
98
|
+
tag = true
|
|
99
|
+
push = true
|
|
100
|
+
|
|
101
|
+
[tool.bumpver.file_patterns]
|
|
102
|
+
"pyproject.toml" = [
|
|
103
|
+
'version = "{version}"',
|
|
104
|
+
]
|
roboml-0.2.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from logging import Logger
|
|
3
|
+
import inspect
|
|
4
|
+
|
|
5
|
+
from pydantic import validate_call, ValidationError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from roboml.models._encoding import EncodingModel
|
|
9
|
+
from roboml.utils import Status, logging
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class VectorDBTemplate:
|
|
13
|
+
"""
|
|
14
|
+
This class describes a VectorDB template.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, *, name: str, **_):
|
|
18
|
+
"""__init__.
|
|
19
|
+
:param name:
|
|
20
|
+
:type name: str
|
|
21
|
+
:param _:
|
|
22
|
+
"""
|
|
23
|
+
self.name: str = name
|
|
24
|
+
self.encoding_model: EncodingModel
|
|
25
|
+
self.logger: Logger = logging.getLogger(self.name)
|
|
26
|
+
self.status: Status = Status.LOADED
|
|
27
|
+
|
|
28
|
+
def initialize(self, **kwargs) -> None:
|
|
29
|
+
"""
|
|
30
|
+
Calls the db initialization function and sets status accordingly
|
|
31
|
+
"""
|
|
32
|
+
if self.status == Status.READY:
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
self.status = Status.INITIALIZING
|
|
36
|
+
try:
|
|
37
|
+
validated_init = validate_call(self._initialize)
|
|
38
|
+
validated_init(**kwargs)
|
|
39
|
+
except Exception as e:
|
|
40
|
+
self.logger.error(f"Initialization Error: {e}")
|
|
41
|
+
self.status = Status.INITIALIZATION_ERROR
|
|
42
|
+
raise e
|
|
43
|
+
self.logger.info(f"{self.__class__.__name__} VectorDB initialized")
|
|
44
|
+
self.status = Status.READY
|
|
45
|
+
|
|
46
|
+
def get_status(self):
|
|
47
|
+
"""Returns status of the model node"""
|
|
48
|
+
return self.status.name
|
|
49
|
+
|
|
50
|
+
def add(self, **kwargs) -> dict:
|
|
51
|
+
"""VectorDB specific add function.
|
|
52
|
+
:param kwargs:
|
|
53
|
+
:rtype: None
|
|
54
|
+
"""
|
|
55
|
+
if self.status is not Status.READY:
|
|
56
|
+
self.logger.error("Error: DB method called before initialization")
|
|
57
|
+
raise Exception("DB Method Called called before initialization")
|
|
58
|
+
try:
|
|
59
|
+
data_model = inspect.signature(self._add).parameters["data"].annotation
|
|
60
|
+
data = data_model(**kwargs)
|
|
61
|
+
except ValidationError:
|
|
62
|
+
self.logger.error("Validation Error occured for inference input")
|
|
63
|
+
raise
|
|
64
|
+
return self._add(data)
|
|
65
|
+
|
|
66
|
+
def conditional_add(self, **kwargs) -> dict:
|
|
67
|
+
"""VectorDB specific conditional_add function.
|
|
68
|
+
:param kwargs:
|
|
69
|
+
:rtype: None
|
|
70
|
+
"""
|
|
71
|
+
if self.status is not Status.READY:
|
|
72
|
+
self.logger.error("Error: DB method called before initialization")
|
|
73
|
+
raise Exception("DB Method Called called before initialization")
|
|
74
|
+
try:
|
|
75
|
+
data_model = (
|
|
76
|
+
inspect.signature(self._conditional_add).parameters["data"].annotation
|
|
77
|
+
)
|
|
78
|
+
data = data_model(**kwargs)
|
|
79
|
+
except ValidationError:
|
|
80
|
+
self.logger.error("Validation Error occured for inference input")
|
|
81
|
+
raise
|
|
82
|
+
return self._conditional_add(data)
|
|
83
|
+
|
|
84
|
+
def metadata_query(self, **kwargs) -> dict:
|
|
85
|
+
"""VectorDB specific metadata_query function.
|
|
86
|
+
:param kwargs:
|
|
87
|
+
:rtype: None
|
|
88
|
+
"""
|
|
89
|
+
if self.status is not Status.READY:
|
|
90
|
+
self.logger.error("Error: DB method called before initialization")
|
|
91
|
+
raise Exception("DB Method Called called before initialization")
|
|
92
|
+
try:
|
|
93
|
+
data_model = (
|
|
94
|
+
inspect.signature(self._metadata_query).parameters["data"].annotation
|
|
95
|
+
)
|
|
96
|
+
data = data_model(**kwargs)
|
|
97
|
+
except ValidationError:
|
|
98
|
+
self.logger.error("Validation Error occured for inference input")
|
|
99
|
+
raise
|
|
100
|
+
return self._metadata_query(data)
|
|
101
|
+
|
|
102
|
+
def query(self, **kwargs) -> dict:
|
|
103
|
+
"""VectorDB specific query function.
|
|
104
|
+
:param kwargs:
|
|
105
|
+
:rtype: None
|
|
106
|
+
"""
|
|
107
|
+
if self.status is not Status.READY:
|
|
108
|
+
self.logger.error("Error: DB method called before initialization")
|
|
109
|
+
raise Exception("DB Method Called called before initialization")
|
|
110
|
+
try:
|
|
111
|
+
data_model = inspect.signature(self._query).parameters["data"].annotation
|
|
112
|
+
data = data_model(**kwargs)
|
|
113
|
+
except ValidationError:
|
|
114
|
+
self.logger.error("Validation Error occured for inference input")
|
|
115
|
+
raise
|
|
116
|
+
return self._query(data)
|
|
117
|
+
|
|
118
|
+
@abstractmethod
|
|
119
|
+
def _initialize(self, *_, **__) -> None:
|
|
120
|
+
"""VectorDB specific initialize function, to be implemented in derived classes.
|
|
121
|
+
:param kwargs:
|
|
122
|
+
:rtype: None
|
|
123
|
+
"""
|
|
124
|
+
raise NotImplementedError(
|
|
125
|
+
"VectorDB specific initialize method needs to be implemented by derived classes"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@abstractmethod
|
|
129
|
+
def _add(self, *_, **__) -> dict:
|
|
130
|
+
"""VectorDB specific add function, to be implemented in derived classes.
|
|
131
|
+
:param kwargs:
|
|
132
|
+
:rtype: None
|
|
133
|
+
"""
|
|
134
|
+
raise NotImplementedError(
|
|
135
|
+
"VectorDB specific add method needs to be implemented by derived classes"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
@abstractmethod
|
|
139
|
+
def _conditional_add(self, *_, **__) -> dict:
|
|
140
|
+
"""VectorDB specific conditional_add function, to be implemented in derived classes.
|
|
141
|
+
:param kwargs:
|
|
142
|
+
:rtype: None
|
|
143
|
+
"""
|
|
144
|
+
raise NotImplementedError(
|
|
145
|
+
"VectorDB specific conditional_add method needs to be implemented by derived classes"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@abstractmethod
|
|
149
|
+
def _metadata_query(self, *_, **__) -> dict:
|
|
150
|
+
"""VectorDB specific metadata_query function, to be implemented in derived classes.
|
|
151
|
+
:param kwargs:
|
|
152
|
+
:rtype: None
|
|
153
|
+
"""
|
|
154
|
+
raise NotImplementedError(
|
|
155
|
+
"VectorDB specific metadata_query method needs to be implemented by derived classes"
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@abstractmethod
|
|
159
|
+
def _query(self, *_, **__) -> dict:
|
|
160
|
+
"""VectorDB specific query function, to be implemented in derived classes.
|
|
161
|
+
:param kwargs:
|
|
162
|
+
:rtype: None
|
|
163
|
+
"""
|
|
164
|
+
raise NotImplementedError(
|
|
165
|
+
"VectorDB specific query method needs to be implemented by derived classes"
|
|
166
|
+
)
|