From 5429f9afc5dbbe951ea48caae45347cd3ea34841 Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Sun, 8 Nov 2026 10:40:52 -0500 Subject: [PATCH 1/2] Remove the get_modeling_metrics client methods The backend is removing the /api/modeling routes these methods called (CVector-Energy/cvec-backend#852). Their last callers in cvec-modeling-platform moved to aion, and prod has had no requests to them since 2026-11-05. Drops the three methods, their README sections, examples and tests. Co-Authored-By: Claude Opus 5.5 --- README.md | 29 ---- ...get_modeling_metrics_data_arrow_example.py | 26 --- examples/get_modeling_metrics_data_example.py | 33 ---- examples/get_modeling_metrics_example.py | 18 -- src/cvec/cvec.py | 91 ---------- tests/test_modeling.py | 163 ------------------ 6 files changed, 360 deletions(-) delete mode 100644 examples/get_modeling_metrics_data_arrow_example.py delete mode 100644 examples/get_modeling_metrics_data_example.py delete mode 100644 examples/get_modeling_metrics_example.py delete mode 100644 tests/test_modeling.py diff --git a/README.md b/README.md index 0b058d1..60a2484 100644 --- a/README.md +++ b/README.md @@ -244,35 +244,6 @@ Add multiple metric data points to the database. Return a list of metrics that had at least one transition in the given [`start_at`, `end_at`) interval. All metrics are returned if no `start_at` and `end_at` are given. -## `get_modeling_metrics(?start_at, ?end_at)` - -Fetch modeling metrics from the modeling database. This method returns a list of available modeling metrics that had transitions in the specified time range. - -- `start_at`: Optional start date for the query range (uses class default if not specified) -- `end_at`: Optional end date for the query range (uses class default if not specified) - -Returns a list of `Metric` objects containing modeling metrics. - -## `get_modeling_metrics_data(?names, ?start_at, ?end_at)` - -Fetch actual data values from modeling metrics within a time range. This method returns the actual data points (values) for the specified modeling metrics, similar to `get_metric_data()` but for the modeling database. - -- `names`: Optional list of modeling metric names to filter by -- `start_at`: Optional start time for the query (uses class default if not specified) -- `end_at`: Optional end time for the query (uses class default if not specified) - -Returns a list of `MetricDataPoint` objects containing the actual data values. - -## `get_modeling_metrics_data_arrow(?names, ?start_at, ?end_at)` - -Fetch actual data values from modeling metrics within a time range in Apache Arrow format. This method returns the actual data points (values) for the specified modeling metrics in Arrow IPC format, which is more efficient for large datasets. - -- `names`: Optional list of modeling metric names to filter by -- `start_at`: Optional start time for the query (uses class default if not specified) -- `end_at`: Optional end time for the query (uses class default if not specified) - -Returns Arrow IPC format data that can be read using `pyarrow.ipc.open_file()`. - ## `get_eav_tables()` Get all EAV (Entity-Attribute-Value) tables for the tenant. EAV tables store semi-structured data where each row represents an entity with flexible attributes. diff --git a/examples/get_modeling_metrics_data_arrow_example.py b/examples/get_modeling_metrics_data_arrow_example.py deleted file mode 100644 index 6af3c43..0000000 --- a/examples/get_modeling_metrics_data_arrow_example.py +++ /dev/null @@ -1,26 +0,0 @@ -from cvec import CVec -import io -import pyarrow.ipc as ipc # type: ignore[import-untyped] -import os - - -def main() -> None: - cvec = CVec( - host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"), - api_key=os.environ.get("CVEC_API_KEY", "your-api-key"), - ) - test_metric_name = "Data_Marketplace/PROD/Miso_5min/ILLINOIS_HUB_lmp" - print("\nGetting modeling metrics data as Arrow...") - arrow_data = cvec.get_modeling_metrics_data_arrow(names=[test_metric_name]) - reader = ipc.open_file(io.BytesIO(arrow_data)) - table = reader.read_all() - print(f"Arrow table shape: {len(table)} rows") - print("\nFirst few rows:") - for i in range(min(5, len(table))): - print( - 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()}" - ) - - -if __name__ == "__main__": - main() diff --git a/examples/get_modeling_metrics_data_example.py b/examples/get_modeling_metrics_data_example.py deleted file mode 100644 index 36ba526..0000000 --- a/examples/get_modeling_metrics_data_example.py +++ /dev/null @@ -1,33 +0,0 @@ -from cvec import CVec -import os -from datetime import datetime, timedelta - - -def main() -> None: - cvec = CVec( - host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"), - api_key=os.environ.get("CVEC_API_KEY", "your-api-key"), - ) - end_date = datetime.now() - start_date = end_date - timedelta(hours=3) - print("\nGetting modeling metrics data...") - modeling_data = cvec.get_modeling_metrics_data( - names=["Data_Marketplace/PROD/Miso_5min/ILLINOIS_HUB_lmp"], - start_at=start_date, - end_at=end_date, - ) - print(f"Found {len(modeling_data)} data points") - - if modeling_data: - print("\nFirst few data points:") - for i, point in enumerate(modeling_data[:5]): - print( - f"- {point.name}: {point.value_double or point.value_string} at {point.time}" - ) - - if len(modeling_data) > 5: - print(f"... and {len(modeling_data) - 5} more data points") - - -if __name__ == "__main__": - main() diff --git a/examples/get_modeling_metrics_example.py b/examples/get_modeling_metrics_example.py deleted file mode 100644 index 711e7fe..0000000 --- a/examples/get_modeling_metrics_example.py +++ /dev/null @@ -1,18 +0,0 @@ -from cvec import CVec -import os - - -def main() -> None: - cvec = CVec( - host=os.environ.get("CVEC_HOST", "https://your-subdomain.cvector.dev"), - api_key=os.environ.get("CVEC_API_KEY", "your-api-key"), - ) - print("\nGetting available modeling metrics...") - modeling_metrics = cvec.get_modeling_metrics() - print(f"Found {len(modeling_metrics)} modeling metrics") - for metric in modeling_metrics: - print(f"- {metric.name}") - - -if __name__ == "__main__": - main() diff --git a/src/cvec/cvec.py b/src/cvec/cvec.py index 4ecf2cf..41e84fe 100644 --- a/src/cvec/cvec.py +++ b/src/cvec/cvec.py @@ -405,97 +405,6 @@ def add_metric_data( ] self._make_request("POST", endpoint, json_data=data_dicts) # type: ignore[arg-type] - def get_modeling_metrics( - self, - start_at: Optional[datetime] = None, - end_at: Optional[datetime] = None, - ) -> List[Metric]: - """ - Return a list of modeling metrics that had at least one transition in the given [start_at, end_at) interval. - All metrics are returned if no start_at and end_at are given. - - Args: - start_at: Optional start time for the query (uses class default if not specified) - end_at: Optional end time for the query (uses class default if not specified) - - Returns: - List of Metric objects containing modeling metrics - """ - _start_at = start_at or self.default_start_at - _end_at = end_at or self.default_end_at - - params: Dict[str, Any] = { - "start_at": _start_at.isoformat() if _start_at else None, - "end_at": _end_at.isoformat() if _end_at else None, - } - - response_data = self._make_request( - "GET", "/api/modeling/metrics", params=params - ) - return [Metric.model_validate(metric_data) for metric_data in response_data] - - def get_modeling_metrics_data( - self, - names: Optional[List[str]] = None, - start_at: Optional[datetime] = None, - end_at: Optional[datetime] = None, - ) -> List[MetricDataPoint]: - """ - Return all data-points within a given [start_at, end_at) interval, - optionally selecting a given list of modeling metric names. - Returns a list of MetricDataPoint objects, one for each metric value transition. - - Args: - names: Optional list of modeling metric names to filter by - start_at: Optional start time for the query - end_at: Optional end time for the query - """ - _start_at = start_at or self.default_start_at - _end_at = end_at or self.default_end_at - - params: Dict[str, Any] = { - "start_at": _start_at.isoformat() if _start_at else None, - "end_at": _end_at.isoformat() if _end_at else None, - "names": ",".join(names) if names else None, - } - - response_data = self._make_request( - "GET", "/api/modeling/metrics/data", params=params - ) - return [ - MetricDataPoint.model_validate(point_data) for point_data in response_data - ] - - def get_modeling_metrics_data_arrow( - self, - names: Optional[List[str]] = None, - start_at: Optional[datetime] = None, - end_at: Optional[datetime] = None, - ) -> bytes: - """ - Return all data-points within a given [start_at, end_at) interval, - optionally selecting a given list of modeling metric names. - Returns Arrow IPC format data that can be read using pyarrow.ipc.open_file. - - Args: - names: Optional list of modeling metric names to filter by - start_at: Optional start time for the query - end_at: Optional end time for the query - """ - _start_at = start_at or self.default_start_at - _end_at = end_at or self.default_end_at - - params: Dict[str, Any] = { - "start_at": _start_at.isoformat() if _start_at else None, - "end_at": _end_at.isoformat() if _end_at else None, - "names": ",".join(names) if names else None, - } - - endpoint = "/api/modeling/metrics/data/arrow" - result = self._make_request("GET", endpoint, params=params) - assert isinstance(result, bytes) - return result - def add_agent_post( self, title: str, diff --git a/tests/test_modeling.py b/tests/test_modeling.py deleted file mode 100644 index 4924c4e..0000000 --- a/tests/test_modeling.py +++ /dev/null @@ -1,163 +0,0 @@ -""" -Tests for the modeling functionality in the CVec client. -""" - -import pytest -from datetime import datetime -from unittest.mock import Mock, patch - - -from cvec.cvec import CVec - - -def mock_fetch_config_side_effect(instance: CVec) -> str: - """Side effect for _fetch_config mock that sets tenant_id.""" - instance._tenant_id = 1 - return "test_publishable_key" - - -class TestModelingMethods: - """Test the modeling methods in the CVec class.""" - - @patch.object( - CVec, "_fetch_config", autospec=True, side_effect=mock_fetch_config_side_effect - ) - @patch.object(CVec, "_login_with_supabase", return_value=None) - @patch.object(CVec, "_make_request") - def test_get_modeling_metrics( - self, mock_make_request: Mock, mock_login: Mock, mock_fetch_key: Mock - ) -> None: - """Test get_modeling_metrics method.""" - - # Mock the response - mock_response = [ - { - "id": 1, - "name": "test_metric", - "birth_at": "2024-01-01T12:00:00", - "death_at": None, - } - ] - mock_make_request.return_value = mock_response - - # Create CVec instance - cvec = CVec( - host="http://test.com", api_key="cva_test12345678901234567890123456789012" - ) - - # Call the method - start_date = datetime(2024, 1, 1, 12, 0, 0) - end_date = datetime(2024, 1, 1, 13, 0, 0) - result = cvec.get_modeling_metrics( - start_at=start_date, - end_at=end_date, - ) - - # Verify the result - assert isinstance(result, list) - assert len(result) == 1 - assert result[0].id == 1 - assert result[0].name == "test_metric" - - # Verify the request was made correctly - mock_make_request.assert_called_once() - call_args = mock_make_request.call_args - assert call_args[0][0] == "GET" - assert call_args[0][1] == "/api/modeling/metrics" - assert call_args[1]["params"]["start_at"] == "2024-01-01T12:00:00" - assert call_args[1]["params"]["end_at"] == "2024-01-01T13:00:00" - - @patch.object( - CVec, "_fetch_config", autospec=True, side_effect=mock_fetch_config_side_effect - ) - @patch.object(CVec, "_login_with_supabase", return_value=None) - @patch.object(CVec, "_make_request") - def test_get_modeling_metrics_data( - self, mock_make_request: Mock, mock_login: Mock, mock_fetch_key: Mock - ) -> None: - """Test get_modeling_metrics_data method.""" - - # Mock the response - mock_response = [ - { - "name": "test_metric", - "time": "2024-01-01T12:00:00", - "value_double": 42.5, - "value_string": None, - } - ] - mock_make_request.return_value = mock_response - - # Create CVec instance - cvec = CVec( - host="http://test.com", api_key="cva_test12345678901234567890123456789012" - ) - - # Call the method - start_date = datetime(2024, 1, 1, 12, 0, 0) - end_date = datetime(2024, 1, 1, 13, 0, 0) - result = cvec.get_modeling_metrics_data( - names=["test_metric"], - start_at=start_date, - end_at=end_date, - ) - - # Verify the result - assert isinstance(result, list) - assert len(result) == 1 - assert result[0].name == "test_metric" - assert result[0].value_double == 42.5 - - # Verify the request was made correctly - mock_make_request.assert_called_once() - call_args = mock_make_request.call_args - assert call_args[0][0] == "GET" - assert call_args[0][1] == "/api/modeling/metrics/data" - assert call_args[1]["params"]["names"] == "test_metric" - assert call_args[1]["params"]["start_at"] == "2024-01-01T12:00:00" - assert call_args[1]["params"]["end_at"] == "2024-01-01T13:00:00" - - @patch.object( - CVec, "_fetch_config", autospec=True, side_effect=mock_fetch_config_side_effect - ) - @patch.object(CVec, "_login_with_supabase", return_value=None) - @patch.object(CVec, "_make_request") - def test_get_modeling_metrics_data_arrow( - self, mock_make_request: Mock, mock_login: Mock, mock_fetch_key: Mock - ) -> None: - """Test get_modeling_metrics_data_arrow method.""" - - # Mock the response (Arrow data as bytes) - mock_response = b"fake_arrow_data" - mock_make_request.return_value = mock_response - - # Create CVec instance - cvec = CVec( - host="http://test.com", api_key="cva_test12345678901234567890123456789012" - ) - - # Call the method - start_date = datetime(2024, 1, 1, 12, 0, 0) - end_date = datetime(2024, 1, 1, 13, 0, 0) - result = cvec.get_modeling_metrics_data_arrow( - names=["test_metric"], - start_at=start_date, - end_at=end_date, - ) - - # Verify the result - assert isinstance(result, bytes) - assert result == b"fake_arrow_data" - - # Verify the request was made correctly - mock_make_request.assert_called_once() - call_args = mock_make_request.call_args - assert call_args[0][0] == "GET" - assert call_args[0][1] == "/api/modeling/metrics/data/arrow" - assert call_args[1]["params"]["names"] == "test_metric" - assert call_args[1]["params"]["start_at"] == "2024-01-01T12:00:00" - assert call_args[1]["params"]["end_at"] == "2024-01-01T13:00:00" - - -if __name__ == "__main__": - pytest.main([__file__]) From 45d2fa79dbcd80be8452943b639e2710046dd797 Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Sun, 8 Nov 2026 10:42:06 -0500 Subject: [PATCH 2/2] Bump to v2.0.0 Removing public client methods is a breaking change. Co-Authored-By: Claude Opus 5.5 --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4df82e7..9fbff08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cvec" -version = "1.5.3" +version = "2.0.0" description = "SDK for CVector Energy" authors = [{ name = "CVector", email = "support@cvector.energy" }] readme = "README.md" diff --git a/uv.lock b/uv.lock index 68b5f4e..d317de3 100644 --- a/uv.lock +++ b/uv.lock @@ -80,7 +80,7 @@ wheels = [ [[package]] name = "cvec" -version = "1.5.3" +version = "2.0.0" source = { editable = "." } dependencies = [ { name = "brotli" },