Skip to content

Conversation

@michal-chrobok-semantive
  • Removed email and publishable key from Cvec class constructor params
  • Renamed password to api_key
  • Added logic for fetching publishable key from /config endpoint
  • Added logic for construction of user email for auth
  • Modified example scripts

@linear
Copy link

linear bot commented Jul 2, 2025

PD1-465 SDK should use API Key rather than username & password

host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
email=os.environ.get("CVEC_EMAIL", "your-email@cvector.app"),
password=os.environ.get("CVEC_PASSWORD", "your-password"),

The SDK should be responsible for splitting the API Key into "username" and "password". The requirement to split the key is an implementation detail due to the limitation of our current auth provider. In the future, we will improve this (by moving to a more capable auth provider), but will strive to maintain compatibility.

Therefore, the user should just manage the single API Key as an opaque secret value.

Similarly, get the CVEC_PUBLISHABLE_KEY from the /config resource as in https://github.com/CVector-Energy/ui/pull/105/files#diff-4c4160f55a2aadeac4efa96a843696d4f9f0d98b1329909b05cb9db4a8ffcce4R85-R86. Do not accept it as an environment variable. The Supabase publishable key is another Supabase friction/detail detail that shouldn't impact the user.

Also see this SDK setup: https://github.com/CVector-Energy/cvec-iot/pull/2/files#diff-c989b78806f11ebc41fcc62b339831ff9ef486a0643d9390d3b291ee31fed4f1R34-R37

Copy link
Member

@joshuanapoli joshuanapoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that sandbox backend is setup for, but there is still some discrepancy with the SDK:

(.venv) joshuanapoli@mac cvec-python % CVEC_HOST=https://sandbox.cvector.dev CVEC_API_KEY=cva_hHs0CbkKALxMnxUdI9hanF0TBPvvvr1HjG6O python
Python 3.13.3 (main, Apr  8 2025, 13:54:08) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvec
... from datetime import datetime
...
>>> cvec = cvec.CVec()
>>> for item in cvec.get_metrics(start_at=datetime(2025, 7, 14, 10, 0, 0), end_at=datetime(2025, 7, 14, 11, 0, 0)):
...   print(item.name)
...
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    for item in cvec.get_metrics(start_at=datetime(2025, 7, 14, 10, 0, 0), end_at=datetime(2025, 7, 14, 11, 0, 0)):
                ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joshuanapoli/src/cvec-python/src/cvec/cvec.py", line 275, in get_metrics
    response_data = self._make_request("GET", "/api/metrics/", params=params)
  File "/Users/joshuanapoli/src/cvec-python/src/cvec/cvec.py", line 143, in _make_request
    response.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/joshuanapoli/src/cvec-python/.venv/lib/python3.13/site-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://sandbox.cvector.dev/api/metrics/?start_at=2025-07-14T10%3A00%3A00&end_at=2025-07-14T11%3A00%3A00

Copy link
Contributor

@baftinho baftinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

baftinho and others added 5 commits July 29, 2025 17:30
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
@joshuanapoli joshuanapoli force-pushed the fix/cvec-class-params branch from 4e09f36 to 1b3e6a9 Compare July 29, 2025 22:07
Copy link
Member

@joshuanapoli joshuanapoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @baftinho for the more comprehensive test. This worked for me, tested in the scope of https://github.com/CVector-Energy/cvec-backend/pull/53

@joshuanapoli joshuanapoli merged commit a30086f into main Jul 29, 2025
4 checks passed
@joshuanapoli joshuanapoli deleted the fix/cvec-class-params branch July 29, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants