cvec 1.5.0__tar.gz → 1.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. cvec-1.5.2/.claude/settings.json +51 -0
  2. cvec-1.5.2/.claude/settings.local.json +28 -0
  3. cvec-1.5.2/.github/workflows/ci.yml +33 -0
  4. cvec-1.5.2/.github/workflows/license-check-python.yml +17 -0
  5. cvec-1.5.2/.github/workflows/pyproject-license-check.yml +17 -0
  6. cvec-1.5.2/.gitignore +177 -0
  7. cvec-1.5.2/CLAUDE.md +1 -0
  8. {cvec-1.5.0 → cvec-1.5.2}/PKG-INFO +10 -10
  9. cvec-1.5.2/examples/add_agent_post_example.py +52 -0
  10. cvec-1.5.2/examples/add_metric_data_arrow_example.py +34 -0
  11. cvec-1.5.2/examples/add_metric_data_example.py +34 -0
  12. cvec-1.5.2/examples/add_multiple_metrics_and_get_spans_for_them.py +127 -0
  13. cvec-1.5.2/examples/eav_example.py +29 -0
  14. cvec-1.5.2/examples/get_metric_arrow_example.py +26 -0
  15. cvec-1.5.2/examples/get_metric_data_objects_example.py +21 -0
  16. cvec-1.5.2/examples/get_metrics_example.py +20 -0
  17. cvec-1.5.2/examples/get_modeling_metrics_data_arrow_example.py +26 -0
  18. cvec-1.5.2/examples/get_modeling_metrics_data_example.py +33 -0
  19. cvec-1.5.2/examples/get_modeling_metrics_example.py +18 -0
  20. cvec-1.5.2/examples/get_spans_example.py +25 -0
  21. cvec-1.5.2/examples/show_eav_schema.py +27 -0
  22. {cvec-1.5.0 → cvec-1.5.2}/pyproject.toml +14 -12
  23. cvec-1.5.2/scripts/csv_import.py +228 -0
  24. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/cvec.py +78 -12
  25. cvec-1.5.2/src/cvec/http_cache.py +40 -0
  26. cvec-1.5.2/tests/__init__.py +0 -0
  27. cvec-1.5.2/tests/test_cvec.py +899 -0
  28. cvec-1.5.2/tests/test_http_cache.py +407 -0
  29. cvec-1.5.2/tests/test_http_compression.py +226 -0
  30. cvec-1.5.2/tests/test_modeling.py +163 -0
  31. cvec-1.5.2/tests/test_token_refresh.py +162 -0
  32. cvec-1.5.2/uv.lock +519 -0
  33. {cvec-1.5.0 → cvec-1.5.2}/LICENSE +0 -0
  34. {cvec-1.5.0 → cvec-1.5.2}/README.md +0 -0
  35. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/__init__.py +0 -0
  36. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/__init__.py +0 -0
  37. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/agent_post.py +0 -0
  38. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/eav_column.py +0 -0
  39. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/eav_filter.py +0 -0
  40. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/eav_table.py +0 -0
  41. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/metric.py +0 -0
  42. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/models/span.py +0 -0
  43. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/py.typed +0 -0
  44. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/utils/__init__.py +0 -0
  45. {cvec-1.5.0 → cvec-1.5.2}/src/cvec/utils/arrow_converter.py +0 -0
@@ -0,0 +1,51 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "uv run python-claude session start"
9
+ },
10
+ {
11
+ "type": "command",
12
+ "command": "uv run python-claude git status"
13
+ }
14
+ ]
15
+ }
16
+ ],
17
+ "Stop": [
18
+ {
19
+ "hooks": [
20
+ {
21
+ "type": "command",
22
+ "command": "uv run python-claude ruff format"
23
+ },
24
+ {
25
+ "type": "command",
26
+ "command": "uv run python-claude ruff check"
27
+ },
28
+ {
29
+ "type": "command",
30
+ "command": "uv run python-claude mypy"
31
+ },
32
+ {
33
+ "type": "command",
34
+ "command": "uv run python-claude pytest"
35
+ }
36
+ ]
37
+ }
38
+ ],
39
+ "PostToolUse": [
40
+ {
41
+ "matcher": "Write|Edit",
42
+ "hooks": [
43
+ {
44
+ "type": "command",
45
+ "command": "uv run python-claude edited"
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(chmod:*)",
5
+ "Bash(python:*)",
6
+ "Bash(git commit:*)",
7
+ "Bash(pytest:*)",
8
+ "Bash(python3 -m pytest:*)",
9
+ "Bash(poetry run pytest:*)",
10
+ "Bash(git add:*)",
11
+ "Bash(poetry run mypy:*)",
12
+ "Bash(git checkout:*)",
13
+ "Bash(poetry run ruff:*)",
14
+ "Bash(poetry install:*)",
15
+ "Bash(tree:*)",
16
+ "Bash(git mv:*)",
17
+ "WebFetch(domain:github.com)",
18
+ "WebFetch(domain:pypi.org)",
19
+ "Bash(poetry run python:*)",
20
+ "Bash(poetry add:*)",
21
+ "Bash(git fetch:*)",
22
+ "Bash(git rebase:*)",
23
+ "Bash(git rm:*)"
24
+ ],
25
+ "deny": [],
26
+ "ask": []
27
+ }
28
+ }
@@ -0,0 +1,33 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ pull_request:
5
+ paths:
6
+ - .github/workflows/ci.yml
7
+ - uv.lock
8
+ - pyproject.toml
9
+ - src/**
10
+ - tests/**
11
+ push:
12
+ paths:
13
+ - .github/workflows/ci.yml
14
+ - uv.lock
15
+ - pyproject.toml
16
+ - src/**
17
+ - tests/**
18
+
19
+ jobs:
20
+ build:
21
+ runs-on: ubuntu-24.04
22
+ strategy:
23
+ matrix:
24
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
25
+
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
29
+
30
+ - uses: CVector-Energy/python-test@uv
31
+ with:
32
+ python-version: ${{ matrix.python-version }}
33
+ src-dirs: .
@@ -0,0 +1,17 @@
1
+ name: Python License Check
2
+
3
+ on:
4
+ push:
5
+
6
+ jobs:
7
+ license-check:
8
+ runs-on: ubuntu-24.04
9
+
10
+ steps:
11
+ - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
12
+
13
+ - name: Check Python licenses
14
+ uses: CVector-Energy/pyproject-license-check@main
15
+ with:
16
+ app-id: ${{ vars.APP_ID }}
17
+ app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
@@ -0,0 +1,17 @@
1
+ name: Python License Check
2
+
3
+ on:
4
+ push:
5
+
6
+ jobs:
7
+ license-check:
8
+ runs-on: ubuntu-24.04
9
+
10
+ steps:
11
+ - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
12
+
13
+ - name: Check Python licenses
14
+ uses: CVector-Energy/pyproject-license-check@main
15
+ with:
16
+ app-id: ${{ vars.APP_ID }}
17
+ app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
cvec-1.5.2/.gitignore ADDED
@@ -0,0 +1,177 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
175
+ .aider*
176
+
177
+ .vscode/
cvec-1.5.2/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ - Name files for their main export, transforming Python names from PascalCase to underscore_case. For example, the file that defines the EAVFilter class should be named eav_filter.py.
@@ -1,22 +1,23 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: cvec
3
- Version: 1.5.0
3
+ Version: 1.5.2
4
4
  Summary: SDK for CVector Energy
5
- License: MIT
6
- Author: CVector
7
- Author-email: support@cvector.energy
8
- Requires-Python: >=3.10
5
+ Author-email: CVector <support@cvector.energy>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Intended Audience :: Developers
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Intended Audience :: Developers
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
16
  Classifier: Programming Language :: Python :: 3.14
18
- Requires-Dist: pyarrow (>=22.0.0)
19
- Requires-Dist: pydantic (>=2.12.0)
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: brotli<2,>=1.2.0
19
+ Requires-Dist: pyarrow>=22.0.0
20
+ Requires-Dist: pydantic>=2.12.0
20
21
  Description-Content-Type: text/markdown
21
22
 
22
23
  # CVec Client Library
@@ -404,4 +405,3 @@ rows = cvec.select_from_eav_id(
404
405
  for row in rows:
405
406
  print(f"ID: {row['id']}, Values: {row}")
406
407
  ```
407
-
@@ -0,0 +1,52 @@
1
+ import os
2
+ import uuid
3
+
4
+ from cvec import CVec
5
+ from cvec.models.agent_post import AgentPostRecommendation, AgentPostTag, Severity
6
+
7
+
8
+ def main() -> None:
9
+ # Initialize CVec client
10
+ cvec = CVec(
11
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
12
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
13
+ )
14
+
15
+ recommendations = [
16
+ AgentPostRecommendation(
17
+ content="Critical recommendation",
18
+ severity=Severity.CRITICAL,
19
+ ),
20
+ AgentPostRecommendation(
21
+ content="Warning recommendation",
22
+ severity=Severity.WARNING,
23
+ ),
24
+ AgentPostRecommendation(
25
+ content="Info recommendation",
26
+ severity=Severity.INFO,
27
+ ),
28
+ ]
29
+
30
+ tags = [
31
+ AgentPostTag(
32
+ content="urgent",
33
+ severity=Severity.CRITICAL,
34
+ ),
35
+ AgentPostTag(
36
+ content="monitoring",
37
+ severity=Severity.INFO,
38
+ ),
39
+ ]
40
+
41
+ cvec.add_agent_post(
42
+ title="Test post",
43
+ author="Operational Agent",
44
+ image_id=str(uuid.uuid4()), # Replace with actual image UUID uploaded to S3
45
+ content="SDK add post test.",
46
+ recommendations=recommendations,
47
+ tags=tags,
48
+ )
49
+
50
+
51
+ if __name__ == "__main__":
52
+ main()
@@ -0,0 +1,34 @@
1
+ from cvec import CVec
2
+ from cvec.models.metric import MetricDataPoint
3
+ from datetime import datetime, timezone
4
+ import random
5
+ import os
6
+
7
+
8
+ def main() -> None:
9
+ cvec = CVec(
10
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
11
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
12
+ )
13
+ test_metric_name = "python-sdk/test"
14
+ print("\nAdding new metric data using Arrow...")
15
+ new_data = [
16
+ MetricDataPoint(
17
+ name=test_metric_name,
18
+ time=datetime.now(timezone.utc),
19
+ value_double=random.random() * 100.0,
20
+ value_string=None,
21
+ ),
22
+ MetricDataPoint(
23
+ name=test_metric_name,
24
+ time=datetime.now(timezone.utc),
25
+ value_double=random.random() * 100.0,
26
+ value_string=None,
27
+ ),
28
+ ]
29
+ cvec.add_metric_data(new_data, use_arrow=True)
30
+ print("Data added successfully")
31
+
32
+
33
+ if __name__ == "__main__":
34
+ main()
@@ -0,0 +1,34 @@
1
+ from cvec import CVec
2
+ from cvec.models.metric import MetricDataPoint
3
+ from datetime import datetime, timezone
4
+ import random
5
+ import os
6
+
7
+
8
+ def main() -> None:
9
+ cvec = CVec(
10
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
11
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
12
+ )
13
+ test_metric_name = "python-sdk/test"
14
+ print("\nAdding new metric data...")
15
+ new_data = [
16
+ MetricDataPoint(
17
+ name=test_metric_name,
18
+ time=datetime.now(timezone.utc),
19
+ value_double=random.random() * 100.0,
20
+ value_string=None,
21
+ ),
22
+ MetricDataPoint(
23
+ name=test_metric_name,
24
+ time=datetime.now(timezone.utc),
25
+ value_double=random.random() * 100.0,
26
+ value_string=None,
27
+ ),
28
+ ]
29
+ cvec.add_metric_data(new_data, use_arrow=False)
30
+ print("Data added successfully")
31
+
32
+
33
+ if __name__ == "__main__":
34
+ main()
@@ -0,0 +1,127 @@
1
+ import random
2
+ from cvec import CVec
3
+ from datetime import datetime, timedelta, timezone
4
+ import os
5
+ import io
6
+ import pyarrow.ipc as ipc # type: ignore[import-untyped]
7
+
8
+ from cvec.models.metric import MetricDataPoint
9
+
10
+
11
+ def main() -> None:
12
+ cvec = CVec(
13
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
14
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
15
+ )
16
+ test_metric_name = ""
17
+
18
+ # fetch & pick metrics
19
+ metrics = cvec.get_metrics(
20
+ start_at=datetime(2025, 7, 14, 10, 0, 0),
21
+ end_at=datetime(2025, 7, 14, 11, 0, 0),
22
+ )
23
+ print(f"Found {len(metrics)} metrics")
24
+ for metric in metrics:
25
+ print(f"- {metric.name} - {metric.id}")
26
+ if metrics:
27
+ found_metric_name = next((m.name for m in metrics if "Sensor_" in m.name))
28
+ assert found_metric_name, "No suitable metric found"
29
+ test_metric_name = found_metric_name
30
+ print(f"\nUsing metric: {test_metric_name}")
31
+
32
+ # Add metric non-Arrow data
33
+ random_number_nonarrow = random.randint(10000, 20000)
34
+ print(
35
+ f"\nAdding new metric data point with non-Arrow format for metric "
36
+ f"'{test_metric_name}' and values {random_number_nonarrow}..."
37
+ )
38
+ new_data = [
39
+ MetricDataPoint(
40
+ name=test_metric_name,
41
+ time=datetime.now(timezone.utc),
42
+ value_double=random_number_nonarrow,
43
+ value_string=None,
44
+ ),
45
+ MetricDataPoint(
46
+ name=test_metric_name,
47
+ time=datetime.now(timezone.utc),
48
+ value_double=None,
49
+ value_string=str(random_number_nonarrow),
50
+ ),
51
+ ]
52
+ cvec.add_metric_data(new_data, use_arrow=False)
53
+ print("Non-Arrow Data added successfully")
54
+
55
+ # Add metric Arrow data
56
+
57
+ random_number_arrow = random.randint(10000, 20000)
58
+ print(
59
+ f"\nAdding new metric data point with Arrow format for metric "
60
+ f"'{test_metric_name}' and value {random_number_arrow}..."
61
+ )
62
+ new_data = [
63
+ MetricDataPoint(
64
+ name=test_metric_name,
65
+ time=datetime.now(timezone.utc),
66
+ value_double=random_number_arrow,
67
+ value_string=None,
68
+ ),
69
+ ]
70
+ cvec.add_metric_data(new_data, use_arrow=True)
71
+ print("Arrow Data added successfully")
72
+
73
+ # Fetch and print metric data - non-Arrow
74
+ data_points = cvec.get_metric_data(
75
+ start_at=datetime.now(timezone.utc) - timedelta(minutes=1),
76
+ end_at=datetime.now(timezone.utc),
77
+ names=[test_metric_name],
78
+ )
79
+ assert len(data_points) > 0, "No data points found for the metric"
80
+ assert any(dp.value_double == random_number_nonarrow for dp in data_points), (
81
+ "No data point found with the expected non-Arrow value"
82
+ )
83
+ assert any(dp.value_string == str(random_number_nonarrow) for dp in data_points), (
84
+ "No data point found with the expected non-Arrow string value"
85
+ )
86
+ assert any(dp.value_double == random_number_arrow for dp in data_points), (
87
+ "No data point found with the expected Arrow value"
88
+ )
89
+ print(f"\nFound {len(data_points)} data points for metric '{test_metric_name}'")
90
+ for point in data_points:
91
+ print(
92
+ f"- {point.name}: {point.value_double or point.value_string} at {point.time}"
93
+ )
94
+
95
+ # Fetch and print metric data - Arrow
96
+ arrow_data = cvec.get_metric_arrow(
97
+ start_at=datetime.now(timezone.utc) - timedelta(minutes=1),
98
+ end_at=datetime.now(timezone.utc),
99
+ names=[test_metric_name],
100
+ )
101
+ reader = ipc.open_file(io.BytesIO(arrow_data))
102
+ table = reader.read_all()
103
+ assert len(table) > 0, "No data found in Arrow format"
104
+ print(f"Arrow table shape: {len(table)} rows")
105
+ print("\nFirst few rows:")
106
+ for i in range(min(5, len(table))):
107
+ print(
108
+ f"- {table['name'][i].as_py()}: {table['value_double'][i].as_py() or table['value_string'][i].as_py()} at {table['time'][i].as_py()}"
109
+ )
110
+
111
+ # spans
112
+ spans = cvec.get_spans(
113
+ start_at=datetime.now(timezone.utc) - timedelta(minutes=1),
114
+ end_at=datetime.now(timezone.utc),
115
+ name=test_metric_name,
116
+ limit=5,
117
+ )
118
+ assert len(spans) > 0, "No spans found for the metric"
119
+ print(f"Found {len(spans)} spans")
120
+ for span in spans:
121
+ print(f"- Value: {span.value} from {span.raw_start_at} to {span.raw_end_at}")
122
+
123
+ print("\nAll operations completed successfully.")
124
+
125
+
126
+ if __name__ == "__main__":
127
+ main()
@@ -0,0 +1,29 @@
1
+ import os
2
+
3
+ from cvec import CVec, EAVFilter
4
+
5
+
6
+ def main() -> None:
7
+ cvec = CVec(
8
+ host=os.environ.get(
9
+ "CVEC_HOST", "https://your-subdomain.cvector.dev"
10
+ ), # Replace with your API host
11
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
12
+ )
13
+
14
+ # Example: Query with numeric range filter
15
+ print("\nQuerying with numeric range filter...")
16
+ rows = cvec.select_from_eav_id(
17
+ table_id="00000000-0000-0000-0000-000000000000",
18
+ column_ids=["abcd", "defg", "hijk"],
19
+ filters=[
20
+ EAVFilter(column_id="abcd", numeric_min=45992, numeric_max=45993),
21
+ ],
22
+ )
23
+ print(f"Found {len(rows)} rows with abcd in range [45992, 45993)")
24
+ for row in rows:
25
+ print(f"- {row}")
26
+
27
+
28
+ if __name__ == "__main__":
29
+ main()
@@ -0,0 +1,26 @@
1
+ from cvec import CVec
2
+ import io
3
+ import pyarrow.ipc as ipc # type: ignore[import-untyped]
4
+ import os
5
+
6
+
7
+ def main() -> None:
8
+ cvec = CVec(
9
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
10
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
11
+ )
12
+ test_metric_name = "python-sdk/test"
13
+ print("\nGetting metric data as Arrow...")
14
+ arrow_data = cvec.get_metric_arrow(names=[test_metric_name])
15
+ reader = ipc.open_file(io.BytesIO(arrow_data))
16
+ table = reader.read_all()
17
+ print(f"Arrow table shape: {len(table)} rows")
18
+ print("\nFirst few rows:")
19
+ for i in range(min(5, len(table))):
20
+ print(
21
+ f"- {table['name'][i].as_py()}: {table['value_double'][i].as_py() or table['value_string'][i].as_py()} at {table['time'][i].as_py()}"
22
+ )
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
@@ -0,0 +1,21 @@
1
+ from cvec import CVec
2
+ import os
3
+
4
+
5
+ def main() -> None:
6
+ cvec = CVec(
7
+ host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"),
8
+ api_key=os.environ.get("CVEC_API_KEY", "your-api-key"),
9
+ )
10
+ test_metric_name = "python-sdk/test"
11
+ print("\nGetting metric data as objects...")
12
+ data_points = cvec.get_metric_data(names=[test_metric_name])
13
+ print(f"Found {len(data_points)} data points")
14
+ for point in data_points[:3]:
15
+ print(
16
+ f"- {point.name}: {point.value_double or point.value_string} at {point.time}"
17
+ )
18
+
19
+
20
+ if __name__ == "__main__":
21
+ main()