Skip to content

Commit d185b06

Browse files
feat(data-model-discovery-agent): fix lint issues
1 parent c4354cd commit d185b06

File tree

17 files changed

+121
-122
lines changed

17 files changed

+121
-122
lines changed

agent-app/app/agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
mosaic_rag_agent_presales,
2929
)
3030
from .sub_agents.compliance_and_security_baseline_agent import compliance_agent
31+
from .sub_agents.data_model_discovery_agent import data_model_discovery_agent
3132
from .sub_agents.detailed_architecture_design_agent import (
3233
detailed_architecture_design_agent,
3334
)
@@ -38,8 +39,6 @@
3839
from .sub_agents.recommendation_agent import recommendation_agent
3940
from .sub_agents.strategy_recommender_agent import strategy_recommender_agent
4041
from .sub_agents.tech_stack_profiler_agent import tech_stack_profiler
41-
from .sub_agents.data_model_discovery_agent import data_model_discovery_agent
42-
4342
from .tools import (
4443
transfer_to_capability_mapper_agent_tool,
4544
transfer_to_discovery_agent_tool,

agent-app/app/sub_agents/data_model_discovery_agent/agent.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import logging
2+
13
from google.adk.agents.llm_agent import LlmAgent
24
from google.adk.agents.readonly_context import ReadonlyContext
5+
6+
from app.config import MODEL
7+
8+
from .sub_agents.data_profiling_agent.agent import data_profiling_agent
39
from .sub_agents.database_cred_agent.agent import database_cred_agent
4-
from .sub_agents.schema_introspection_agent.agent import schema_introspection_agent
510
from .sub_agents.qa_agent.agent import qa_agent
6-
from .sub_agents.data_profiling_agent.agent import data_profiling_agent
711
from .sub_agents.reporting_agent.agent import reporting_agent
8-
9-
import logging
10-
import json
12+
from .sub_agents.schema_introspection_agent.agent import schema_introspection_agent
1113

1214
logger = logging.getLogger(__name__)
1315
logging.basicConfig(level=logging.INFO)
@@ -200,7 +202,7 @@ def root_agent_instruction(ctx: ReadonlyContext) -> str:
200202

201203

202204
data_model_discovery_agent = LlmAgent(
203-
model="gemini-2.5-flash",
205+
model=MODEL,
204206
name="data_model_discovery_agent",
205207
description=(
206208
"A helpful root agent that orchestrates sub-agents to introspect and profile legacy databases."

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/data_profiling_agent/agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from google.adk.agents.llm_agent import LlmAgent
2+
3+
from app.config import MODEL
4+
25
from .tools import profile_schema_data
3-
from ..qa_agent.agent import qa_agent
46

57
data_profiling_agent = LlmAgent(
6-
model="gemini-2.5-flash",
8+
model=MODEL,
79
name="data_profiling_agent",
810
description="Profiles data quality for the selected schema and then calls QA agent to summarize.",
911
instruction="""

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/data_profiling_agent/tools.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import logging
2-
from typing import Dict, Any
3-
from google.adk.tools import ToolContext
4-
import psycopg2
2+
from typing import Any
3+
54
import mysql.connector
5+
import psycopg2
66
import pyodbc
7+
from google.adk.tools import ToolContext
8+
79
from .utils import (
8-
postgres_profiling_utils,
9-
mysql_profiling_utils,
1010
mssql_profiling_utils,
11+
mysql_profiling_utils,
12+
postgres_profiling_utils,
1113
)
1214

1315
logger = logging.getLogger(__name__)
1416
logging.basicConfig(level=logging.INFO)
1517

1618

17-
def _get_db_connection(metadata: Dict[str, Any], password: str) -> Any:
19+
def _get_db_connection(metadata: dict[str, Any], password: str) -> Any:
1820
db_type = metadata.get("db_type")
1921
host = metadata.get("host")
2022
port = int(metadata.get("port"))
@@ -39,8 +41,8 @@ def _get_db_connection(metadata: Dict[str, Any], password: str) -> Any:
3941

4042

4143
async def profile_schema_data(
42-
tool_context: ToolContext, args: Dict[str, Any]
43-
) -> Dict[str, Any]:
44+
tool_context: ToolContext, args: dict[str, Any]
45+
) -> dict[str, Any]:
4446
"""
4547
Profiles the data in the selected schema based on the schema structure.
4648
Calculates nullability, cardinality, orphan records, and type anomalies.
@@ -104,7 +106,7 @@ async def profile_schema_data(
104106
except Exception as e:
105107
logger.error(f"Error during data profiling: {e}", exc_info=True)
106108
return {
107-
"error": f"Failed to profile data for {db_type} ({schema_name}): {str(e)}"
109+
"error": f"Failed to profile data for {db_type} ({schema_name}): {e!s}"
108110
}
109111
finally:
110112
if conn:

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/data_profiling_agent/utils/mssql_profiling_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import logging
2-
from typing import Dict, Any, List
3-
import pyodbc
4-
from decimal import Decimal
2+
from typing import Any
53

64
logger = logging.getLogger(__name__)
75

86

9-
def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
7+
def _execute_query(conn: Any, query: str) -> list[dict[str, Any]]:
108
"""Executes a SQL query and returns results as a list of dicts for SQL Server."""
119
cursor = conn.cursor()
1210
try:
1311
cursor.execute(query)
1412
if cursor.description:
1513
columns = [column[0] for column in cursor.description]
1614
rows = cursor.fetchall()
17-
return [dict(zip(columns, row)) for row in rows]
15+
return [dict(zip(columns, row, strict=False)) for row in rows]
1816
return []
1917
finally:
2018
cursor.close()
@@ -23,9 +21,9 @@ def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
2321
def profile_mssql_data(
2422
conn: Any,
2523
schema_name: str,
26-
schema_structure: Dict[str, Any],
24+
schema_structure: dict[str, Any],
2725
sample_size: int = 10000,
28-
) -> Dict[str, Any]:
26+
) -> dict[str, Any]:
2927
profile_results = {
3028
"nullability": {},
3129
"cardinality": {},

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/data_profiling_agent/utils/mysql_profiling_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging
2-
from typing import Dict, Any, List
2+
from typing import Any
33

44
logger = logging.getLogger(__name__)
55

66

7-
def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
7+
def _execute_query(conn: Any, query: str) -> list[dict[str, Any]]:
88
cursor = conn.cursor(dictionary=True)
99
try:
1010
cursor.execute(query)
@@ -16,9 +16,9 @@ def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
1616
def profile_mysql_data(
1717
conn: Any,
1818
schema_name: str,
19-
schema_structure: Dict[str, Any],
19+
schema_structure: dict[str, Any],
2020
sample_size: int = 10000,
21-
) -> Dict[str, Any]:
21+
) -> dict[str, Any]:
2222
try:
2323
conn.database = schema_name
2424
except Exception as e:

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/data_profiling_agent/utils/postgres_profiling_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import logging
2-
from typing import Dict, Any, List
3-
import psycopg2
4-
from decimal import Decimal
2+
from typing import Any
53

64
logger = logging.getLogger(__name__)
75

86

9-
def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
7+
def _execute_query(conn: Any, query: str) -> list[dict[str, Any]]:
108
"""Executes a SQL query and returns results as a list of dicts for PostgreSQL."""
119
cursor = conn.cursor()
1210
try:
@@ -15,7 +13,7 @@ def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
1513
if cursor.description:
1614
columns = [desc[0] for desc in cursor.description]
1715
rows = cursor.fetchall()
18-
return [dict(zip(columns, row)) for row in rows]
16+
return [dict(zip(columns, row, strict=False)) for row in rows]
1917
return []
2018
finally:
2119
cursor.close()
@@ -24,9 +22,9 @@ def _execute_query(conn: Any, query: str) -> List[Dict[str, Any]]:
2422
def profile_postgres_data(
2523
conn: Any,
2624
schema_name: str,
27-
schema_structure: Dict[str, Any],
25+
schema_structure: dict[str, Any],
2826
sample_size: int = 10000,
29-
) -> Dict[str, Any]:
27+
) -> dict[str, Any]:
3028
profile_results = {
3129
"nullability": {},
3230
"cardinality": {},

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/database_cred_agent/agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from google.adk.agents.llm_agent import LlmAgent
2-
from .tools import validate_db_connection
32

3+
from app.config import MODEL
4+
5+
from .tools import validate_db_connection
46

57
database_cred_agent = LlmAgent(
6-
model="gemini-2.5-flash",
8+
model=MODEL,
79
name="database_cred_agent",
810
description="A helpful assistant that collects and validates database connection details, and lists available schemas.",
911
instruction="""

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/database_cred_agent/tools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from google.adk.tools import ToolContext
21
import logging
3-
from typing import Dict, Any, List
2+
from typing import Any
43

5-
import psycopg2
64
import mysql.connector
5+
import psycopg2
76
import pyodbc
7+
from google.adk.tools import ToolContext
88

99
logger = logging.getLogger(__name__)
1010
logging.basicConfig(level=logging.INFO)
1111

1212

13-
def _get_schemas(conn: Any, db_type: str) -> List[str]:
13+
def _get_schemas(conn: Any, db_type: str) -> list[str]:
1414
"""Fetches list of schemas/databases based on db type."""
1515
schemas = []
1616
cursor = conn.cursor()
@@ -52,8 +52,8 @@ def _get_schemas(conn: Any, db_type: str) -> List[str]:
5252

5353

5454
async def validate_db_connection(
55-
connection_details: Dict[str, Any], tool_context: ToolContext
56-
) -> Dict[str, Any]:
55+
connection_details: dict[str, Any], tool_context: ToolContext
56+
) -> dict[str, Any]:
5757
"""Validates a database connection for PostgreSQL, MySQL, or MSSQL,
5858
fetches available schemas, and saves metadata to session memory.
5959

agent-app/app/sub_agents/data_model_discovery_agent/sub_agents/qa_agent/agent.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import json
22
from decimal import Decimal
3+
34
from google.adk.agents.llm_agent import LlmAgent
45
from google.adk.agents.readonly_context import ReadonlyContext
56

7+
from app.config import MODEL
8+
69

710
def json_encoder_default(obj):
811
if isinstance(obj, Decimal):
912
return str(obj)
1013
raise TypeError(f"Object of type {obj.__class__.__name__} is not JSON serializable")
1114

12-
1315
def qa_agent_instruction(ctx: ReadonlyContext) -> str:
1416
"""Builds the QA agent's instruction for schema and data profiling queries."""
1517

@@ -30,9 +32,7 @@ def qa_agent_instruction(ctx: ReadonlyContext) -> str:
3032
"""
3133

3234
try:
33-
schema_json = json.dumps(
34-
schema_structure, indent=2, default=json_encoder_default
35-
)
35+
schema_json = json.dumps(schema_structure, indent=2, default=json_encoder_default)
3636
except Exception as e:
3737
schema_json = f"Error serializing schema structure: {e}"
3838

@@ -45,15 +45,11 @@ def qa_agent_instruction(ctx: ReadonlyContext) -> str:
4545
"Nullability": data_profile.get("nullability", "Not available"),
4646
"Cardinality": data_profile.get("cardinality", "Not available"),
4747
"Orphan Records": data_profile.get("orphan_records", "Not available"),
48-
"Type Anomalies": data_profile.get("type_anomalies", "Not available"),
48+
"Type Anomalies": data_profile.get("type_anomalies", "Not available")
4949
}
50-
profile_message = json.dumps(
51-
profile_summary, indent=2, default=json_encoder_default
52-
)
50+
profile_message = json.dumps(profile_summary, indent=2, default=json_encoder_default)
5351
except Exception:
54-
profile_message = (
55-
"Data profiling results exist but could not be summarized."
56-
)
52+
profile_message = "Data profiling results exist but could not be summarized."
5753
else:
5854
profile_message = (
5955
"Data profiling has not been run yet. "
@@ -97,11 +93,10 @@ def qa_agent_instruction(ctx: ReadonlyContext) -> str:
9793
Always respond in clear, human-readable sentences. If profiling data is missing, offer to run profiling on a sample of up to 10,000 rows to provide a summary.
9894
"""
9995

100-
10196
qa_agent = LlmAgent(
102-
model="gemini-2.5-flash",
103-
name="qa_agent",
104-
description="Answers natural language questions about the discovered database schema structure and data profiling results.",
97+
model=MODEL,
98+
name='qa_agent',
99+
description='Answers natural language questions about the discovered database schema structure and data profiling results.',
105100
instruction=qa_agent_instruction,
106-
tools=[],
101+
tools=[]
107102
)

0 commit comments

Comments
 (0)