-
Notifications
You must be signed in to change notification settings - Fork 18
feat: processing stages in framework #439
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
Draft
rock-n-shrimproll
wants to merge
9
commits into
dev
Choose a base branch
from
feat/add_processing_stage
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
01b351c
framework_data.current_stage added
rock-n-shrimproll 4e1eea2
Merge branch 'dev' into feat/add_processing_stage
rock-n-shrimproll d225cc7
log_exception and get_lasr_exception first glance
rock-n-shrimproll 6c262dd
minor fixes
rock-n-shrimproll 3ebee6a
def get_exception fixed
rock-n-shrimproll 4c38b7c
minor codestyle fix
rock-n-shrimproll 8354055
get_exception fixed
rock-n-shrimproll d982b09
tests for get_exception added
rock-n-shrimproll 0ba69d1
fixture for None ctx added
rock-n-shrimproll 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from asyncio import Event | ||
| from json import loads | ||
| from time import time_ns | ||
| from typing import Any, Optional, Dict, TYPE_CHECKING | ||
| from typing import Any, List, Optional, Dict, Literal, TYPE_CHECKING, Tuple | ||
|
|
||
| from pydantic import BaseModel, Field, PrivateAttr, TypeAdapter, field_serializer, field_validator | ||
|
|
||
|
|
@@ -40,6 +40,18 @@ class ServiceState(BaseModel, arbitrary_types_allowed=True): | |
| Cleared at the end of every turn. | ||
| """ | ||
|
|
||
| STAGES = ["PRE_SERVICE", "PRE_TRANSITION", "CONDITION", "PRIORITY", "DESTINATION", "PRE_RESPONSE", "RESPONSE", "POST_SERVICE"] | ||
|
|
||
| class ExceptionInfo(BaseModel, arbitrary_types_allowed=True): | ||
| PRE_SERVICE: List[Exception] = Field(default_factory=list) | ||
| PRE_TRANSITION: List[Exception] = Field(default_factory=list) | ||
| CONDITION: List[Exception] = Field(default_factory=list) | ||
| PRIORITY: List[Exception] = Field(default_factory=list) | ||
| DESTINATION: List[Exception] = Field(default_factory=list) | ||
| TRANSITION: List[Exception] = Field(default_factory=list) | ||
| PRE_RESPONSE: List[Exception] = Field(default_factory=list) | ||
| RESPONSE: List[Exception] = Field(default_factory=list) | ||
| POST_SERVICE: List[Exception] = Field(default_factory=list) | ||
|
|
||
| class FrameworkData(BaseModel, arbitrary_types_allowed=True): | ||
| """ | ||
|
|
@@ -74,6 +86,19 @@ class FrameworkData(BaseModel, arbitrary_types_allowed=True): | |
| - no transition has been made during this turn yet (e.g. the turn is in the pre-transition step); | ||
| - no valid transition has been found (i.e. transitioned to fallback node). | ||
| """ | ||
| current_stage: Optional[Literal[*STAGES]] = Field(default=None, exclude=True) | ||
|
||
| "Stores current processing stage" | ||
| exception_info: Optional[ExceptionInfo] = Field(default=None, exclude=True) | ||
| "Stores exceptions raised at different stages" | ||
|
|
||
| def get_exception(self, stage: Optional[Literal[*STAGES]]) -> Optional[Tuple[str, ExceptionInfo]]: | ||
| if stage is None: | ||
| for stage in reversed(STAGES): | ||
| exception_list = getattr(self.exception_info, stage, []) | ||
| if exception_list: | ||
| return stage, exception_list[-1] | ||
| else: | ||
| return getattr(self.exception_info, stage, []) | ||
|
|
||
|
|
||
| class ContextMainInfo(BaseModel): | ||
|
|
||
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
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
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.
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.
Remove exception info model, replace with
Dict[Stages, List[Exception]], anddefaultdict(list).