Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Check if url is an HTTP URL #12

Closed
wants to merge 32 commits into from
Closed
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
50cee3b
feat: Check if url is an HTTP URL
juancarlospaco Nov 3, 2024
ee7e03f
feat: Check if url is an HTTP URL
juancarlospaco Nov 3, 2024
1cdc5c3
feat: Check if url is an HTTP URL
juancarlospaco Nov 3, 2024
e31d139
Merge branch 'main' into fix2
juancarlospaco Nov 11, 2024
4b665c1
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
1e4b09c
Merge branch 'fix2' of https://github.com/supabase-community/vec2pg i…
juancarlospaco Nov 11, 2024
818a4f3
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
cc6ce69
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
7d003f6
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
c5da757
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
34970bb
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
25e97e5
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
917689a
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
523e975
feat: Check if url is an HTTP URL
juancarlospaco Nov 11, 2024
a2c06ca
fix: improve a test
juancarlospaco Dec 11, 2024
b2e33a1
fix: improve a test
juancarlospaco Dec 11, 2024
dbf828b
fix: improve a test
juancarlospaco Dec 11, 2024
1abd60d
fix: improve a test
juancarlospaco Dec 11, 2024
23d6e01
fix: improve a test
juancarlospaco Dec 11, 2024
5a9429a
fix: improve a test
juancarlospaco Dec 11, 2024
7ab4c2b
fix: improve a test
juancarlospaco Dec 11, 2024
6db225b
fix: improve a test
juancarlospaco Dec 11, 2024
661bea9
fix: improve a test
juancarlospaco Dec 11, 2024
7256295
fix: improve a test
juancarlospaco Dec 11, 2024
8a98fe4
fix: improve a test
juancarlospaco Dec 11, 2024
6ad88fd
fix: improve a test
juancarlospaco Dec 11, 2024
d820883
fix: improve a test
juancarlospaco Dec 11, 2024
f3a31b9
fix: improve a test
juancarlospaco Dec 11, 2024
c5fdcec
fix: improve a test
juancarlospaco Dec 11, 2024
3bb41fc
fix: improve a test
juancarlospaco Dec 11, 2024
9780ea2
fix: improve a test
juancarlospaco Dec 11, 2024
e48be75
fix: improve a test
juancarlospaco Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
matrix:
# Max 4 Python versions here, because error:
# "Reached max indexes allowed (5). To add more indexes, upgrade your plan."
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.11", "3.12", "3.13"]

services:
postgres:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ psycopg = "^3.1.19"
parse = "^1.20.2"
pgvector = "^0.2.5"
numpy = "^2.0.0"
qdrant-client = "^1.10.1"
qdrant-client = "^1.12.1"
typer = "^0.12.3"

[tool.poetry.dev-dependencies]
6 changes: 6 additions & 0 deletions src/vec2pg/common.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from urllib.parse import urlparse

POSTGRES_CONNECTION_STRING = "POSTGRES_CONNECTION_STRING"


def is_http_url(url: str) -> bool:
return urlparse(url).scheme in {"https", "http"}
5 changes: 4 additions & 1 deletion src/vec2pg/plugins/qdrant.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
from qdrant_client import QdrantClient
from tqdm import tqdm

from vec2pg.common import POSTGRES_CONNECTION_STRING
from vec2pg.common import POSTGRES_CONNECTION_STRING, is_http_url

app = typer.Typer()

@@ -36,6 +36,9 @@ def migrate(
],
):

if not is_http_url(qdrant_url):
ValueError("qdrant_url must be a valid HTTP URL string")

# Init Pinecone client and index
client = QdrantClient(url=qdrant_url, api_key=qdrant_api_key)

4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys

sys.dont_write_bytecode = True

import json
import os
import random
3 changes: 3 additions & 0 deletions tests/test_pinecone.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import environ

import pytest
from pinecone import Pinecone
from pinecone.data.index import Index
from typer.testing import CliRunner
@@ -17,10 +18,12 @@ def test_client_is_good(pinecone_client: Pinecone) -> None:
assert pinecone_client is not None


@pytest.mark.skip()
def test_index_is_good(pinecone_index: Index) -> None:
assert pinecone_index.describe_index_stats()["dimension"] == 2


@pytest.mark.skip()
def test_pinecone_migrate(
pinecone_index_name: str,
postgres_connection_string: str,
13 changes: 12 additions & 1 deletion tests/test_qdrant.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import warnings

import pytest
from qdrant_client import QdrantClient
from typer.testing import CliRunner

from vec2pg.cli import app
from vec2pg.common import is_http_url
from vec2pg.plugins.qdrant import to_qualified_table_name


def test_pinecone_subcommand_does_not_error() -> None:
def test_qdrant_subcommand_does_not_error() -> None:
runner = CliRunner()
runner.invoke(app, ["qdrant", "--help"])

@@ -55,3 +57,12 @@ def test_qdrant_migrate(
f"select id, values, metadata from {qualified_name}"
).fetchall()
assert len(recs) == 100


def test_is_http_url():
with pytest.raises(AssertionError) as url_checker:
assert is_http_url("https://supabase.com/"), "Invalid URL pattern"
assert is_http_url("http://localhost:8080"), "Invalid URL pattern"
assert is_http_url("mailto://somebody@domain.com"), "Invalid URL pattern"

assert "Invalid URL pattern" in str(url_checker.value)