-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: durable runtime support #4200
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
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
78b1c4e
feat: extract durable runtime support changes
marcusmotill 57ddf8f
chore: remove pr_description.md
marcusmotill 08d099d
address Bo comments, move runtime to platform
marcusmotill cc58fa5
updates for durable execution
marcusmotill 5abb519
back out a2a changes
marcusmotill 544af2d
update for concurrency and review feedback
marcusmotill f518ee6
cover more bases with regards to durable utils
marcusmotill 0c695cc
revert rounding
marcusmotill 2856d2d
remove unused imports
marcusmotill 48a56ba
Merge upstream main and resolve conflicts
marcusmotill ae66ac9
Merge branch 'main' into motill/durable-support
marcusmotill 31700cb
Merge branch 'main' into motill/durable-support
sasha-gitg 61798e2
chore: run formatting and linting (isort/pyink)
marcusmotill 8863af6
Merge branch 'main' into motill/durable-support
marcusmotill 5f003fb
chore: add __future__.annotations to platform modules
marcusmotill 448a351
fix: cast platform_uuid.new_uuid to str for mypy strictness
marcusmotill 0791508
Merge branch 'main' into motill/durable-support
marcusmotill 06eeca8
Merge upstream/main and resolve conflict
marcusmotill 9673095
fix(typing): explicitly cast platform uuid to str using typing.cast t…
marcusmotill 118bc91
Merge remote-tracking branch 'origin/motill/durable-support' into mot…
marcusmotill 8082764
fix(typing): add missing annotations and typing.cast to event.py and …
marcusmotill b491999
revert(typing): remove unnecessary model_post_init typing
marcusmotill 6225046
Merge branch 'main' into motill/durable-support
marcusmotill 79f8a48
Merge branch 'main' into motill/durable-support
sasha-gitg b317e57
import order and double casting
marcusmotill 6244b3b
Merge branch 'main' into motill/durable-support
sasha-gitg 8234af3
Merge branch 'main' into motill/durable-support
marcusmotill 345e478
Merge branch 'main' into motill/durable-support
marcusmotill 61d0e31
add license header
marcusmotill 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
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,43 @@ | ||
| # Copyright 2026 Google LLC | ||
|
sasha-gitg marked this conversation as resolved.
|
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Platform module for abstracting system time generation.""" | ||
|
|
||
| import time | ||
| from typing import Callable | ||
|
|
||
| _default_time_provider: Callable[[], float] = time.time | ||
|
sasha-gitg marked this conversation as resolved.
|
||
| _time_provider: Callable[[], float] = _default_time_provider | ||
|
|
||
|
|
||
| def set_time_provider(provider: Callable[[], float]) -> None: | ||
|
marcusmotill marked this conversation as resolved.
|
||
| """Sets the provider for the current time. | ||
|
|
||
| Args: | ||
| provider: A callable that returns the current time in seconds since the | ||
| epoch. | ||
| """ | ||
| global _time_provider | ||
| _time_provider = provider | ||
|
|
||
|
|
||
| def reset_time_provider() -> None: | ||
| """Resets the time provider to its default implementation.""" | ||
| global _time_provider | ||
| _time_provider = _default_time_provider | ||
|
|
||
|
|
||
| def get_time() -> float: | ||
| """Returns the current time in seconds since the epoch.""" | ||
| return _time_provider() | ||
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,42 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Platform module for abstracting unique ID generation.""" | ||
|
|
||
| import uuid | ||
| from typing import Callable | ||
|
|
||
| _default_id_provider: Callable[[], str] = lambda: str(uuid.uuid4()) | ||
| _id_provider: Callable[[], str] = _default_id_provider | ||
|
|
||
|
|
||
| def set_id_provider(provider: Callable[[], str]) -> None: | ||
| """Sets the provider for generating unique IDs. | ||
|
|
||
| Args: | ||
| provider: A callable that returns a unique ID string. | ||
| """ | ||
| global _id_provider | ||
| _id_provider = provider | ||
|
|
||
|
|
||
| def reset_id_provider() -> None: | ||
| """Resets the ID provider to its default implementation.""" | ||
| global _id_provider | ||
| _id_provider = _default_id_provider | ||
|
|
||
|
|
||
| def new_uuid() -> str: | ||
| """Returns a new unique ID.""" | ||
| return _id_provider() |
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Copyright 2026 Google LLC | ||
|
marcusmotill marked this conversation as resolved.
|
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Unit tests for the platform time module.""" | ||
|
|
||
| import time | ||
| import unittest | ||
|
|
||
| from google.adk.platform import time as platform_time | ||
|
|
||
|
|
||
| class TestTime(unittest.TestCase): | ||
|
|
||
| def tearDown(self): | ||
| # Reset provider to default after each test | ||
| platform_time.reset_time_provider() | ||
|
|
||
| def test_default_time_provider(self): | ||
| # Verify it returns a float that is close to now | ||
| now = time.time() | ||
| rt_time = platform_time.get_time() | ||
| self.assertIsInstance(rt_time, float) | ||
| self.assertAlmostEqual(rt_time, now, delta=1.0) | ||
|
|
||
| def test_custom_time_provider(self): | ||
| # Test override | ||
| mock_time = 123456789.0 | ||
| platform_time.set_time_provider(lambda: mock_time) | ||
| self.assertEqual(platform_time.get_time(), mock_time) | ||
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,40 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Unit tests for the platform uuid module.""" | ||
|
|
||
| import uuid | ||
| import unittest | ||
|
|
||
| from google.adk.platform import uuid as platform_uuid | ||
|
|
||
|
|
||
| class TestUUID(unittest.TestCase): | ||
|
|
||
| def tearDown(self): | ||
| # Reset provider to default after each test | ||
| platform_uuid.reset_id_provider() | ||
|
|
||
| def test_default_id_provider(self): | ||
| # Verify it returns a string uuid | ||
| uid = platform_uuid.new_uuid() | ||
| self.assertIsInstance(uid, str) | ||
| # Should be parseable as uuid | ||
| uuid.UUID(uid) | ||
|
|
||
| def test_custom_id_provider(self): | ||
| # Test override | ||
| mock_id = "test-id-123" | ||
| platform_uuid.set_id_provider(lambda: mock_id) | ||
| self.assertEqual(platform_uuid.new_uuid(), mock_id) |
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.