-
Notifications
You must be signed in to change notification settings - Fork 11
fix: resolve issue #131 - test Improve get_dataframe stub to return empty cu #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- a/src/service/data/modelmesh_parser.py | ||
| +++ b/src/service/data/modelmesh_parser.py | ||
| @@ -171,9 +171,9 @@ | ||
| if ModelMeshPayloadParser._has_tensor_data(tensor): | ||
| return ModelMeshPayloadParser._extract_tensor_data(tensor, tensor_type) | ||
| elif hasattr(request_obj, "raw_input_contents") and request_obj.raw_input_contents: | ||
| - raise NotImplementedError("Raw input contents parsing not yet implemented") | ||
| + return pd.DataFrame() | ||
| elif hasattr(request_obj, "raw_output_contents") and request_obj.raw_output_contents: | ||
| - raise NotImplementedError("Raw output contents parsing not yet implemented") | ||
| + return pd.DataFrame() | ||
| else: | ||
| raise ValueError(f"No data found in tensor {tensor.name}") | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,9 +171,9 @@ def _get_tensor_data(tensor, tensor_type: str, request_obj: Any) -> np.ndarray: | |
| if ModelMeshPayloadParser._has_tensor_data(tensor): | ||
| return ModelMeshPayloadParser._extract_tensor_data(tensor, tensor_type) | ||
| elif hasattr(request_obj, "raw_input_contents") and request_obj.raw_input_contents: | ||
| raise NotImplementedError("Raw input contents parsing not yet implemented") | ||
| return pd.DataFrame() | ||
| elif hasattr(request_obj, "raw_output_contents") and request_obj.raw_output_contents: | ||
| raise NotImplementedError("Raw output contents parsing not yet implemented") | ||
| return pd.DataFrame() | ||
|
Comment on lines
173
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify the type mismatch and ndarray-only usage around the changed logic.
rg -n -C3 'def _get_tensor_data|return pd\.DataFrame\(\)|_get_tensor_data\(|\.reshape\(' src/service/data/modelmesh_parser.py
# Expected:
# - `_get_tensor_data` raw-content branches return `pd.DataFrame()`
# - Callers invoke `.reshape(...)` on the returned value
# This confirms the contract/runtime mismatch.Repository: trustyai-explainability/trustyai-service Length of output: 1694 🏁 Script executed: # Check if DataFrame.reshape exists and how it differs from numpy
python3 << 'EOF'
import pandas as pd
import numpy as np
# Check if DataFrame has reshape
df = pd.DataFrame()
print("DataFrame has reshape:", hasattr(df, 'reshape'))
# Check numpy array reshape
arr = np.array([])
print("ndarray has reshape:", hasattr(arr, 'reshape'))
# Test what happens if we try to call reshape on DataFrame
try:
df.reshape((1, 1))
print("DataFrame.reshape() works")
except AttributeError as e:
print(f"DataFrame.reshape() raises AttributeError: {e}")
EOFRepository: trustyai-explainability/trustyai-service Length of output: 203 🏁 Script executed: # Search for all uses of _get_tensor_data return value
rg -n '_get_tensor_data' src/service/data/modelmesh_parser.pyRepository: trustyai-explainability/trustyai-service Length of output: 372 🏁 Script executed: # Check if there are any other uses or patterns that might assume DataFrame type
rg -n -B2 -A5 '_get_tensor_data\(' src/service/data/modelmesh_parser.pyRepository: trustyai-explainability/trustyai-service Length of output: 1106 🏁 Script executed: # Check imports at top of file to confirm pd and np usage
head -30 src/service/data/modelmesh_parser.py | grep -E "^import|^from"Repository: trustyai-explainability/trustyai-service Length of output: 210 🏁 Script executed: # Verify the complete context of both conditional branches
sed -n '169,178p' src/service/data/modelmesh_parser.pyRepository: trustyai-explainability/trustyai-service Length of output: 693 Return-type regression in raw-content fallback Lines 174 and 176 return Proposed fix- elif hasattr(request_obj, "raw_input_contents") and request_obj.raw_input_contents:
- return pd.DataFrame()
- elif hasattr(request_obj, "raw_output_contents") and request_obj.raw_output_contents:
- return pd.DataFrame()
+ elif hasattr(request_obj, "raw_input_contents") and request_obj.raw_input_contents:
+ return np.array([])
+ elif hasattr(request_obj, "raw_output_contents") and request_obj.raw_output_contents:
+ return np.array([])- if len(shape) > 1:
+ if len(shape) > 1 and getattr(data, "size", 0) > 0:
data = data.reshape(shape)🤖 Prompt for AI Agents |
||
| else: | ||
| raise ValueError(f"No data found in tensor {tensor.name}") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Returning an empty DataFrame may mask missing or malformed input data.
This path used to raise
NotImplementedError, clearly signaling that raw input contents were unsupported. Returningpd.DataFrame()turns that into a silent no-op, making it impossible to distinguish between “no data” and “unsupported/malformed input,” and also conflicts with the function’snp.ndarrayreturn type. Please either keep an explicit exception (or a more specific one), or introduce logging and a distinct sentinel (e.g.,None) so callers can reliably detect this case.