Skip to content

Commit a429ec3

Browse files
authored
Enable Quarto rendering for docs and reference (#51)
* Enable Quarto rendering for docs and reference This enabled quarto for reference docs and in-repo documentation and examples * Default c++ unit tests to disabled for python setup * Add missing pyyaml package * Add missing click package * WIP: Temp allow pushing docs on this branch * Update doc strings * Formatting * Add index * Adjust README and repo rename * Initial installation and building docs * Minor updates * Re-enable limiting to main * Clean up, remove duplication
1 parent 38d236a commit a429ec3

File tree

24 files changed

+784
-67
lines changed

24 files changed

+784
-67
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Cloned from https://github.com/TileDB-Inc/tiledb-quarto-template
2+
3+
name: Render and deploy Quarto files
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
quarto-render-and-deploy:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest]
13+
python-version: ["3.9"]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Install OpenBLAS
17+
run: sudo apt install libopenblas-dev
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Print Python version
23+
run: |
24+
which python
25+
which pip
26+
python --version
27+
- name: Install pybind11
28+
run: pip install "pybind11[global]"
29+
- uses: actions/checkout@v3
30+
- name: Install
31+
run: cd apis/python && pip install .
32+
33+
- name: "Install Quarto"
34+
uses: quarto-dev/quarto-actions/setup@v2
35+
36+
- name: "Quarto render"
37+
shell: bash
38+
run: |
39+
pip install quartodoc PyYAML click
40+
# create a symlink to the tiledbvcf python package, so it doesn't have to be installed
41+
#ln -s apis/python/src/tiledb/vector_search
42+
quartodoc build
43+
quarto render --fail-if-warnings
44+
# https://github.com/quarto-dev/quarto-cli/issues/493
45+
46+
- name: "Deploy to gh-pages"
47+
uses: peaceiris/actions-gh-pages@v3
48+
# Change to the name of your repo's primary branch name:
49+
if: github.ref == 'refs/heads/main'
50+
with:
51+
# This is GitHub Actions magic; no secrets for us to manage; and this works first-time
52+
# without any extra configs other than visiting Settings -> Pages in your GitHub repo.
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
publish_dir: docs
55+
destination_dir: docs

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ apis/python/.mypy_cache/
9494
.idea
9595
apis/python/src/tiledb/vector_search/version.py
9696
_skbuild
97+
98+
# Quarto dev-cache
99+
/.quarto/
100+
docs/.quarto
101+
102+
documentation/reference/*
103+
documentation/reference

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
TileDB vector similarity search
1+
<a href="https://tiledb.com"><img src="https://github.com/TileDB-Inc/TileDB/raw/dev/doc/source/_static/[email protected]" alt="TileDB logo" width="400"></a>
2+
3+
4+
5+
# TileDB Vector Search
6+
7+
*TileDB-Vector-Search* is a C++ library and Python interface to Vector Search built onto of the [TileDB Storage Engine](https://github.com/TileDB-Inc/TileDB).
8+
9+
# Quick Links
10+
11+
* [Installation](https://tiledb-inc.github.io/tiledb-vector-search/documentation/Installation.html)
12+
* [Build Instructions](https://tiledb-inc.github.io/TileDB-Vector-Search/documentation/Building.html)
13+
* [TileDB Documentation](https://tiledb-inc.github.io/TileDB-Vector-Search/)
14+
* [Python API reference](https://tiledb-inc.github.io/TileDB-Vector-Search/documentation/reference/)
15+
16+
# Quick Installation
17+
18+
TileDB-Vector-Search is available from either [PyPI](https://pypi.org/project/tiledb-vector-search/) with ``pip``:
19+
20+
```
21+
pip install tiledb-vector-search
22+
```
23+
24+
or from [conda-forge](https://anaconda.org/conda-forge/tiledb-vector-searcg) with
25+
[conda](https://conda.io/docs/) or [mamba](https://github.com/mamba-org/mamba#installation):
26+
27+
```
28+
conda install -c tiledb tiledb-vector-search
29+
```
30+
31+
# Contributing
32+
33+
We welcome contributions, please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for suggestions and
34+
development-build instructions. For larger features, please open an issue to discuss goals and
35+
approach in order to ensure a smooth PR integration and review process.

_quarto.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Cloned from https://github.com/TileDB-Inc/tiledb-quarto-template
2+
project:
3+
type: website
4+
output-dir: docs
5+
render:
6+
# The first item will be the landing page
7+
- "documentation/index.md"
8+
- "documentation"
9+
- "documentation/reference"
10+
- "examples/README.md"
11+
- "examples"
12+
13+
format:
14+
html:
15+
# https://quarto.org/docs/output-formats/page-layout.html#grid-customization
16+
grid:
17+
sidebar-width: 350px
18+
body-width: 1000px
19+
margin-width: 350px
20+
gutter-width: 1rem
21+
toc: true
22+
theme:
23+
light: [flatly, "quarto-materials/tiledb.scss"]
24+
mainfont: Helvetica
25+
fontsize: 1rem
26+
linkcolor: "#4d9fff"
27+
code-copy: true
28+
code-overflow: wrap
29+
css: "quarto-materials/tiledb.css"
30+
31+
quartodoc:
32+
title: "Python"
33+
package: tiledb.vector_search
34+
dir: "documentation/reference"
35+
sections:
36+
- title: "tiledb.vector_search"
37+
desc: ""
38+
contents:
39+
- index.Index
40+
- index.FlatIndex
41+
- index.IVFFlatIndex
42+
- ingestion
43+
44+
website:
45+
favicon: "documentation/assets/tiledb.ico"
46+
site-url: https://tiledb-inc.github.io/TileDB-Vector-Search/
47+
repo-url: https://github.com/TileDB-Inc/TileDB-Vector-Search
48+
# You may want one or both of these, or neither:
49+
repo-actions: [edit, issue]
50+
page-navigation: true
51+
navbar:
52+
background: light
53+
logo: "quarto-materials/tiledb-logo.png"
54+
collapse-below: lg
55+
left:
56+
- text: "Home page"
57+
href: "https://tiledb.com"
58+
- text: "Login"
59+
href: "https://cloud.tiledb.com/auth/login"
60+
- text: "Contact us"
61+
href: "https://tiledb.com/contact"
62+
- text: "Repo"
63+
href: "https://github.com/TileDB-Inc/TileDB-Vector-Search"
64+
65+
sidebar:
66+
- style: "floating"
67+
collapse-level: 2
68+
align: left
69+
contents:
70+
- href: "documentation/index.md"
71+
- href: "documentation/Building.md"
72+
73+
# - section: "Examples"
74+
# contents:
75+
# # - href: "examples/overview.md"
76+
77+
# - section: "Ingestion"
78+
# contents:
79+
# # - href: "documentation/ingestion/overview.md"
80+
81+
- section: "API Reference"
82+
contents:
83+
- href: "documentation/reference/index.qmd"

apis/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test = ["pytest"]
2828

2929
[project.urls]
3030
homepage = "https://tiledb.com"
31-
repository = "https://github.com/TileDB-Inc/feature-vector-prototype"
31+
repository = "https://github.com/TileDB-Inc/tiledb-vector-search"
3232

3333
[build-system]
3434
requires = [

apis/python/setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import os
2+
13
from skbuild import setup # This line replaces 'from setuptools import setup'
24

3-
import os
45

56
def get_cmake_overrides():
6-
import sys
77

88
conf = list()
99

@@ -23,9 +23,8 @@ def get_cmake_overrides():
2323
conf.append("-DCMAKE_BUILD_TYPE={}".format(val))
2424

2525
key = "BUILD_TESTS"
26-
val = os.environ.get(key, default=None)
27-
if val:
28-
conf.append("-DBUILD_TESTS={}".format(val))
26+
val = os.environ.get(key, default="OFF")
27+
conf.append("-DBUILD_TESTS={}".format(val))
2928

3029
key = "USE_MKL_CBLAS"
3130
val = os.environ.get(key, default=None)
@@ -34,6 +33,7 @@ def get_cmake_overrides():
3433

3534
return conf
3635

36+
3737
cmake_args = ["-DTILEDB_VS_PYTHON=ON"]
3838

3939
cmake_args += get_cmake_overrides()
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
from .index import FlatIndex
22
from .ingestion import ingest
3-
from .module import load_as_array, load_as_matrix, query_vq
3+
from .module import load_as_array
4+
from .module import load_as_matrix
5+
from .module import query_vq
46

5-
__all__ = ["FlatIndex", "load_as_array", "load_as_matrix", "ingest", "query_vq", "query_kmeans"]
7+
__all__ = [
8+
"FlatIndex",
9+
"load_as_array",
10+
"load_as_matrix",
11+
"ingest",
12+
"query_vq",
13+
"query_kmeans",
14+
]

apis/python/src/tiledb/vector_search/index.py

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
import numpy as np
4+
45
from tiledb.vector_search.module import *
56

67

@@ -10,17 +11,50 @@ def query(self, targets: np.ndarray, k=10, nqueries=10, nthreads=8, nprobe=1):
1011

1112

1213
class FlatIndex(Index):
13-
def __init__(self,
14-
uri,
15-
dtype: np.dtype,
16-
parts_name="parts.tdb"):
14+
"""
15+
Open a flat index
16+
17+
Parameters
18+
----------
19+
uri: str
20+
URI of datataset
21+
dtype: numpy.dtype
22+
datatype float32 or uint8
23+
parts_name: str
24+
Optional name of partitions
25+
"""
26+
27+
def __init__(self, uri: str, dtype: np.dtype, parts_name: str = "parts.tdb"):
1728
self.uri = uri
1829
self.dtype = dtype
1930
self._index = None
2031

2132
self._db = load_as_matrix(os.path.join(uri, parts_name))
2233

23-
def query(self, targets: np.ndarray, k=10, nqueries=10, nthreads=8, nprobe=1):
34+
def query(
35+
self,
36+
targets: np.ndarray,
37+
k: int = 10,
38+
nqueries: int = 10,
39+
nthreads: int = 8,
40+
nprobe: int = 1,
41+
):
42+
"""
43+
Open a flat index
44+
45+
Parameters
46+
----------
47+
targets: numpy.ndarray
48+
ND Array of query targets
49+
k: int
50+
Number of top results to return per target
51+
nqueries: int
52+
Number of queries
53+
nthreads: int
54+
Number of threads to use for queyr
55+
nprobe: int
56+
number of probes
57+
"""
2458
# TODO:
2559
# - typecheck targets
2660
# - don't copy the array
@@ -39,9 +73,18 @@ def query(self, targets: np.ndarray, k=10, nqueries=10, nthreads=8, nprobe=1):
3973

4074

4175
class IVFFlatIndex(Index):
42-
def __init__(self,
43-
uri,
44-
dtype: np.dtype):
76+
"""
77+
Open a IVF Flat index
78+
79+
Parameters
80+
----------
81+
uri: str
82+
URI of datataset
83+
dtype: numpy.dtype
84+
datatype float32 or uint8
85+
"""
86+
87+
def __init__(self, uri, dtype: np.dtype):
4588
self.parts_db_uri = os.path.join(uri, "parts.tdb")
4689
self.centroids_uri = os.path.join(uri, "centroids.tdb")
4790
self.index_uri = os.path.join(uri, "index.tdb")
@@ -55,6 +98,22 @@ def __init__(self,
5598
# self._ids = load_as_matrix(self.ids_uri)
5699

57100
def query(self, targets: np.ndarray, k=10, nqueries=10, nthreads=8, nprobe=1):
101+
"""
102+
Open a flat index
103+
104+
Parameters
105+
----------
106+
targets: numpy.ndarray
107+
ND Array of query targets
108+
k: int
109+
Number of top results to return per target
110+
nqueries: int
111+
Number of queries
112+
nthreads: int
113+
Number of threads to use for queyr
114+
nprobe: int
115+
number of probes
116+
"""
58117
assert targets.dtype == np.float32
59118

60119
# TODO: use Matrix constructor from py::array

0 commit comments

Comments
 (0)