-
-
Notifications
You must be signed in to change notification settings - Fork 13
Update logging with info on the source file running #531
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
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.
Summary of Changes
Hello @sven-oly, 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 focuses on improving the system's observability and maintainability. It standardizes logging output by including the source file path, refines the build process by addressing npm package lock warnings, and removes obsolete test data generation code, leading to a cleaner and more efficient system.
Highlights
- Enhanced Logging: Added file path prefixes to log messages across various Python scripts for better traceability and debugging.
- Build Process Improvement: Introduced "npm install --package-lock-only" in shell scripts to manage "package-lock.json" and clear warnings, ensuring consistent dependency management.
- Code Cleanup and Simplification: Removed deprecated Node.js-based test data generation logic from "testgen/generators/datetime_fmt.py" and other unneeded code, streamlining the codebase.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 aims to improve logging by adding the source file name to log messages. While this is a good goal, the current implementation hardcodes the filenames in log strings across many files, which poses a maintainability challenge. I've provided suggestions to dynamically determine the filename instead. The PR also includes some welcome code cleanup by removing unneeded sections.
I've identified two critical issues: a typo in a variable name in testdriver/testplan.py
that will likely cause runtime errors, and a NameError
in an exception handler in testgen/generators/message_fmt2.py
. There are also some minor typos. Please review the detailed comments.
testdriver/testplan.py
Outdated
# Send a single line of data or command to Stdout, capturing the output | ||
def send_one_line(self, input_line): | ||
self.run_error_message = None | ||
self.runer_ror_message = 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.
This appears to be a typo. The attribute should likely be self.run_error_message
to be consistent with its usage elsewhere in this file. This change will probably lead to an AttributeError
since other parts of the code refer to self.run_error_message
.
self.runer_ror_message = None | |
self.run_error_message = None |
testgen/generators/message_fmt2.py
Outdated
logging.error("testgen/generators/message_fmt2.py: JSON %s not validated against schem a %s. Error = %s", | ||
test_file_path, json_schema_path, error) |
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.
This log message has a couple of issues:
- There's a typo:
schem a
should beschema
. - More importantly, it uses a variable
error
which is not defined in thisexcept
block. The exception object is namederr
. This will cause aNameError
when this exception is caught.
logging.error("testgen/generators/message_fmt2.py: JSON %s not validated against schem a %s. Error = %s", | |
test_file_path, json_schema_path, error) | |
logging.error("testgen/generators/message_fmt2.py: JSON %s not validated against schema %s. Error = %s", | |
test_file_path, json_schema_path, err) |
testgen/generators/base.py
Outdated
return json.load(testdata) if filetype == "json" else testdata.read() | ||
except BaseException as err: | ||
logging.warning("** readFile: %s", err) | ||
logging.warning("testgen/generators: %s", err) |
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.
testdriver/testdriver.py
Outdated
|
||
if test_type not in ddt_data.testDatasets: | ||
logging.warning('**** WARNING: test_type %s not in testDatasets', test_type) | ||
logging.warning('testdriver.py **** WARNING: test_type %s not in testDatasets', test_type) |
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.
Hardcoding the filename prefix in log messages, as done throughout this file, is not ideal for maintainability. If the file is ever renamed, all these log strings would need to be updated manually. A better approach is to obtain the filename dynamically. You can define a constant at the top of the module:
import os
FILENAME = os.path.basename(__file__)
And then use it in your log messages, for example:
logging.warning('%s **** WARNING: test_type %%s not in testDatasets', FILENAME, test_type)
testdriver/testplan.py
Outdated
self.icu_version = options.icu_version | ||
except KeyError: | ||
logging.warning('NO ICU VERSION SET') | ||
logging.warning('testdriver/testplan.py: NO ICU VERSION SET') |
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.
Hardcoding the filename prefix in log messages, as done throughout this file, is not ideal for maintainability. If the file is ever renamed, all these log strings would need to be updated manually. A better approach is to obtain the filename dynamically. You can define a constant at the top of the module:
import os
FILENAME = os.path.basename(__file__)
And then use it in your log messages, for example:
logging.warning('%s: NO ICU VERSION SET', FILENAME)
logging.debug('testgen/generator/localeDisplayNames: %s ignored for %s, %s', | ||
locale_label, test_data[0], language_display) |
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.
There seems to be a typo in the hardcoded path: testgen/generator/
should probably be testgen/generators/
.
More generally, hardcoding path prefixes in log messages is not ideal for maintainability. It's better to get this information dynamically, for example using __name__
or os.path.basename(__file__)
.
src_data = self.readFile(test_file_path, filetype="json") | ||
if src_data is None: | ||
logging.error("Problem reading JSON. Omitting file %s", test_file_path) | ||
logging.error("testgen/generators/message_fmt2.py: Problem reading JSON. Omitting file %s", test_file_path) |
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.
schema/check_schemas.py
Outdated
summary_data = json.dumps(summary_json) | ||
except BaseException as err: | ||
logging.error('%s: Cannot create JSON summary: %s', err, summary_json) | ||
logging.error('schema/check_schemas: %s: Cannot create JSON summary: %s', err, summary_json) |
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.
Hardcoding the filename prefix in log messages, as done throughout this file, is not ideal for maintainability. If the file is ever renamed, all these log strings would need to be updated manually. A better approach is to obtain the filename dynamically. You can define a constant at the top of the module:
import os
FILENAME = os.path.basename(__file__)
And then use it in your log messages, for example:
logging.error('%s: %%s: Cannot create JSON summary: %%s', FILENAME, err, summary_json)
|
||
logging.info( | ||
"NumberFormat Test (%s): %s tests created", self.icu_version, count | ||
"testgen/generators/number_fmt.py: NumberFormat Test (%s): %s tests created", self.icu_version, count |
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.
tree = ET.parse(filename) | ||
except: | ||
logging.warning('No plurals file found: %s', filename) | ||
logging.warning('testgen/generators/plurals.py: No plurals file found: %s', filename) |
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.
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.
This is good progress. I'm eager to see the end-to-end log when CI is passing. It seems you are annotating a lot of the messages in Python, but I think you might also want to annotate the messages generated by the bash scripts as well as any generated by a Python subprocess.
# To clear warnings | ||
npm install --package-lock-only |
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.
You should run npm only in the package directories that need them
# To clear lock | ||
npm install --package-lock-only |
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.
Same
{ | ||
"dependencies": { | ||
"@js-temporal/polyfill": "^0.5.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.
We should have a package.json in each node package directory, but probably not at the top level
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.
My concerns about the new top-level package.json haven't been addressed
Fixes #417
Fixes #432
Adds the name of the python file being executed in logging output.
Also removes old unneeded code.
Add npm command to handle package-lock.