-
Notifications
You must be signed in to change notification settings - Fork 1
New features #88
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
Closed
Closed
New features #88
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5693cd1
Ordered timing fields in logical way; added hover help text
pendingintent a84ff8d
Changed Default Condition header
pendingintent 18e6102
Rearranged headers to make timings more intuitive
pendingintent ef1a7ca
Added ISO validation rules for windows, value as well as all-or-nothi…
pendingintent ee05f7e
Removed numpy dependency
pendingintent 564fab7
Merge branch 'master' into ui-features
pendingintent f52d47c
Ensure window values are all-or-nothing
pendingintent 1511c1e
Merge branch 'ui-features' of https://github.com/pendingintent/soa-wo…
pendingintent c50a8f1
Updated requirements.txt
pendingintent 80cedf0
Updated requirements.txt
pendingintent aa57741
Updated to use python 3.13
pendingintent 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,50 @@ | ||
| import re | ||
| from typing import List, Optional | ||
|
|
||
| from pydantic import BaseModel | ||
| from pydantic import BaseModel, field_validator, model_validator | ||
|
|
||
| # ISO 8601 duration pattern supporting both standard (-P2D) and USDM (P-2D) conventions | ||
| _ISO8601_DURATION_RE = re.compile( | ||
| r"^-?P-?(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$" | ||
| ) | ||
|
Comment on lines
+6
to
+9
|
||
|
|
||
|
|
||
| def _validate_iso8601_duration(v: Optional[str]) -> Optional[str]: | ||
| if v is None: | ||
| return v | ||
| v = v.strip() | ||
| if not v: | ||
| return None | ||
| m = _ISO8601_DURATION_RE.match(v) | ||
| if not m or not any(m.group(i) is not None for i in range(1, 8)): | ||
| raise ValueError( | ||
| f"'{v}' is not a valid ISO 8601 duration (e.g. P1D, P2W, PT8H, -P2D)" | ||
| ) | ||
| return v | ||
|
|
||
|
|
||
| def _validate_window_all_or_none( | ||
| window_lower: Optional[str], | ||
| window_upper: Optional[str], | ||
| window_label: Optional[str], | ||
| ) -> None: | ||
| """Enforce that window_lower, window_upper, and window_label are all provided or all absent.""" | ||
|
|
||
| def _present(v: Optional[str]) -> bool: | ||
| return v is not None and v.strip() != "" | ||
|
|
||
| provided = [_present(window_lower), _present(window_upper), _present(window_label)] | ||
| if any(provided) and not all(provided): | ||
| missing = [] | ||
| if not _present(window_lower): | ||
| missing.append("window_lower") | ||
| if not _present(window_upper): | ||
| missing.append("window_upper") | ||
| if not _present(window_label): | ||
| missing.append("window_label") | ||
| raise ValueError( | ||
| f"Window fields are all-or-nothing: missing {', '.join(missing)}" | ||
| ) | ||
|
|
||
|
|
||
| class InstanceUpdate(BaseModel): | ||
|
|
@@ -42,6 +86,18 @@ class TimingCreate(BaseModel): | |
| window_lower: Optional[str] = None | ||
| member_of_timeline: Optional[str] = None | ||
|
|
||
| @field_validator("value", "window_lower", "window_upper", mode="before") | ||
| @classmethod | ||
| def check_iso8601_duration(cls, v: Optional[str]) -> Optional[str]: | ||
| return _validate_iso8601_duration(v) | ||
|
|
||
| @model_validator(mode="after") | ||
| def check_window_all_or_none(self) -> "TimingCreate": | ||
| _validate_window_all_or_none( | ||
| self.window_lower, self.window_upper, self.window_label | ||
| ) | ||
| return self | ||
|
|
||
|
|
||
| class TimingUpdate(BaseModel): | ||
| name: str | ||
|
|
@@ -58,6 +114,18 @@ class TimingUpdate(BaseModel): | |
| window_lower: Optional[str] = None | ||
| member_of_timeline: Optional[str] = None | ||
|
|
||
| @field_validator("value", "window_lower", "window_upper", mode="before") | ||
| @classmethod | ||
| def check_iso8601_duration(cls, v: Optional[str]) -> Optional[str]: | ||
| return _validate_iso8601_duration(v) | ||
|
|
||
| @model_validator(mode="after") | ||
| def check_window_all_or_none(self) -> "TimingUpdate": | ||
| _validate_window_all_or_none( | ||
| self.window_lower, self.window_upper, self.window_label | ||
| ) | ||
| return self | ||
|
|
||
|
|
||
| class ScheduleTimelineCreate(BaseModel): | ||
| name: str | ||
|
|
||
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.
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.
Aggregating only
e["msg"]drops the field context, making UI errors harder to act on (e.g., users can’t tell whetherwindow_uppervsvaluefailed). Include the error location (typicallye["loc"]) in the message formatting so the response clearly identifies which field(s) are invalid.