Skip to content

Commit fbf6d83

Browse files
[FIX] Handle None response model in fetch_outputs_with_tree
When the trace server returns a non-200 status for both datatree and timegraph tree endpoints, response.model is None. Accessing .model on None caused an AttributeError, failing CI tests.
1 parent e76ab3f commit fbf6d83

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

tmll/tmll_client.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tmll.common.models.timegraph.timegraph import TimeGraph
1717
from tmll.common.models.trace import Trace
1818
from tmll.common.models.experiment import Experiment
19+
from tmll.common.models.tree.node import NodeTree
1920
from tmll.common.models.tree.tree import Tree
2021

2122
from tmll.tsp.tsp.indexing_status import IndexingStatus
@@ -221,7 +222,22 @@ def fetch_outputs_with_tree(self, experiment: Experiment, custom_output_ids: Opt
221222

222223
# Get the trees of the outputs
223224
match output.type:
224-
case "TABLE" | "DATA_TREE":
225+
case "TABLE":
226+
response = self.tsp_client.fetch_virtual_table_columns(exp_uuid=experiment.uuid, output_id=output.id)
227+
if response.status_code != 200:
228+
self.logger.error(f"Failed to fetch table columns. Error: {response.status_text}")
229+
continue
230+
231+
columns = response.model.model.columns
232+
tree = Tree([NodeTree(name=col.name, id=col.id, parent_id=-1) for col in columns])
233+
fetched_outputs.append({
234+
"output": output,
235+
"tree": tree
236+
})
237+
self.logger.info(f"Output '{output.name}' and its tree fetched successfully.")
238+
continue
239+
240+
case "DATA_TREE":
225241
while True:
226242
response = self.tsp_client.fetch_datatree(exp_uuid=experiment.uuid, output_id=output.id)
227243
if response.status_code != 200:
@@ -265,6 +281,10 @@ def fetch_outputs_with_tree(self, experiment: Experiment, custom_output_ids: Opt
265281
self.logger.warning(f"Output type '{output.type}' is not supported.")
266282
continue
267283

284+
if response.model is None:
285+
self.logger.warning(f"Tree of the output '{output.name}' is None.")
286+
continue
287+
268288
model = response.model.model
269289
if model is None:
270290
self.logger.warning(f"Tree of the output '{output.name}' is None.")

0 commit comments

Comments
 (0)