Skip to content

Commit

Permalink
Storing demo data in home folder instead of local
Browse files Browse the repository at this point in the history
  • Loading branch information
leopiney committed Oct 12, 2022
1 parent b2e457d commit 0fc2b5b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vectory"
version = "0.1.4"
version = "0.1.5"
description = "Streamline the benchmark and experimentation process of your models that rely on generating embeddings"
authors = ["Pento <hello@pento.ai>"]
readme = "README.md"
Expand Down Expand Up @@ -32,7 +32,7 @@ classifiers= [
"Topic :: Software Development :: Libraries",
]

include = ["docker-compose.yml", "Dockerfile", ".dockerignore", "troubleshooting.md"]
include = ["docker-compose.yml", "Dockerfile", ".dockerignore", "TROUBLESHOOTING.md"]

[tool.poetry.scripts]
vectory = "vectory.cli:app"
Expand Down
2 changes: 1 addition & 1 deletion vectory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
from .demo import download_demo_data, prepare_demo_data # noqa
from .es.client import ElasticKNNClient # noqa
from .es.utils import load_csv_with_headers, load_embeddings_from_numpy # noqa
from .experiments import Experiment
from .experiments import Experiment # noqa
from .indices import delete_index, list_indices, load_index, match_query # noqa
from .spaces import EmbeddingSpace, compare_embedding_spaces # noqa
3 changes: 2 additions & 1 deletion vectory/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from vectory.experiments import Experiment
from vectory.indices import delete_index, list_indices, load_index
from vectory.spaces import EmbeddingSpace, compare_embedding_spaces
from vectory.utils import get_vectory_dir
from vectory.visualization.run import run_streamlit

create_db_tables()
Expand Down Expand Up @@ -77,7 +78,7 @@ def demo(
),
),
data_path: Path = typer.Option(
"data/demo",
get_vectory_dir() / "demo",
"--data-path",
help="Path to the demo files",
file_okay=False,
Expand Down
10 changes: 5 additions & 5 deletions vectory/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from peewee import CharField, DateTimeField, IntegerField, Model
from playhouse.sqlite_ext import ForeignKeyField, JSONField, SqliteExtDatabase
from vectory.utils import get_vectory_dir

default_folder_path = os.path.join(os.path.expanduser("~"), ".vectory")
db_path = os.path.join(default_folder_path, "main.db")
DB_PATH = get_vectory_dir() / "main.db"


database = SqliteExtDatabase(
db_path,
DB_PATH,
pragmas={
"journal_mode": "off",
"synchronous": 0,
Expand Down Expand Up @@ -216,8 +216,8 @@ def get_knn(embedding_space_name: str, metric: str):


def create_db_tables():
if not os.path.exists(default_folder_path):
os.makedirs(default_folder_path)
if not DB_PATH.parent.exists():
os.makedirs(DB_PATH.parent, exist_ok=True)
with database:
database.create_tables(
[
Expand Down
12 changes: 3 additions & 9 deletions vectory/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from typing import List, Union

import requests
import requests # type: ignore
import typer
from vectory.datasets import Dataset
from vectory.db.models import EmbeddingSpaceModel
Expand All @@ -30,7 +30,7 @@ def download_demo_data(
) -> None:

if not os.path.isdir(data_path):
os.makedirs(data_path)
os.makedirs(data_path, exist_ok=True)

base_url = "https://github.com/pentoai/vectory/releases/download/v0.1.1/"

Expand Down Expand Up @@ -71,13 +71,7 @@ def prepare_demo_data(

dataset = Dataset.get_or_create(
name=dataset_name,
csv_path=str(
Path(__file__).parent.parent
/ "data"
/ "demo"
/ dataset_name
/ f"{dataset_name}-data.csv"
),
csv_path=str(Path(data_path) / f"{dataset_name}-data.csv"),
id_field="_idx",
)
typer.secho(f"Dataset {dataset_name} created", fg="yellow")
Expand Down
6 changes: 6 additions & 0 deletions vectory/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from pathlib import Path

from coolname import generate


def generate_name(name: str, words=3) -> str:
return "-".join([*generate(words), name])


def get_vectory_dir() -> Path:
return Path.home() / ".vectory"
8 changes: 6 additions & 2 deletions vectory/visualization/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def selection(dataset):
selected_emb_space, model=model, similarity=similarity
)

except:
except Exception:
st.warning(
"There isn't any loaded index from the embedding space "
+ f"'{selected_emb_space}', with model: '{model}' "
Expand Down Expand Up @@ -450,7 +450,11 @@ def main():
most_similar_indices_2, scores_2 = calculate_indices(
selected_vector, index_2
)
intersection = set(most_similar_indices_1) & set(most_similar_indices_1)

# intersection = (
# set(most_similar_indices_1) & set(most_similar_indices_1)
# )

col1, col2 = st.columns(2)
if df_1 is not None:

Expand Down
1 change: 0 additions & 1 deletion vectory/visualization/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from pathlib import Path

from streamlit import config
Expand Down

0 comments on commit 0fc2b5b

Please sign in to comment.