-
Notifications
You must be signed in to change notification settings - Fork 128
utils for pv-map comparison #1688
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: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ajaits, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a suite of utilities and test scripts for property-value (PV) map comparison and generation. The changes include adding a new flag to output PVs per data cell and implementing the logic in the stat_var_processor. Several new files are added for testing and evaluation, including a baseline script, a shell test script, and Python utility modules. My review identifies several critical issues in the new scripts, such as runtime errors due to missing imports and incorrect syntax, which need to be addressed. I also found a likely-to-be-obsolete file (statvar_imports_test_utils.py) that is riddled with bugs and should probably be removed. Additionally, I've provided suggestions to improve code quality, such as replacing os.system with the more secure subprocess module and fixing minor bugs and typos.
| process_http_server.run_http_server(http_port=_FLAGS.http_port, | ||
| script=__file__, | ||
| module=config_flags) | ||
| process_import(import_name=_FLAGS.statvar_import_name, | ||
| pvmap_generation_method=_FLAGS.pvmap_generation_method) |
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.
The functions process_http_server.run_http_server and process_import are called here, but they are not imported or defined in this file. Similarly, the config_flags module is used but not imported. This will cause NameError exceptions at runtime. Please add the necessary imports to resolve these references.
| sys.path.append(_SCRIPT_DIR) | ||
| sys.path.append(os.path.dirname(_SCRIPT_DIR)) | ||
| sys.path.append(os.path.dirname(os.path.dirname(_SCRIPT_DIR))) | ||
| sys.path.append(_DATA_DIR, 'util') |
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.
| with open(file, 'r') as fp: | ||
| manifest_json = json.loads(fp.read()) | ||
| return manifest_json | ||
| except e: |
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.
| -gm) shift; GEMINI_MODEL="$1";; | ||
| -gen_pvmap_s*) GENERATE_PVMAP_STATVAR="1";; | ||
| -q) QUIET="1";; | ||
| -m) shift; MANIFEST="$1";; |
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.
| # Get the manifest.josn file for an import | ||
| def get_import_manifest(import_name: str, root_dir: str = _DATA_DIR) -> str: | ||
| """Returns the folder containing the manifest.json for the import name.""" | ||
| files = glob.glob(os.path.join(root_dir, '**'), recurive=True) |
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.
| import os | ||
| import sys | ||
| import glob | ||
| import json | ||
| from typing import Union | ||
|
|
||
| from absl import app | ||
| from absl import flags | ||
| from absl import logging |
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.
| import json | ||
| import re | ||
| import shlex | ||
| from typing import Union |
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.
| cwd = os.getcwd() | ||
| if run_dir: | ||
| os.chdir(run_dir) | ||
| os.system(generate_pvmap_cmd) |
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.
Using os.system() can be a security risk if any part of the command comes from untrusted input. It is also less flexible than the subprocess module. Consider using subprocess.run() which provides more control over command execution, error handling, and capturing output. You will also need to import subprocess at the top of the file.
| os.system(generate_pvmap_cmd) | |
| subprocess.run(generate_pvmap_cmd, shell=True, check=True) |
| cwd = os.getcwd() | ||
| os.chdir(import_dir) | ||
| logging.info(f'Generating test output with command: {statvar_test_cmd}') | ||
| os.system(statvar_test_cmd) |
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.
Using os.system() can be a security risk and is less flexible than the subprocess module. It's recommended to use subprocess.run() for better error handling and control over the executed process. You will also need to import subprocess at the top of the file if you haven't already.
| os.system(statvar_test_cmd) | |
| subprocess.run(statvar_test_cmd, shell=True, check=True) |
| pvmap1 = load_pvmap_file(pvmap_file1) | ||
| pvmap2 = load_pvmap_file(pvmap_file2) | ||
| counters.add_counter(f'nodes-input1-{pvmap_file1}', len(pvmap1)) | ||
| counters.add_counter(f'nodes-inpit2-{pvmap_file2}', len(pvmap2)) |
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.
No description provided.