Skip to content

feature: improve async / executor functionality #2070

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ahgraber
Copy link
Contributor

@ahgraber ahgraber commented Jun 9, 2025

  • refactor: move is_event_loop_running and as_completed to async_utils
    This helps separate async features from executor and engine modules, and will prevent circular imports in these modules.
  • feat: add ProgressBarManager for enhanced progress tracking
    Introduces a new ProgressBarManager class to manage progress bars for both batch and non-batch execution. This includes methods for creating single and nested progress bars, as well as updating batch progress bars, improving user experience during long-running tasks.
  • feat: refactor async utilities for improved functionality
    • Refactored run function from repeated async, executor, and engine logic.
    • Changed as_completed from async to a regular function for better compatibility.
    • Added process_futures to handle futures with optional progress tracking.
  • feat: enhance async task management with ProgressBarManager
    • Refactored Executor to utilize new async_utils and ProgressBarManager for improved composition
    • Refactored run_async_tasks to utilize ProgressBarManager for improved progress tracking.
    • Modified tests to validate the new behavior functions
  • feat: enhance Executor with job indexing and exception handling
    • Introduced a locking mechanism to ensure thread-safe job processing.
    • Added _jobs_processed attribute to maintain consistent job indexing across multiple runs.
    • Implemented clear_jobs method to reset job indices.
    • Updated tests to verify exception handling and job indexing after clearing jobs.
    • Adjusted Jupyter notebook tests for consistency in results retrieval.
  • feat: update engine's apply_transformations to recursively process nested Transformation or Parallel procedures
    • The apply_transforms() function has been updated to handle different types of transformations recursively:
      If transforms is a list, it recursively applies each transform in the list.
      If transforms is a Parallel instance, it recursively applies the transformations contained within the Parallel object.
      If transforms is a BaseGraphTransformation, it generates an execution plan (a list of coroutines), gets a description, and then runs the coroutines asynchronously using run_async_tasks().
      If transforms is none of the above, it raises a ValueError indicating an invalid type.
    • Move apply_nest_asyncio to async_utils for better organization
    • Updated the Parallel class to support transformations with improved type hints.
    • Added unit tests
  • chore: use Sequence over List for type checking improvements; add debug logging

ahgraber added 7 commits June 9, 2025 11:18
This helps separate async features from executor and engine modules, and will prevent circular imports in these modules.
Introduces a new ProgressBarManager class to manage progress bars for both batch and non-batch execution. This includes methods for creating single and nested progress bars, as well as updating batch progress bars, improving user experience during long-running tasks.
- Refactored `run` function from repeated async, executor, and engine logic.
- Changed `as_completed` from async to a regular function for better compatibility.
- Added `process_futures` to handle futures with optional progress tracking.
- Refactored Executor to utilize new async_utils and ProgressBarManager for improved composition
- Refactored run_async_tasks to utilize ProgressBarManager for improved progress tracking.
- Modified tests to validate the new behavior functions
- Introduced a locking mechanism to ensure thread-safe job processing.
- Added `_jobs_processed` attribute to maintain consistent job indexing across multiple runs.
- Implemented `clear_jobs` method to reset job indices.
- Updated tests to verify exception handling and job indexing after clearing jobs.
- Adjusted Jupyter notebook tests for consistency in results retrieval.
…sted Transformation or Parallel procedures

- The apply_transforms() function has been updated to handle different types of transformations recursively:
  If transforms is a list, it recursively applies each transform in the list.
  If transforms is a Parallel instance, it recursively applies the transformations contained within the Parallel object.
  If transforms is a BaseGraphTransformation, it generates an execution plan (a list of coroutines), gets a description, and then runs the coroutines asynchronously using run_async_tasks().
  If transforms is none of the above, it raises a ValueError indicating an invalid type.
- Move apply_nest_asyncio to async_utils for better organization
- Updated the Parallel class to support transformations with improved type hints.
- Added unit tests
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 9, 2025
@ahgraber
Copy link
Contributor Author

ahgraber commented Jun 9, 2025

I know this one is a big review - everything's interrelated enough that I had a hard time splitting it up, but I could try to refactor into smaller pulls if necessary.

@ahgraber ahgraber changed the title Feature/async executor feature! improve async / executor functionality Jun 9, 2025
@ahgraber ahgraber changed the title feature! improve async / executor functionality feature: improve async / executor functionality Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants