A golang-based data loader which can be used from Python. Compatible with a soon-to-be open sourced VectorDB-enabled data stack, which exposes HTTP requests.
Datago handles, outside of the Python GIL
- per sample IO from object storage
- deserialization (jpg and png decompression)
- some optional vision processing (aligning different image payloads)
- optional serialization
Samples are exposed in the Python scope as python native objects, using PIL and Numpy base types. Speed will be network dependent, but GB/s is typical.
Datago is rank and world-size aware, in which case the samples are dispatched depending on the samples hash.
Use it
from datago import datago
config = datago.GetDefaultConfig()
# Check out the config fields, plenty of option to specify your DB query and optimize performance
client = datago.GetClient(config)
client.Start() # This can be done early for convenience, not mandatory (can fetch samples while models are instanciated for intance)
for _ in range(10):
sample = client.GetSample() # This start the client if not previously done, in that case latency for the first sample is higher
Please note that the image buffers will be passed around as raw pointers, they can be re-interpreted in python with the attached helpers
See helper functions provided in polyglot.py
, should be self explanatory
Build it
$ sudo apt install golang libjpeg-turbo8-dev libvips-dev
$ sudo ldconfig
From the root of this project:
$ go build cmd/main/main.go
Running it:
$ ./main --help` will tell you all about it
Running it with additional sanity checks
$ go run -race cmd/main/main.go
From the root folder
$ go test -v tests/client_test.go
- Install the dependencies as detailed in the next point
- Run the
generate_python_package.sh
script
$ python3 -m pip install pybindgen
$ go install golang.org/x/tools/cmd/goimports@latest
$ go install github.com/go-python/gopy@latest
$ go install golang.org/x/image/draw
NOTE:
- you may need to add
~/go/bin
to your PATH so that gopy is found. -
- Either
export PATH=$PATH:~/go/bin
or add it to your .bashrc
- Either
- you may need this to make sure that LDD looks at the current folder
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
then from the /pkg folder:
$ gopy pkg -author="Photoroom" -email="[email protected]" -url="" -name="datago" -version="0.0.1" .
then you can pip install -e .
from here.
python3 setup.py sdist
python3 -m twine upload dist/* --verbose
MIT License
Copyright (c) 2024 Photoroom
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.