Skip to content

Commit 7367ca7

Browse files
committed
fix(data profile): add try-exception in profile
1 parent 81be4d8 commit 7367ca7

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

alias/src/alias/agent/agents/data_source/_data_profiler_factory.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ def generate_profile(self) -> Dict[str, Any]:
4949
Returns:
5050
Dictionary containing the complete data profile
5151
"""
52-
self.data = self._read_data()
53-
content = self._generate_content(self.prompt, self.data)
54-
# content = self.prompt.format(data=self.data)
55-
res = self._call_model(content)
56-
self.profile = self._wrap_data_response(res)
52+
try:
53+
self.profile = self.generate_profile()
54+
self.data = self._read_data()
55+
content = self._generate_content(self.prompt, self.data)
56+
# content = self.prompt.format(data=self.data)
57+
res = self._call_model(content)
58+
self.profile = self._wrap_data_response(res)
59+
except Exception as e:
60+
print(f"Error generating profile: {e}")
61+
self.profile = {}
5762
return self.profile
5863

5964
@staticmethod
@@ -212,6 +217,7 @@ def _call_model(
212217
messages=messages,
213218
api_key=self.api_key,
214219
)
220+
# TODO: handle failed call of model
215221
response = response.output["choices"][0]["message"]["content"]
216222
# Clean and parse the JSON response from the LLM
217223
response = (
@@ -223,10 +229,8 @@ def _call_model(
223229
)
224230
return response
225231

226-
except Exception:
227-
import traceback
228-
229-
print(traceback.format_exc())
232+
except Exception as e:
233+
print(f"Error calling the model {self.model} with {e}")
230234
# Consider returning None or an empty dict on failure
231235
return {}
232236

alias/src/alias/agent/agents/data_source/data_source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ def __init__(
5858
self.endpoint = endpoint
5959
self.name = name
6060

61-
source_access_type = SOURCE_TYPE_TO_ACCESS_TYPE.get(source_type, \
62-
SourceAccessType.DIRECT)
61+
source_access_type = SOURCE_TYPE_TO_ACCESS_TYPE.get(
62+
source_type,
63+
SourceAccessType.DIRECT,
64+
)
6365

6466
self.source_access_type = source_access_type
6567
self.source_type = source_type

0 commit comments

Comments
 (0)