Improved error handling, multiprocess environment setup, and pytest fixes#63
Merged
sophiemiddleton merged 13 commits intoMu2e:mainfrom Feb 19, 2026
Merged
Conversation
…Found error instead of 'file not associated with a value'
…pyutils into sgrant/error-handling
…pyutils into sgrant/error-handling
…global ENV_IS_SETUP with os.environ[PYUTILS_ENV_SETUP]. Spawned worker processes inherit os.environ from the parent, so they now skip setup that was already done in the main process.
There was a problem hiding this comment.
Pull request overview
This pull request improves error handling and multiprocess environment setup in the pyutils data processing framework, along with several bug fixes in file handling and test suite improvements.
Changes:
- Replaced Python-global
ENV_IS_SETUPvariable withos.environ["PYUTILS_ENV_SETUP"]to properly propagate environment setup state to spawned worker processes - Modified parallel file processing to skip failed files and continue processing the batch rather than crashing on first failure
- Fixed
UnboundLocalErrorinpyimport.pyand corrected log level inpyread.pyfor file open failures - Cleaned up test suite by removing duplicate method definition, adding test for corrupted files, and adjusting test configurations
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyutils/_env_manager.py | Replaced module-level global ENV_IS_SETUP with os.environ["PYUTILS_ENV_SETUP"] to ensure spawned processes inherit environment setup state |
| pyutils/pyprocess.py | Enhanced error handling: skip failed files in parallel processing, add warnings for None returns, cap max_workers to file list length, fix Skeleton.execute() success logging |
| pyutils/pyread.py | Changed log level from "warning" to "error" for file open exceptions since they're immediately re-raised |
| pyutils/pyimport.py | Fixed UnboundLocalError by initializing file = None before try block so finally block can safely reference it |
| tests/pytest.py | Removed duplicate _remote_process_file method, added test for corrupted files with expect_return=False, enabled emoji logging, fixed file paths and test configurations |
| tests/run.ipynb | Updated test execution output reflecting new test data files and test results (output only, no code changes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sophiemiddleton
approved these changes
Feb 19, 2026
Collaborator
sophiemiddleton
left a comment
There was a problem hiding this comment.
Looks good. Do you have time on mayne friday to discuss tests and examples?
Collaborator
Author
Yes, I can do that. I'm busy throughout the morning, but have time in the afternoon. |
This file contains hidden or 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
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.
Improved error handling, multiprocess environment setup, and
pytestfixesError handling (
pyprocess.py)Skeleton.execute()falsely logging success when results are Nonemax_workersto file list lengthEnvironment setup (
_env_manager.py)ENV_IS_SETUPwithos.environ["PYUTILS_ENV_SETUP"]: spawned worker processes now inherit setup state from the parent and skip redundant re-initialisationBug fixes (
pyread.py,pyimport.py)UnboundLocalErrorin finally block when file open fails beforefilevariable is assignedpytest.py)