-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Robot() factory + top-level lazy imports #86
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
cagataycali
wants to merge
22
commits into
strands-labs:main
Choose a base branch
from
cagataycali:feat/robot-factory
base: main
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.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cd94627
feat: MuJoCo simulation backend — AgentTool with 35 actions
cagataycali fca42b8
fix: address all review comments — ABC, thread-safety, injection, cle…
cagataycali b35e99e
fix: resolve lint errors — import ordering, format, strict param
cagataycali bf9dfe0
fix: acquire _lock around MuJoCo data mutations + sanitize all XML names
cagataycali 37cdb19
ci: add MuJoCo system deps (libosmesa6-dev + MUJOCO_GL=osmesa)
cagataycali 9987c23
feat: add [sim] extra with mujoco dependency
cagataycali 8a6c510
fix: rename [sim] extra to [sim-mujoco] per review
2f6d6e6
fix: rebase on simulation-foundation — SimulationBackend→SimEngine, u…
cagataycali fb5a14a
fix: resolve all mypy errors — mixin overrides, Optional types, impor…
cagataycali 8b8c78d
fix: properly fix mypy errors instead of blanket suppression
cagataycali 4964643
fix: zero mypy suppressions — proper type declarations instead of dis…
cagataycali 4ca9173
feat(sim): use require_optional for imageio in policy_runner
cagataycali 70648d1
fix: address 8 review threads — deps, exports, init, headless, coupli…
cagataycali 19ea1dd
fix: replace Protocol annotation with direct TYPE_CHECKING stubs in P…
strands-agent 62fa590
refactor(mujoco): migrate SimWorld private fields to _backend_state
abc65e6
feat: Robot() factory + top-level lazy imports
cagataycali 1639079
fix: address review — resource leak, exception narrowing, GL comment,…
cagataycali 33c45eb
fix: handle None in serial port description/manufacturer during auto-…
cagataycali 9af0a55
fix: use inline MJCF in test_sim_happy_path so CI works without assets
cagataycali 577b00f
refactor: address 10 review threads from @awsarron on PR #86
strands-agent ac55331
docs: address 3 unresolved review threads from @awsarron on PR #86
cagataycali 0917c24
fix(hardware_robot): add missing type annotations for mypy strict
cagataycali 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,36 @@ | ||
| """Async-to-sync helper for resolving coroutines in sync contexts.""" | ||
|
|
||
| import asyncio | ||
| import atexit | ||
| from concurrent.futures import ThreadPoolExecutor | ||
|
|
||
| # Module-level executor reused across calls to avoid creating threads at high frequency. | ||
| # A single worker is sufficient — we only need to offload one asyncio.run() at a time. | ||
| _EXECUTOR = ThreadPoolExecutor(max_workers=1, thread_name_prefix="strands_async") | ||
|
|
||
| # Ensure the executor is shut down cleanly on interpreter exit to avoid | ||
| # ResourceWarning and orphaned threads. | ||
| atexit.register(_EXECUTOR.shutdown, wait=False) | ||
|
|
||
|
|
||
| def _resolve_coroutine(coro_or_result): # type: ignore[no-untyped-def] | ||
| """Safely resolve a potentially-async result to a sync value. | ||
|
|
||
| Handles three cases: | ||
| 1. Already a plain value → return as-is | ||
| 2. Coroutine, no running loop → asyncio.run() | ||
| 3. Coroutine, inside running loop → offload to reused thread | ||
|
|
||
| Args: | ||
| coro_or_result: Either a coroutine or an already-resolved value. | ||
|
|
||
| Returns: | ||
| The resolved (sync) value. | ||
| """ | ||
| if not asyncio.iscoroutine(coro_or_result): | ||
| return coro_or_result | ||
| try: | ||
| asyncio.get_running_loop() | ||
| return _EXECUTOR.submit(asyncio.run, coro_or_result).result() | ||
| except RuntimeError: | ||
| return asyncio.run(coro_or_result) |
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.