Skip to content

Commit 3515327

Browse files
committed
flatten profile names
1 parent 0868e53 commit 3515327

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sam-sql-analytics-db-tool/src/sam_sql_analytics_db_tool/services/profile_history.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ def __init__(self, tool_name: str):
1313
"""Initialize profile history service.
1414
1515
Args:
16-
tool_name: Tool instance name (for artifact path scoping)
16+
tool_name: Tool instance name (for artifact filename scoping)
1717
"""
1818
self.tool_name = tool_name
19-
self.base_path = f"analytics_profiles/{tool_name}"
19+
# Use flat storage (no subdirectories) for artifact service compatibility
20+
self.filename_prefix = f"analytics_profile_{tool_name}_"
2021

2122
async def save_profile(
2223
self,
@@ -36,7 +37,8 @@ async def save_profile(
3637
from solace_agent_mesh.agent.utils.artifact_helpers import save_artifact_with_metadata
3738
from datetime import datetime as dt, timezone
3839

39-
filename = f"{self.base_path}/profile_{date}.json"
40+
# Flat filename: analytics_profile_analytics_db_2026-01-06.json
41+
filename = f"{self.filename_prefix}{date}.json"
4042

4143
await save_artifact_with_metadata(
4244
artifact_service=artifact_service,
@@ -72,7 +74,8 @@ async def get_profile(
7274
Returns:
7375
Profile dict or None if not found
7476
"""
75-
filename = f"{self.base_path}/profile_{date}.json"
77+
# Flat filename
78+
filename = f"{self.filename_prefix}{date}.json"
7679

7780
try:
7881
artifact = await artifact_service.load_artifact(
@@ -111,7 +114,7 @@ async def list_profiles(
111114
List of date strings (YYYY-MM-DD), sorted newest first
112115
"""
113116
try:
114-
# Get all artifact keys (no prefix filtering available)
117+
# Get all artifact keys (returns flat list of filenames)
115118
artifact_keys = await artifact_service.list_artifact_keys(
116119
app_name=app_name,
117120
user_id="global",
@@ -121,10 +124,10 @@ async def list_profiles(
121124
# Filter for our profile files and extract dates
122125
dates = []
123126
for filename in artifact_keys:
124-
# Match: analytics_profiles/analytics_db/profile_2026-01-06.json
125-
if self.base_path in filename and "profile_" in filename and filename.endswith(".json"):
126-
# Extract date from filename
127-
date_str = filename.split("profile_")[1].replace(".json", "")
127+
# Match flat filenames: analytics_profile_analytics_db_2026-01-06.json
128+
if filename.startswith(self.filename_prefix) and filename.endswith(".json"):
129+
# Extract date from: analytics_profile_analytics_db_2026-01-06.json
130+
date_str = filename.replace(self.filename_prefix, "").replace(".json", "")
128131
dates.append(date_str)
129132

130133
# Sort newest first

0 commit comments

Comments
 (0)