-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/python3.8+ #3
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…racing - Implemented dual tracing mechanisms based on `sys.monitoring` and `sys.setprofile` considering following design patterns. - `engine/pyftrace_monitoring.py`: - Implemented the `PyftraceMonitoring` class based on `sys.monitoring`. - Registered callbacks for various monitoring events (`CALL`, `PY_RETURN`, `C_RETURN`, `C_RAISE`). - `engine/pyftrace_setprofile.py`: - Implemented the `PyftraceSetprofile` class based on `sys.setprofile`. - Handled profiling events (`call`, `return`) while ignoring C-level calls (`c_call`, `c_return`). - `pyftrace_base.py`: - Defined the abstract base class `PyftraceBase` outlining the interface for tracers. - Included common functionality such as determining if a file should be traced, etc. - `tracer.py`: - Updated to inherit from `PyftraceBase`. - Integrated `PyftraceMonitoring` for Python versions >= 3.12 and `PyftraceSetprofile` for earlier versions. - How to change tracing API - tracer.py class Pyftrace(PyftraceBase): def __init__(self, verbose=False, show_path=False, report_mode=False, output_stream=sys.stdout): super().__init__(verbose, show_path, report_mode, output_stream) if sys.version_info >= (3, 12): #### set PyftraceSetprofile for sys.setprofile based tracing #### set PyftraceMonitoring for sys.monitoring based tracing self.impl = PyftraceMonitoring(verbose, show_path, report_mode, output_stream) # self.impl = PyftraceSetprofile(verbose, show_path, report_mode, output_stream) else: self.impl = PyftraceSetprofile(verbose, show_path, report_mode, output_stream) - Filter out python stdlib code when using `sys.setprofile` - Fixed to not track <module> - only track calls/returns of functions in the code - Also changed related test code.
- Added Python 3.10 and 3.11 to the test matrix in github workflows
- Changed `self.call_stack` to store function names instead of frame objects. - Modified `handle_return_event` to compare function names, ensuring return values (including `None`) are correctly displayed. - Removed unused `get_site_packages_modules` import.
- Use `getattr` for safe retrieval of `func_name` and `module_name`: - Enhance built-in function handling: - Adjusted conditions to trace built-in functions (`module_name == 'builtins'`) when verbose mode is enabled. - Simplify tracing logic - Fix call location retrieval
- Introduced `normalize_output` to output comparison. - Updated test methods to use `normalize_output` when comparing expected and actual outputs. - Added `setUp` and `tearDown` methods - to initialize and display test outputs (`self.output` and `self.error`). - Commented out tests that are currently not in use.
- Introduced `normalize_output` to output comparison. - Updated test methods to use `normalize_output` when comparing expected and actual outputs. - Added `setUp` and `tearDown` methods - to initialize and display test outputs (`self.output` and `self.error`). - Added `self.maxDiff = None` in `setUp` to display the full diff for easier debugging of test failures. - Enhanced `normalize_output` to unify path separators (`\` to `/`) for Windows.
- Updated `is_stdlib_code` in `pyftrace_base.py` to use `os.path.normcase` for case-insensitive path comparison. - Ensured stdlib paths are accurately identified especially on Windows, avoiding issues caused by differing path casing. Fixed: #2
Commented messages for debugging in the setprofile event monitor. It's annoying to write & clear them every time, so I just leave them as comment in this commit...
- Consolidated the PyftraceBase abstract base class into tracer.py to eliminate redundancy. - Updated engine modules (pyftrace_monitoring.py and pyftrace_setprofile.py) to import PyftraceBase from tracer.py instead of the now-removed pyftrace_base.py. - Rearranged the import order in tracer.py by defining PyftraceBase before importing engine modules to prevent circular import issues. - Removed references to pyftrace_base.py, as it is no longer necessary.
Changed Python version in the PyPI release workflow from 3.12 to 3.8.
find_import_end_line don't always have to be tracer.py so I moved this method to utils.py
This commit modifies the tracing conditions in PyftraceSetprofile so that standard library functions are included when verbose mode is enabled. Previously, stdlib functions were only traced if they were 'builtins' under -v mode. Now, any stdlib function will be traced in verbose mode.
This commit adds torch_example.py and requests_example.py to show examples of tracing the torch library or the requests library.
- Add caller frame checks to detect if an external call is triggered by user script code beyond the import threshold. - Ensure tracing begins even for top-level calls to external libraries after imports. - Prevent unnecessary tracing of functions invoked during the import phase.
- Limit OS matrix to `ubuntu-latest` for CI tests. - Remove Windows and macOS from the test matrix.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.