Supporting grafting envs onto pre-existing API#352
Merged
jamesbraza merged 3 commits intomainfrom Apr 16, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends Aviary’s TaskDatasetServer to support being mounted onto an external FastAPI app via an injected APIRouter, and adds a new TaskDataset.get_new_env_by_args() path so environments can be created from request-driven configuration (task_kwargs).
Changes:
- Add
TaskDataset.get_new_env_by_args()base API (defaultNotImplementedError). - Add
task_kwargsto/start(StartRequest) and define precedence overtask_idx. - Refactor
TaskDatasetServerto register routes on a router and optionally expose a standaloneFastAPIapp; add tests for mounted-router andtask_kwargsbehavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/test_envs.py |
Adds fixtures and tests covering task_kwargs, precedence vs task_idx, and mounting the server router under a prefix. |
src/aviary/env.py |
Introduces the TaskDataset.get_new_env_by_args() base method. |
src/aviary/dataset_server.py |
Adds task_kwargs support in StartRequest, introduces router injection/mounted mode, and shifts route registration to APIRouter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
398bcab to
374dd84
Compare
sidnarayanan
approved these changes
Apr 16, 2026
…rver Add TaskDataset.get_new_env_by_args(**kwargs) so subclasses can build envs from request-driven payloads rather than a fixed index. StartRequest picks it up via a new task_kwargs field (takes precedence over task_idx). TaskDatasetServer now accepts an optional APIRouter: routes are always attached to self.router, and in mounted mode the caller includes the router on their own FastAPI app (start()/astart() raise in that mode). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
374dd84 to
bbb0875
Compare
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR:
APIRouterinTaskDatasetServerso we can graft aviary endpoints onto a separate FastAPI serverTaskDataset.get_new_env_by_argsto let one build an env from a configurationtask_kwargstoStartRequestso it works withTaskDatasetServertask_idxandtask_kwargsare mutually exclusive; specifying both is rejected with a 422