- 
                Notifications
    
You must be signed in to change notification settings  - Fork 32
 
✨ dynamic-scheduler can chain operations #8446
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 21 commits
      Commits
    
    
            Show all changes
          
          
            31 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      18e3669
              
                added after event manager
              
              
                 992cfc1
              
                added rest of code
              
              
                 8da80c9
              
                added cancellable operation
              
              
                 b48c7e4
              
                revert changes
              
              
                 6ee4e25
              
                fixed test
              
              
                 9039b37
              
                added capability to run operation when one is done
              
              
                 bcf2721
              
                added tests to ensure switching of operations
              
              
                 52b4f7d
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 33f1b6e
              
                event is actually emitted when the previous operation finished
              
              
                 c5201f2
              
                fixed flaky tests
              
              
                 8880e81
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 83448f4
              
                mypy + pylint
              
              
                 e44c0d7
              
                typos
              
              
                 0bf48e7
              
                typos
              
              
                 d617187
              
                fixed broken functionality
              
              
                 29a947b
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 e1c4201
              
                pylint
              
              
                 8ef6313
              
                removed commented commander
              
              
                 38dac25
              
                typo
              
              
                 93b83e6
              
                refactor event scheduler
              
              
                 65b5256
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 e91aead
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 8e6a4f2
              
                added test
              
              
                 7e42181
              
                operation is composed instead of inherited form list
              
              
                 0c72939
              
                renamed create/undo to execute/revert
              
              
                 878bd62
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 b021862
              
                mypy
              
              
                 ca93197
              
                Merge remote-tracking branch 'upstream/master' into migrate-dy-schedu…
              
              
                 c100e56
              
                Merge branch 'master' into migrate-dy-scheduler-6
              
              
                GitHK a2e528f
              
                address possible flaky
              
              
                 a1338ac
              
                Merge branch 'migrate-dy-scheduler-6' of github.com:GitHK/osparc-simc…
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
        
          
          
            30 changes: 30 additions & 0 deletions
          
          30 
        
  ...heduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler/_dependencies.py
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from typing import TYPE_CHECKING | ||
| 
     | 
||
| from fastapi import FastAPI | ||
| 
     | 
||
| if TYPE_CHECKING: | ||
| from ._core import Core | ||
| from ._event_after import AfterEventManager | ||
| from ._event_scheduler import EventScheduler | ||
| 
     | 
||
| # NOTE: | ||
| # Due to circular dependencies it is not possible to use the following: | ||
| # - `Core.get_from_app_state(app)` | ||
| # - `AfterEventManager.get_from_app_state(app)` | ||
| # - `EventScheduler.get_from_app_state(app)` | ||
| # This module avoids issues with circular dependencies | ||
| 
     | 
||
| 
     | 
||
| def get_core(app: FastAPI) -> "Core": | ||
| core: Core = app.state.generic_scheduler_core | ||
| return core | ||
| 
     | 
||
| 
     | 
||
| def get_after_event_manager(app: FastAPI) -> "AfterEventManager": | ||
| after_event_manager: AfterEventManager = app.state.after_event_manager | ||
| return after_event_manager | ||
| 
     | 
||
| 
     | 
||
| def get_event_scheduler(app: FastAPI) -> "EventScheduler": | ||
| event_scheduler: EventScheduler = app.state.generic_scheduler_event_scheduler | ||
| return event_scheduler | 
  
    
      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
    
  
  
    
              
        
          
          
            45 changes: 37 additions & 8 deletions
          
          45 
        
  ...amic-scheduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler/_event.py
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,13 +1,42 @@ | ||
| from typing import TYPE_CHECKING | ||
| 
     | 
||
| from fastapi import FastAPI | ||
| 
     | 
||
| from ._models import ScheduleId | ||
| 
     | 
||
| if TYPE_CHECKING: | ||
| from ._event_scheduler import EventScheduler | ||
| from ._dependencies import get_event_scheduler | ||
| from ._event_base_queue import OperationToStartEvent | ||
| from ._event_queues import CreateCompletedQueue, ScheduleQueue, UndoCompletedQueue | ||
| from ._models import OperationContext, OperationName, ScheduleId | ||
| 
     | 
||
| 
     | 
||
| async def enqueue_schedule_event(app: FastAPI, schedule_id: ScheduleId) -> None: | ||
| event_scheduler: EventScheduler = app.state.generic_scheduler_event_scheduler | ||
| await event_scheduler.enqueue_schedule_event(schedule_id) | ||
| await get_event_scheduler(app).enqueue_message_for(ScheduleQueue, schedule_id) | ||
| 
     | 
||
| 
     | 
||
| async def enqueue_create_completed_event( | ||
| app: FastAPI, | ||
| schedule_id: ScheduleId, | ||
| operation_name: OperationName, | ||
| initial_context: OperationContext, | ||
| ) -> None: | ||
| await get_event_scheduler(app).enqueue_message_for( | ||
| CreateCompletedQueue, | ||
| OperationToStartEvent( | ||
| schedule_id=schedule_id, | ||
| operation_name=operation_name, | ||
| initial_context=initial_context, | ||
| ), | ||
| ) | ||
| 
     | 
||
| 
     | 
||
| async def enqueue_undo_completed_event( | ||
| app: FastAPI, | ||
| schedule_id: ScheduleId, | ||
| operation_name: OperationName, | ||
| initial_context: OperationContext, | ||
| ) -> None: | ||
| await get_event_scheduler(app).enqueue_message_for( | ||
| UndoCompletedQueue, | ||
| OperationToStartEvent( | ||
| schedule_id=schedule_id, | ||
| operation_name=operation_name, | ||
| initial_context=initial_context, | ||
| ), | ||
| ) | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.