Skip to content

Supporting grafting envs onto pre-existing API#352

Merged
jamesbraza merged 3 commits intomainfrom
router-dataset-server
Apr 16, 2026
Merged

Supporting grafting envs onto pre-existing API#352
jamesbraza merged 3 commits intomainfrom
router-dataset-server

Conversation

@jamesbraza
Copy link
Copy Markdown
Collaborator

@jamesbraza jamesbraza commented Apr 15, 2026

This PR:

  • Adds support for an APIRouter in TaskDatasetServer so we can graft aviary endpoints onto a separate FastAPI server
    • Can share things like port, middleware
    • Can outsource lifecycle management
  • Creates TaskDataset.get_new_env_by_args to let one build an env from a configuration
    • Adds optional task_kwargs to StartRequest so it works with TaskDatasetServer
    • task_idx and task_kwargs are mutually exclusive; specifying both is rejected with a 422

@jamesbraza jamesbraza self-assigned this Apr 15, 2026
Copilot AI review requested due to automatic review settings April 15, 2026 19:42
@jamesbraza jamesbraza added the enhancement New feature or request label Apr 15, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 15, 2026
@jamesbraza jamesbraza requested a review from MicPie April 15, 2026 19:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (default NotImplementedError).
  • Add task_kwargs to /start (StartRequest) and define precedence over task_idx.
  • Refactor TaskDatasetServer to register routes on a router and optionally expose a standalone FastAPI app; add tests for mounted-router and task_kwargs behavior.

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.

Comment thread src/aviary/dataset_server.py Outdated
Comment thread src/aviary/dataset_server.py
Comment thread src/aviary/dataset_server.py Outdated
@jamesbraza jamesbraza force-pushed the router-dataset-server branch from 398bcab to 374dd84 Compare April 15, 2026 20:14
Comment thread src/aviary/dataset_server.py Outdated
jamesbraza and others added 2 commits April 16, 2026 11:25
…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>
@jamesbraza jamesbraza force-pushed the router-dataset-server branch from 374dd84 to bbb0875 Compare April 16, 2026 18:38
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@jamesbraza jamesbraza merged commit 79918d5 into main Apr 16, 2026
5 checks passed
@jamesbraza jamesbraza deleted the router-dataset-server branch April 16, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants