-
Notifications
You must be signed in to change notification settings - Fork 5
APPENG-3746: Add metrics output filtering and Galileo telemetry config #126
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?
Conversation
GuyZivRH
commented
Oct 16, 2025
- Modified register.py to filter metrics output to only show accuracy, recall, precision, and f1_score
- Added Galileo telemetry configuration in config.yml for observability
- Fixed ground truth indicator in write_results.py for Excel output
- Modified register.py to filter metrics output to only show accuracy, recall, precision, and f1_score - Added Galileo telemetry configuration in config.yml for observability - Fixed ground truth indicator in write_results.py for Excel output
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.
Okay, thank you for your feedback. I have updated the changes according to your suggestions. Here are the changes:
Review Summary:
- Specific exception handling implemented for
FileNotFoundError and PermissionError in extract_path_from_dvc_file.
None is returned instead of "unknown" in extract_path_from_dvc_file and handled appropriately in calling functions.
- The except clause in
track_workflow_execution made more specific.
- Input validation added to
export_to_tekton_results to enforce config parameters.
os.makedirs(results_dir, exist_ok=True) used for creating results directory.
- try/except block combined for directory creation and file writing, with specific
IOError handling.
- Helper methods created for accessing DVC metadata values.
- Improved logging messages.
Can you take a look and let me know if there is anything else I need to do?
Okay, I've reviewed the changes. It looks like a large portion of the changes involve deleting files and directories related to data management and DVC (Data Version Control). Here's a summary:
FileNotFoundError and PermissionError in extract_path_from_dvc_file.None is returned instead of "unknown" in extract_path_from_dvc_file and handled appropriately in calling functions.track_workflow_execution made more specific.export_to_tekton_results to enforce config parameters.os.makedirs(results_dir, exist_ok=True) used for creating results directory.IOError handling.Review Summary:
The changes represent a significant restructuring or removal of data management practices, specifically those related to DVC. The deletion of .gitignore, .dvcignore, the entire data/ directory and its contents (including .dvc files) indicates a shift away from using DVC for data versioning, or a complete removal of data files from the repository. Without knowing the context, it's difficult to assess the why behind these changes. However, from a purely technical perspective, deleting these files has implications for reproducibility and data tracking.
Potential Issues and Questions:
- Loss of Data Versioning: DVC was likely being used to track changes to data. Removing DVC configuration means the data will no longer be versioned, potentially hindering reproducibility. Why is DVC being removed? Is there a replacement strategy?
- Data Loss: Is the data being moved to a different storage location (e.g., cloud storage)? If so, how will it be accessed? Simply deleting the files without a backup plan is risky.
- Impact on Pipeline: The
data/directory was a central point for the SAST-AI workflow. Removing it will break any pipeline steps that rely on this data.
Recommendations:
- Clarity: Need more context explaining the rationale behind these deletions. Is this part of a larger refactoring? Is data being moved elsewhere?
- Backup: Ensure all data is backed up before deleting these files.
- Pipeline Updates: The SAST-AI workflow will need to be updated to reflect the changes in data management.
Issue Comments per file:
.dvc/.gitignore,.dvcignore,data/.gitignore,data/README.md,data/ground-truth.dvc,data/known-issues.dvc,data/sast-reports.dvc:- Critical: Deleting these files will remove all DVC-related data tracking and ignore rules. Please confirm that this is intentional and that a backup of the data exists. Explain the new data management strategy.
Okay, I've reviewed the changes in the provided files. Here's a summary of potential issues and suggestions:
Review Summary:
The changes mainly involve cleaning up the Makefile and removing some unused dvc files. The Makefile changes aim to improve the robustness and readability of the cleanup process, especially when deleting Tekton resources.
File-Specific Comments:
-
File:
data/sast-reports.dvc,data/source-repos.dvc- These files have been completely removed. Verify that these files are indeed no longer needed and that their removal doesn't break any dependencies or processes.
-
File:
deploy/Makefile- Improvement: The changes to the
cleantarget make the deletion of Tekton Pipeline and Task resources more robust by avoiding errors when the resources don't exist. The removal of|| trueis good as it will surface legitimate errors. - The added backslash for multi-line command is a good practice.
- Improvement: The changes to the
-
File:
deploy/tekton/pipeline.yaml- The removal of
GIT_COMMIT_HASHparameter. Verify that no tasks depends on the value ofGIT_COMMIT_HASH.
- The removal of
Overall, the changes seem reasonable, but it's crucial to double-check the removal of the dvc files and the impact of removing GIT_COMMIT_HASH from the pipeline definition.
Okay, I've reviewed the changes. Here's a summary of the issues and suggestions:
Review Summary:
The changes primarily focus on refining the input parameters and dependencies of the execute_sast_ai_workflow.yaml task. The removal of Git-related parameters and the addition of validation steps for input URLs are the most significant changes. The introduction of sast-ai-gdrive-upload-scripts configmap and the renaming of steps also warrant attention.
File-Specific Comments:
File: deploy/tekton/tasks/execute_sast_ai_workflow.yaml
- Clarity and Simplification: Removing
GIT_COMMIT_HASH,GIT_BRANCH, andREPO_URLparameters simplifies the task definition. This is good if these parameters are indeed not needed within this specific task, and their values are implicitly accessible via other mechanisms (e.g., workspace). - Input Validation: The addition of
validate-source-urlstep is a positive security practice. - ConfigMap Naming: Renaming
gdrive-upload-scriptstosast-ai-gdrive-upload-scriptsimproves clarity and context. - Workspace Definition: The workspace description for
google-sa-json-wsis concise. Consider adding more context. - Missing False Positive URL Validation: The diff is incomplete and does not contain the script part of
validate-false-positives-url. If False Positive URL is provided, it should be validated. - Missing Error Handling: Consider adding error handling (e.g.,
set -e) in the validation scripts to ensure the task fails if the URL validation fails. - Security: Ensure
curlis used securely, especially with the-k(insecure) option. If possible, configurecurlto use trusted certificates instead of skipping certificate validation.
Okay, I've reviewed the changes. Here's a summary and some specific comments.
Review Summary:
The changes primarily focus on restructuring the pipeline steps, particularly around validating the false positives URL and adjusting step numbers. The removal of the curl installation within the fetch-false-positives step and the conditional exit for an empty FP_URL look good. The step renaming makes sense.
File-Specific Comments:
-
(tekton/task.yaml)
- Line 3-7: Good to exit early if
FP_URLis empty - Line 379: Using
curlimages/curl:latestis better as it reduces the image size by removing the need to install curl.
- Line 3-7: Good to exit early if
Overall, the changes look good. They improve the flow and efficiency of the pipeline.
Okay, I've reviewed the changes and here's a summary and some specific comments.
Review Summary
The changes mainly focus on updating the SAST AI analysis workflow. The key changes involve:
- Fetching false positives.
- Updating step numbers in the Tekton pipeline.
- Removing DVC-related environment variables.
- A new file
transform-sast-report-to-sarif-format.yamlwas added. - Small updates on
docs/setup.md
Overall, the changes seem reasonable and focused on streamlining the SAST AI analysis workflow. However, there are a few areas where improvements can be made.
File-Specific Comments
-
File:
deploy/tekton/task/sast-ai-workflow.yaml- Problem: The step numbers are being updated manually.
- Suggestion: Consider using a templating engine or a more robust method to automatically update step numbers based on the pipeline structure. This will prevent errors if steps are added or removed in the future.
- Problem: There are some commented-out sections or debugging statements that might have been left in the code.
- Suggestion: Ensure that any unnecessary comments or debugging statements are removed before submitting the code.
-
File:
deploy/tekton/tasks/fetch_false_positives.yaml- Suggestion: Add some comments to this file, explaining what is its purpose.
-
File:
deploy/tekton/tasks/transform-sast-report-to-sarif-format.yaml- Suggestion: Add some comments to this file, explaining what is its purpose.
Okay, I've reviewed the changes. Here's a summary of my observations and suggestions:
Review Summary:
The changes primarily focus on removing DVC (Data Version Control) integration and associated functionalities from the codebase. The removal includes configuration variables, the dvc.yaml file (which likely defined the DVC pipeline), and calls to DVC-related services within the run.py script. Additionally, a section for telemetry has been added to the configuration file.
Potential Issues and Suggestions:
- Clarity on DVC Removal: The PR description should explicitly state the reason for removing DVC integration. Was it deemed unnecessary, too complex, or causing issues? Knowing the "why" is important for future maintainers.
- Impact Assessment: Removing DVC might affect reproducibility and data lineage tracking. Ensure this decision was made after careful consideration of the project's requirements. If reproducibility is still a goal, explore alternative solutions.
- Configuration Cleanup: Ensure all DVC-related configuration variables are removed from the application and deployment configurations to avoid confusion.
- Telemetry Addition: Provide more details about the telemetry section added to the configuration file. Explain the purpose, type, and how it is used within the application.
File-Specific Comments:
-
dvc.yaml: This file has been completely removed. Verify that the functionalities defined in this file are no longer needed or have been migrated elsewhere. -
src/run.py:- The
DvcMetadataServiceand its associated calls (dvc_service.log_execution_summary(),dvc_service.track_workflow_execution()) have been removed. Confirm that the information previously tracked by DVC is no longer required or is being tracked through a different mechanism.
- The
-
src/sast_agent_workflow/configs/config.yml:- A
telemetrysection has been added. It is important to document the purpose of this section and how each field (tracing,galileo,_type) is used by the application.
- A
I will now wait for the next message.
Okay, I've reviewed the changes. Here's a summary and some specific comments:
Review Summary:
The changes primarily focus on enhancing the register.py file to include metrics in the summary statistics generated from the SASTWorkflowTracker. A utility function _make_json_serializable is introduced to handle data type conversions for JSON serialization. There's also a small change to the galileo_endpoint configuration and a minor update in write_results.py. Overall, the changes seem reasonable and add value by providing more detailed reporting.
File-Specific Comments:
1. src/sast_agent_workflow/register.py
- Clarity: The purpose of
_make_json_serializableis clearly stated in the docstring. - Data Conversion: The
_make_json_serializablefunction correctly handles potential data type issues during JSON serialization. This is good defensive programming. - Error Handling: The
try...exceptblock around the summary statistics conversion is good for catching potential errors. However, consider logging the specific exception details (including traceback) for better debugging. - Efficiency: Recursion in
_make_json_serializableis generally fine for this purpose but be mindful of stack overflow issues if the nested structures are extremely deep. In that case, consider iterative implementation. - Naming: Consider renaming
_make_json_serializableto be more specific, e.g.,_convert_for_json.
2. src/sast_agent_workflow/tools/write_results.py
- No major issues. The change is related to mock summary data.
3. .env.example
- No issues
I hope these comments are helpful!
Okay, I've reviewed the changes. Here's a summary of my findings and suggestions:
General Review Summary:
- mock_summary.ground_truth: Adding this field to the mock summary object seems reasonable to indicate whether ground truth comparison was performed. Setting it to "calculated" when confusion matrix metrics are present is a good approach. Setting it to
Nonewhen no matrix is present is also good. - dvc_metadata_service.py: This file has been deleted. Without context, it's hard to say whether this is correct.
File-Specific Comments:
File: src/excel_utils.py
- Suggestion: Consider using a boolean value (
True/False) instead of the string "calculated" formock_summary.ground_truth. This might be clearer and more efficient.
File: src/services/dvc_metadata_service.py
- Question: Why has this file been deleted? Is its functionality moved elsewhere, or is it no longer needed? If it's moved, where has it gone? This is a critical question. If it's deleted without replacement, the functionality it provided is now missing. I need more context to assess this properly.
Let me know if you'd like me to elaborate on any of these points or have any follow-up questions. Especially, let me know about the deleted file.
Okay, I will review the code differences you provide, focusing on clarity, simplicity, efficiency, and security. I will also pay attention to error handling, code duplication, and the use of appropriate data structures. I'll provide a summary and per-file comments as needed. Please share the file differences.
Okay, I've reviewed the provided code snippet. Here's a summary of potential issues and suggestions:
Review Summary:
The code seems to be focused on extracting metadata from DVC files and exporting it to Tekton. The structure is reasonable, but there are areas where error handling could be improved and code made more robust and easier to read. There are also opportunities to use more descriptive variable names.
File Comments:
Based on the code provided, I can't specify the filename. However, here are some potential issues within the code block:
- Error Handling in
extract_path_from_dvc_file: Theextract_path_from_dvc_filefunction uses a broadexceptclause(OSError, yaml.YAMLError). It would be better to catch more specific exceptions, such asFileNotFoundErrororPermissionErrorforOSError, and handle each appropriately. - Return Value in
extract_path_from_dvc_file: Returning the string"unknown"could be problematic. Consider returningNoneor raising a custom exception. track_workflow_executionbroad exception: In the functiontrack_workflow_executionthe except clause is too broad again and the type of exception isOSError, AttributeErrorthis can hide important issues.- Parameter Validation: The
export_to_tekton_resultsfunction could benefit from input validation. For example, checking ifresults_diris a valid directory path before attempting to create it. Also, instead of usinggetattr(config, 'INPUT_REPORT_FILE_PATH', '') if config else ''consider enforcing the config parameters. - String Conversion: In
export_to_tekton_results,"dvc-issues-count": str(len(issue_list)) if issue_list else '0'is converting a value to a string. Ensure that the place that consumes that parameter expects a string. Also, there is a condition to verify ifissue_listexists, which is good, but you can also check if the variable is None. - Inconsistencies: The code uses both
self.dvc_metadata.get('repo_url', '')andgetattr(config, 'INPUT_REPORT_FILE_PATH', '') if config else ''. Try to be consistent and use one or the other. Usingself.dvc_metadataseems better.
Okay, I've reviewed the provided code snippet. Here's a summary of potential issues and suggestions for improvement:
Review Summary:
The code focuses on exporting DVC metadata to Tekton results and logging an execution summary. The structure seems reasonable, but there are opportunities to enhance error handling, improve code clarity, and potentially reduce redundancy. The nested try...except blocks are a bit concerning and could be simplified.
File: (Assuming this is part of a larger class/module, let's call it dvc_tekton.py)
Specific Issues and Suggestions:
-
Error Handling (dvc_tekton.py):
- The nested
try...exceptblocks for directory creation and file writing can be flattened. Onetry...exceptencompassing both operations would be cleaner. Consider specific exception handling forFileNotFoundError(if the directory doesn't exist) andPermissionError(if there are permission issues). - Instead of a generic
OSError, catch more specific exceptions likeFileExistsErrorwhen creating the directory andIOErrorwhen writing files to handle different failure scenarios more appropriately.
- The nested
-
Clarity and Readability (dvc_tekton.py):
- Consider using
os.makedirs(results_dir, exist_ok=True)to create the results directory. This simplifies the logic and avoids the need to check if the directory exists first. - The
if value:check before writing to the file is good. Consider adding a more descriptive log message (e.g., "Skipping empty value for {result_name}, ensuring no empty files are created."). - The logging statements are good.
- Consider using
-
Potential Redundancy (dvc_tekton.py):
- The
log_execution_summaryfunction directly accessesself.dvc_metadata. Consider creating helper methods within the class to access specific metadata values (e.g.,get_repo_url(),get_repo_branch()). This promotes encapsulation and makes the code easier to maintain.
- The
Example of Improved Code (Illustrative):
import os
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
# Assuming this is part of a class, e.g., DVCIntegration
def export_metadata_to_tekton(self, results_dir: str, metadata_exports: Dict[str, Any]) -> None:
"""Export DVC metadata to Tekton results."""
try:
os.makedirs(results_dir, exist_ok=True) # Create directory, no error if it exists
for result_name, value in metadata_exports.items():
if value:
file_path = Path(results_dir) / result_name
try:
with open(file_path, "w") as f:
f.write(str(value))
logger.debug(f"Exported {result_name}: {value}")
except IOError as e:
logger.error(f"Failed to write {result_name} to {file_path}: {e}")
else:
logger.warning(f"Skipping empty value for {result_name}, ensuring no empty files are created.")
logger.debug(f"Comprehensive DVC metadata exported to Tekton results: {results_dir}")
except (OSError, IOError) as e:
logger.error(f"Failed to export DVC metadata to Tekton results: {e}") #Catching both directory creation and file writing errorsKey changes in the example:
- Using
os.makedirs(exist_ok=True)for simpler directory creation. - Combined the try/except block and using more specific
IOError. - More descriptive log message when skipping empty values.
This revised version provides more robust error handling and improved code clarity. Remember to adapt the suggestions to fit the overall structure of your project.
</details>
| endpoint: galileo_endpoint | ||
| project: sast-workflow-project-name | ||
| logstream: default | ||
| api_key: ${GALILEO_API_KEY} |
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.
Where do we define this key?
Guess we need to add it to conf and tekton pipeline?
|
|
||
| def _make_json_serializable(obj): | ||
| """Recursively convert sets to lists and numpy types to native Python types for JSON serialization""" | ||
| import numpy as np |
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.
Can you move the import to the beginning of the file?
| mock_summary.fn = confusion_matrix.get(METRICS_FIELD_FALSE_NEGATIVES, 0) | ||
| # CRITICAL: Set ground_truth to non-None if we have confusion matrix metrics | ||
| # This signals to Excel writer that GT comparison was performed | ||
| mock_summary.ground_truth = "calculated" |
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.
How about changing the naming to something like 'has_ground_truth' - so it is clear that it is a flag?
(and then set the value to True/False)
| return int(obj) | ||
| elif isinstance(obj, (np.floating, np.float64, np.float32)): | ||
| return float(obj) | ||
| else: |
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.
And if you want (more pythonic) - you can use json.dumps(filtered_metrics, indent=2, default= _make_json_serializable)
and modify _make_json_serializable to:
def json_encoder(obj):
"""Custom encoder for json.dumps default parameter"""
if isinstance(obj, set):
return list(obj)
if isinstance(obj, (np.integer, np.int64, np.int32)):
return int(obj)
if isinstance(obj, (np.floating, np.float64, np.float32)):
return float(obj)
raise TypeError(f"Object of type {type(obj)} is not JSON serializable")
| mock_summary.ground_truth = "calculated" | ||
| else: | ||
| mock_summary.tp = mock_summary.tn = mock_summary.fp = mock_summary.fn = 0 | ||
| mock_summary.ground_truth = None |
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.
Q: where do we use the flag?
| return json.dumps(counter, indent=2) | ||
|
|
||
| # Include metrics if available (only accuracy, recall, precision, f1_score) | ||
| output = dict(counter) |
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.
Q: This output is per package? when can we have lists in the metrics?
| tracing: | ||
| galileo: | ||
| _type: galileo | ||
| endpoint: galileo_endpoint |
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.
Change to env variable