google-cloud-db-context-engineering 0.7.3__tar.gz → 0.7.4__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.
- {google_cloud_db_context_engineering-0.7.3/src/google_cloud_db_context_engineering.egg-info → google_cloud_db_context_engineering-0.7.4}/PKG-INFO +1 -1
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/pyproject.toml +2 -2
- google_cloud_db_context_engineering-0.7.4/src/google/cloud/db_context_enrichment/evaluate/db_generators/__init__.py +15 -0
- google_cloud_db_context_engineering-0.7.4/src/google/cloud/db_context_enrichment/evaluate/db_generators/bigtable.py +44 -0
- google_cloud_db_context_engineering-0.7.4/src/google/cloud/db_context_enrichment/evaluate/db_generators/custom.py +104 -0
- google_cloud_db_context_engineering-0.7.4/src/google/cloud/db_context_enrichment/evaluate/db_generators/firestore.py +60 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/evaluate_generator.py +83 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/main.py +12 -6
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4/src/google_cloud_db_context_engineering.egg-info}/PKG-INFO +1 -1
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google_cloud_db_context_engineering.egg-info/SOURCES.txt +3 -0
- google_cloud_db_context_engineering-0.7.3/src/google/cloud/db_context_enrichment/model/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/LICENSE +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/README.md +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/setup.cfg +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/common/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/common/config.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/common/context_mutator.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/common/context_store_client.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/common/context_validator.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/dataset/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/dataset/dataset_generator.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/db_generators/alloydb.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/db_generators/base.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/db_generators/mysql.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/db_generators/postgres.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/db_generators/spanner.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/evaluate/result_reader.py +0 -0
- {google_cloud_db_context_engineering-0.7.3/src/google/cloud/db_context_enrichment/evaluate/db_generators → google_cloud_db_context_engineering-0.7.4/src/google/cloud/db_context_enrichment/model}/__init__.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google/cloud/db_context_enrichment/model/context.py +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google_cloud_db_context_engineering.egg-info/dependency_links.txt +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google_cloud_db_context_engineering.egg-info/entry_points.txt +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google_cloud_db_context_engineering.egg-info/requires.txt +0 -0
- {google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/src/google_cloud_db_context_engineering.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "google-cloud-db-context-engineering"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.4"
|
|
4
4
|
description = "A FastMCP server for generating natural language to SQL templates from database schemas."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -45,7 +45,7 @@ dev = [
|
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
[tool.db-context-engineering]
|
|
48
|
-
toolbox_version = "1.
|
|
48
|
+
toolbox_version = "1.10.0"
|
|
49
49
|
evalbench_version = "1.17.0"
|
|
50
50
|
|
|
51
51
|
[tool.ruff]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .alloydb import AlloyDBConfigGenerator
|
|
2
|
+
from .base import BaseDBConfigGenerator
|
|
3
|
+
from .custom import CustomDBConfigGenerator
|
|
4
|
+
from .mysql import MySQLConfigGenerator
|
|
5
|
+
from .postgres import PostgresConfigGenerator
|
|
6
|
+
from .spanner import SpannerConfigGenerator
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"BaseDBConfigGenerator",
|
|
10
|
+
"AlloyDBConfigGenerator",
|
|
11
|
+
"CustomDBConfigGenerator",
|
|
12
|
+
"MySQLConfigGenerator",
|
|
13
|
+
"PostgresConfigGenerator",
|
|
14
|
+
"SpannerConfigGenerator",
|
|
15
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import yaml
|
|
4
|
+
|
|
5
|
+
from .base import BaseDBConfigGenerator
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BigtableConfigGenerator(BaseDBConfigGenerator):
|
|
9
|
+
"""
|
|
10
|
+
Dedicated generator mapping properties to explicit Bigtable configuration
|
|
11
|
+
topologies. Bypasses the GDA Python SDK to construct the model configuration
|
|
12
|
+
directly, as the SDK may lack native BigtableReference definitions.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
SOURCE_TYPE = "bigtable"
|
|
16
|
+
DIALECT = "bigtable"
|
|
17
|
+
REQUIRED_FIELDS = {"project", "instance"}
|
|
18
|
+
|
|
19
|
+
def generate_db_config(self) -> str:
|
|
20
|
+
db_config = {
|
|
21
|
+
"db_type": "bigtable",
|
|
22
|
+
"dialect": self.DIALECT,
|
|
23
|
+
"database_name": self.params.get("instance"),
|
|
24
|
+
"database_path": f"projects/{self.params.get('project')}/instances/{self.params.get('instance')}",
|
|
25
|
+
"instance_id": self.params.get("instance"),
|
|
26
|
+
"gcp_project_id": self.params.get("project"),
|
|
27
|
+
"max_executions_per_minute": 100,
|
|
28
|
+
}
|
|
29
|
+
return yaml.safe_dump(
|
|
30
|
+
db_config, sort_keys=False, default_flow_style=False
|
|
31
|
+
).strip()
|
|
32
|
+
|
|
33
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
34
|
+
return {
|
|
35
|
+
"bigtable_reference": {
|
|
36
|
+
"database_reference": {
|
|
37
|
+
"project_id": self.params.get("project"),
|
|
38
|
+
"instance_id": self.params.get("instance"),
|
|
39
|
+
},
|
|
40
|
+
"agent_context_reference": {
|
|
41
|
+
"context_set_id": context_set_id,
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
from .base import BaseDBConfigGenerator
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CustomDBConfigGenerator(BaseDBConfigGenerator):
|
|
10
|
+
"""
|
|
11
|
+
Pluggable generator mapping properties to custom evaluation configurations.
|
|
12
|
+
Enables arbitrary third-party or proprietary internal engines to be plugged
|
|
13
|
+
into the evaluation framework via dynamic connector and generator SPIs
|
|
14
|
+
without exposing engine-specific code or configuration schemas.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
SOURCE_TYPE = "custom"
|
|
18
|
+
DIALECT = "sql"
|
|
19
|
+
REQUIRED_FIELDS = set()
|
|
20
|
+
|
|
21
|
+
def __init__(self, params: dict[str, Any]):
|
|
22
|
+
self.params = params
|
|
23
|
+
if "project" not in self.params:
|
|
24
|
+
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT") or os.environ.get(
|
|
25
|
+
"GCP_PROJECT"
|
|
26
|
+
)
|
|
27
|
+
if project_id:
|
|
28
|
+
self.params["project"] = project_id
|
|
29
|
+
self.connector_class = params.get("connector_class", "")
|
|
30
|
+
self.generator_class = params.get("generator_class", "")
|
|
31
|
+
self.DIALECT = params.get("dialect", self.DIALECT)
|
|
32
|
+
self.validate()
|
|
33
|
+
|
|
34
|
+
def validate(self) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Validates that either connector_class or generator_class is specified.
|
|
37
|
+
"""
|
|
38
|
+
if not self.connector_class and not self.generator_class:
|
|
39
|
+
raise ValueError(
|
|
40
|
+
"Custom source configuration must specify at least 'connector_class' or 'generator_class'."
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def generate_db_config(self) -> str:
|
|
44
|
+
"""
|
|
45
|
+
Generates the db_config.yaml payload for custom connectors.
|
|
46
|
+
"""
|
|
47
|
+
db_config: dict[str, Any] = {
|
|
48
|
+
"db_type": self.params.get("db_type", "custom"),
|
|
49
|
+
"dialect": self.DIALECT,
|
|
50
|
+
}
|
|
51
|
+
if self.connector_class:
|
|
52
|
+
db_config["connector_class"] = self.connector_class
|
|
53
|
+
|
|
54
|
+
# Forward all non-meta parameters from tools.yaml source block
|
|
55
|
+
excluded_keys = {
|
|
56
|
+
"kind",
|
|
57
|
+
"name",
|
|
58
|
+
"type",
|
|
59
|
+
"connector_class",
|
|
60
|
+
"generator_class",
|
|
61
|
+
"dialect",
|
|
62
|
+
"db_type",
|
|
63
|
+
}
|
|
64
|
+
for key, value in self.params.items():
|
|
65
|
+
if key not in excluded_keys:
|
|
66
|
+
db_config[key] = value
|
|
67
|
+
|
|
68
|
+
return yaml.safe_dump(
|
|
69
|
+
db_config, sort_keys=False, default_flow_style=False
|
|
70
|
+
).strip()
|
|
71
|
+
|
|
72
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
73
|
+
"""
|
|
74
|
+
Datasource reference dictionary. Custom engines manage their own
|
|
75
|
+
schema references or context binding.
|
|
76
|
+
"""
|
|
77
|
+
return {}
|
|
78
|
+
|
|
79
|
+
def generate_model_config(self, context_set_id: str) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Generates model_config.yaml. If generator_class is specified, produces
|
|
82
|
+
a custom generator configuration for dynamic instantiation.
|
|
83
|
+
"""
|
|
84
|
+
if self.generator_class:
|
|
85
|
+
model_config: dict[str, Any] = {
|
|
86
|
+
"generator": "custom",
|
|
87
|
+
"generator_class": self.generator_class,
|
|
88
|
+
"context_set_id": context_set_id,
|
|
89
|
+
}
|
|
90
|
+
excluded_keys = {
|
|
91
|
+
"kind",
|
|
92
|
+
"name",
|
|
93
|
+
"type",
|
|
94
|
+
"connector_class",
|
|
95
|
+
"generator_class",
|
|
96
|
+
}
|
|
97
|
+
for key, value in self.params.items():
|
|
98
|
+
if key not in excluded_keys:
|
|
99
|
+
model_config[key] = value
|
|
100
|
+
return yaml.safe_dump(
|
|
101
|
+
model_config, sort_keys=False, default_flow_style=False
|
|
102
|
+
).strip()
|
|
103
|
+
|
|
104
|
+
return super().generate_model_config(context_set_id)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import yaml
|
|
4
|
+
|
|
5
|
+
from .base import BaseDBConfigGenerator
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FirestoreConfigGenerator(BaseDBConfigGenerator):
|
|
9
|
+
"""
|
|
10
|
+
Dedicated generator mapping properties to Firestore (MongoDB query dialect)
|
|
11
|
+
topologies utilized by both EvalBench binaries and GDA REST API.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
SOURCE_TYPE = "firestore"
|
|
15
|
+
DIALECT = "mongodb"
|
|
16
|
+
REQUIRED_FIELDS = BaseDBConfigGenerator.REQUIRED_FIELDS | {
|
|
17
|
+
"project",
|
|
18
|
+
"database",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def __init__(self, params: dict[str, Any]):
|
|
22
|
+
super().__init__(params)
|
|
23
|
+
self.project = params.get("project")
|
|
24
|
+
self.database = params.get("database")
|
|
25
|
+
self.connection_string = params.get("connection_string")
|
|
26
|
+
self.collection_ids = params.get("collection_ids") or params.get("table_ids")
|
|
27
|
+
|
|
28
|
+
def generate_db_config(self) -> str:
|
|
29
|
+
db_type = "mongodb"
|
|
30
|
+
|
|
31
|
+
db_config = {
|
|
32
|
+
"db_type": db_type,
|
|
33
|
+
"dialect": self.DIALECT,
|
|
34
|
+
"database_name": self.database,
|
|
35
|
+
"database_path": "",
|
|
36
|
+
"firestore_database": f"projects/{self.project}/databases/{self.database}",
|
|
37
|
+
"max_executions_per_minute": 120,
|
|
38
|
+
}
|
|
39
|
+
if self.connection_string:
|
|
40
|
+
db_config["connection_string"] = self.connection_string
|
|
41
|
+
|
|
42
|
+
return yaml.safe_dump(
|
|
43
|
+
db_config, sort_keys=False, default_flow_style=False
|
|
44
|
+
).strip()
|
|
45
|
+
|
|
46
|
+
def build_datasource_reference(self, context_set_id: str) -> dict[str, Any]:
|
|
47
|
+
db_ref: dict[str, Any] = {
|
|
48
|
+
"project_id": self.project,
|
|
49
|
+
"database_id": self.database,
|
|
50
|
+
}
|
|
51
|
+
if self.collection_ids:
|
|
52
|
+
db_ref["collection_ids"] = self.collection_ids
|
|
53
|
+
|
|
54
|
+
ref: dict[str, Any] = {"firestore_reference": {"database_reference": db_ref}}
|
|
55
|
+
if context_set_id:
|
|
56
|
+
ref["firestore_reference"]["agent_context_reference"] = {
|
|
57
|
+
"context_set_id": context_set_id
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return ref
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import importlib
|
|
1
2
|
import json
|
|
3
|
+
import logging
|
|
2
4
|
import os
|
|
3
5
|
import re
|
|
6
|
+
import sys
|
|
4
7
|
import textwrap
|
|
8
|
+
import threading
|
|
5
9
|
from typing import Any
|
|
6
10
|
|
|
7
11
|
import yaml
|
|
@@ -10,10 +14,15 @@ from google.cloud.db_context_enrichment.common import config
|
|
|
10
14
|
|
|
11
15
|
from .db_generators.alloydb import AlloyDBConfigGenerator
|
|
12
16
|
from .db_generators.base import BaseDBConfigGenerator
|
|
17
|
+
from .db_generators.bigtable import BigtableConfigGenerator
|
|
18
|
+
from .db_generators.custom import CustomDBConfigGenerator
|
|
19
|
+
from .db_generators.firestore import FirestoreConfigGenerator
|
|
13
20
|
from .db_generators.mysql import MySQLConfigGenerator
|
|
14
21
|
from .db_generators.postgres import PostgresConfigGenerator
|
|
15
22
|
from .db_generators.spanner import SpannerConfigGenerator
|
|
16
23
|
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
17
26
|
# Constants for EvalBench configuration filenames
|
|
18
27
|
DB_CONFIG_NAME = "db_config.yaml"
|
|
19
28
|
MODEL_CONFIG_NAME = "model_config.yaml"
|
|
@@ -203,19 +212,93 @@ def _interpolate_env_vars(raw_yaml: str) -> str:
|
|
|
203
212
|
return pattern.sub(replacer, raw_yaml)
|
|
204
213
|
|
|
205
214
|
|
|
215
|
+
_SYS_PATH_LOCK = threading.Lock()
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _import_with_cwd_fallback(mod_name: str):
|
|
219
|
+
"""Imports mod_name, falling back to appending os.getcwd() to sys.path."""
|
|
220
|
+
try:
|
|
221
|
+
return importlib.import_module(mod_name)
|
|
222
|
+
except ModuleNotFoundError as e:
|
|
223
|
+
if e.name is None or not (
|
|
224
|
+
mod_name == e.name or mod_name.startswith(e.name + ".")
|
|
225
|
+
):
|
|
226
|
+
raise
|
|
227
|
+
cwd = os.path.abspath(os.getcwd())
|
|
228
|
+
with _SYS_PATH_LOCK:
|
|
229
|
+
if not any(os.path.abspath(p or cwd) == cwd for p in sys.path):
|
|
230
|
+
# Keep cwd at the end of sys.path so lazy runtime imports work
|
|
231
|
+
# without shadowing standard library or installed packages.
|
|
232
|
+
sys.path.append(cwd)
|
|
233
|
+
importlib.invalidate_caches()
|
|
234
|
+
return importlib.import_module(mod_name)
|
|
235
|
+
|
|
236
|
+
|
|
206
237
|
def _get_db_generator(params: dict[str, Any]) -> BaseDBConfigGenerator:
|
|
207
238
|
"""Factory function to build the correct Evaluation Generator."""
|
|
208
239
|
source_type = params.get("type", "").lower()
|
|
209
240
|
|
|
210
241
|
generators = {
|
|
211
242
|
AlloyDBConfigGenerator.SOURCE_TYPE: AlloyDBConfigGenerator,
|
|
243
|
+
BigtableConfigGenerator.SOURCE_TYPE: BigtableConfigGenerator,
|
|
212
244
|
PostgresConfigGenerator.SOURCE_TYPE: PostgresConfigGenerator,
|
|
213
245
|
MySQLConfigGenerator.SOURCE_TYPE: MySQLConfigGenerator,
|
|
214
246
|
SpannerConfigGenerator.SOURCE_TYPE: SpannerConfigGenerator,
|
|
215
247
|
"spanner-postgres": SpannerConfigGenerator,
|
|
216
248
|
"spanner-pg": SpannerConfigGenerator,
|
|
249
|
+
FirestoreConfigGenerator.SOURCE_TYPE: FirestoreConfigGenerator,
|
|
250
|
+
CustomDBConfigGenerator.SOURCE_TYPE: CustomDBConfigGenerator,
|
|
217
251
|
}
|
|
218
252
|
|
|
253
|
+
# Dynamically register external custom database configuration generators.
|
|
254
|
+
# AUTOCTX_CUSTOM_GENERATORS holds a dotted Python module import path
|
|
255
|
+
# (e.g., "my_package.custom_generators") that exposes a
|
|
256
|
+
# CUSTOM_GENERATORS: dict[str, type[BaseDBConfigGenerator]] mapping
|
|
257
|
+
# custom tools.yaml source types to BaseDBConfigGenerator subclasses.
|
|
258
|
+
custom_gens = {}
|
|
259
|
+
custom_plugin = os.environ.get("AUTOCTX_CUSTOM_GENERATORS")
|
|
260
|
+
if custom_plugin:
|
|
261
|
+
try:
|
|
262
|
+
mod = _import_with_cwd_fallback(custom_plugin)
|
|
263
|
+
custom_gens = getattr(mod, "CUSTOM_GENERATORS", None)
|
|
264
|
+
if custom_gens is None:
|
|
265
|
+
raise AttributeError(
|
|
266
|
+
f"Custom generator module '{custom_plugin}' must define 'CUSTOM_GENERATORS' dict."
|
|
267
|
+
)
|
|
268
|
+
if not isinstance(custom_gens, dict):
|
|
269
|
+
raise TypeError(
|
|
270
|
+
f"CUSTOM_GENERATORS in '{custom_plugin}' must be a dictionary, "
|
|
271
|
+
f"got {type(custom_gens).__name__}."
|
|
272
|
+
)
|
|
273
|
+
generators.update(custom_gens)
|
|
274
|
+
except Exception as e:
|
|
275
|
+
logger.error(
|
|
276
|
+
"Failed to load custom generators from plugin module '%s': %s",
|
|
277
|
+
custom_plugin,
|
|
278
|
+
e,
|
|
279
|
+
)
|
|
280
|
+
raise RuntimeError(
|
|
281
|
+
f"Failed to load custom generators from plugin module '{custom_plugin}': {e}"
|
|
282
|
+
) from e
|
|
283
|
+
|
|
284
|
+
# If the source type is not handled by an external AUTOCTX_CUSTOM_GENERATORS
|
|
285
|
+
# plugin, allow inline connector_class / generator_class in tools.yaml to
|
|
286
|
+
# route directly to CustomDBConfigGenerator.
|
|
287
|
+
if source_type not in custom_gens and (
|
|
288
|
+
"connector_class" in params or "generator_class" in params
|
|
289
|
+
):
|
|
290
|
+
if (
|
|
291
|
+
source_type in generators
|
|
292
|
+
and source_type != CustomDBConfigGenerator.SOURCE_TYPE
|
|
293
|
+
):
|
|
294
|
+
logger.warning(
|
|
295
|
+
"Source type '%s' is being overridden by custom connector_class '%s' / generator_class '%s'.",
|
|
296
|
+
source_type,
|
|
297
|
+
params.get("connector_class"),
|
|
298
|
+
params.get("generator_class"),
|
|
299
|
+
)
|
|
300
|
+
return CustomDBConfigGenerator(params)
|
|
301
|
+
|
|
219
302
|
if source_type not in generators:
|
|
220
303
|
supported = ", ".join(generators.keys())
|
|
221
304
|
raise ValueError(
|
|
@@ -74,7 +74,7 @@ def generate_evalbench_configs(
|
|
|
74
74
|
dataset_path: The absolute path to the golden dataset file in the simplified user-facing format (JSON list of objects with keys: "id", "database", "nlq", "golden_sql").
|
|
75
75
|
context_set_id: Full ContextSet resource name to evaluate against.
|
|
76
76
|
toolbox_config_path: The absolute path to the tools.yaml configuration file.
|
|
77
|
-
toolbox_source_name: The name of the database source to use inside tools.yaml. The underlying source block must use a supported 'type' (cloud-sql-postgres, cloud-sql-mysql, spanner, alloydb-postgres).
|
|
77
|
+
toolbox_source_name: The name of the database source to use inside tools.yaml. The underlying source block must use a supported 'type' (cloud-sql-postgres, cloud-sql-mysql, spanner, alloydb-postgres, or custom).
|
|
78
78
|
|
|
79
79
|
Returns:
|
|
80
80
|
A message indicating that the configuration files were successfully created.
|
|
@@ -103,13 +103,14 @@ def generate_upload_url(
|
|
|
103
103
|
|
|
104
104
|
Args:
|
|
105
105
|
db_engine: The database engine. Accepted values are 'alloydb',
|
|
106
|
-
'cloudsql', or '
|
|
107
|
-
field in the tools.yaml file. For example,
|
|
108
|
-
becomes 'alloydb',
|
|
106
|
+
'cloudsql', 'spanner', or 'bigtable'. This can be derived from
|
|
107
|
+
the 'kind' field in the tools.yaml file. For example,
|
|
108
|
+
'alloydb-postgres' becomes 'alloydb', 'cloud-sql-postgres'
|
|
109
|
+
becomes 'cloudsql', and 'bigtable' becomes 'bigtable'.
|
|
109
110
|
project_id: The Google Cloud project ID.
|
|
110
111
|
location: The location of the AlloyDB cluster.
|
|
111
112
|
cluster_id: The ID of the AlloyDB cluster.
|
|
112
|
-
instance_id: The ID of the Cloud SQL or
|
|
113
|
+
instance_id: The ID of the Cloud SQL, Spanner, or Bigtable instance.
|
|
113
114
|
database_id: The ID of the Spanner database.
|
|
114
115
|
|
|
115
116
|
Returns:
|
|
@@ -130,8 +131,13 @@ def generate_upload_url(
|
|
|
130
131
|
return f"https://console.cloud.google.com/spanner/instances/{instance_id}/databases/{database_id}/details/query?project={project_id}"
|
|
131
132
|
else:
|
|
132
133
|
return "Error: Missing instance_id, database_id, or project_id for spanner."
|
|
134
|
+
elif db_engine == "bigtable":
|
|
135
|
+
if instance_id and project_id:
|
|
136
|
+
return f"https://console.cloud.google.com/bigtable/instances/{instance_id}/overview?project={project_id}"
|
|
137
|
+
else:
|
|
138
|
+
return "Error: Missing instance_id or project_id for bigtable."
|
|
133
139
|
else:
|
|
134
|
-
return "Error: Invalid db_engine. Must be one of 'alloydb', 'cloudsql', or '
|
|
140
|
+
return "Error: Invalid db_engine. Must be one of 'alloydb', 'cloudsql', 'spanner', or 'bigtable'."
|
|
135
141
|
|
|
136
142
|
|
|
137
143
|
# NOTE: `@mcp.tool` is intentionally NOT applied to upload_context_set /
|
|
@@ -16,6 +16,9 @@ src/google/cloud/db_context_enrichment/evaluate/result_reader.py
|
|
|
16
16
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/__init__.py
|
|
17
17
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/alloydb.py
|
|
18
18
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/base.py
|
|
19
|
+
src/google/cloud/db_context_enrichment/evaluate/db_generators/bigtable.py
|
|
20
|
+
src/google/cloud/db_context_enrichment/evaluate/db_generators/custom.py
|
|
21
|
+
src/google/cloud/db_context_enrichment/evaluate/db_generators/firestore.py
|
|
19
22
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/mysql.py
|
|
20
23
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/postgres.py
|
|
21
24
|
src/google/cloud/db_context_enrichment/evaluate/db_generators/spanner.py
|
google_cloud_db_context_engineering-0.7.3/src/google/cloud/db_context_enrichment/model/__init__.py
DELETED
|
File without changes
|
{google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/LICENSE
RENAMED
|
File without changes
|
{google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/README.md
RENAMED
|
File without changes
|
{google_cloud_db_context_engineering-0.7.3 → google_cloud_db_context_engineering-0.7.4}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|