Skip to content

feat: add example 01-04 - Dependency Management - #5

Merged
deanq merged 4 commits into
mainfrom
deanq/ae-1471-01-04-example
Nov 18, 2025
Merged

deanq merged 4 commits into
mainfrom
deanq/ae-1471-01-04-example

Conversation

@deanq

@deanq deanq commented Nov 17, 2025

Copy link
Copy Markdown
Member

Prerequisite: merge #4 before this

Add comprehensive dependency management example demonstrating:

Worker Features:
- Python dependencies with version constraints (==, >=, <)
- System dependencies via apt packages
- Minimal workers with no dependencies for fast cold start
- ML dependencies (torch, torchvision, Pillow, numpy)
- Computer vision system deps (ffmpeg, libgl1)

Implementation:
- CPU workers for data science (pandas, numpy, scipy, matplotlib)
- GPU workers for ML inference with versioned packages
- Minimal CPU worker with stdlib only
- Pydantic field validators for input validation
- Prevents NaN serialization with minimum row validation

Validation:
- At least 2 rows required for statistics computation
- Exactly 2 columns per row validation
- Empty data validation
- Helpful error messages with examples

Comprehensive README covers:
- Dependency types and version constraints
- Common dependency stacks (ML, data science, CV, audio, NLP)
- Input validation with Pydantic best practices
- Field validators and common patterns
- System dependencies and cold start optimization
- Troubleshooting and best practices
@linear

linear Bot commented Nov 17, 2025

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a comprehensive example (01-04) demonstrating dependency management in Flash applications, including Python package versioning, system dependencies, and input validation patterns.

Key Changes:

  • Adds new example directory 01_getting_started/04_dependencies/ with GPU and CPU workers showcasing different dependency configurations
  • Updates repository documentation to reflect the new port (8888) and improved setup workflows
  • Adds VS Code debug configuration and PR template for better developer experience

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
01_getting_started/04_dependencies/workers/gpu/endpoint.py GPU workers demonstrating ML dependencies (torch, pillow) and system packages (ffmpeg, libgl1)
01_getting_started/04_dependencies/workers/cpu/endpoint.py CPU workers showing data science dependencies and minimal/no-dependency patterns
01_getting_started/04_dependencies/workers/cpu/__init__.py FastAPI router with Pydantic field validators for input validation
01_getting_started/04_dependencies/README.md Comprehensive guide covering dependency management, validation patterns, and best practices
README.md Updated setup instructions, port change (8000→8888), and testing documentation
CONTRIBUTING.md Added VS Code debugging section and port updates
pyproject.toml Added torch dependency to root project
.vscode/launch.json VS Code debug configuration for endpoint development

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deanq
deanq changed the base branch from main to deanq/ae-1471-01_getting_started November 17, 2025 22:53
return {"result": "processed"}
```

## Input Validation with Pydantic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it worth trimming up some of the details about Flash using Pydantic for this example? I see the use of having it but I wonder if it's okay to omit some here to keep the example focused - someone could read more about Pydantic if they want the details outside of how/why Flash uses it

)


@remote(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know most of this is covered in the README, but for someone skimming in the code it could be helpful to have an extra inline callout that deps are handled here, and are explicitly handled differently than system deps? Also, maybe a discussion on how deps are handled under the hood and why baking deps into a custom docker image will decrease cold start time. For example, I think about Lambda's "best practices" page where they talk about putting code outside of the handler function, but also explain (briefly) why that helps with faster warm starts and costs.

Base automatically changed from deanq/ae-1471-01_getting_started to main November 18, 2025 20:16
@deanq
deanq merged commit 9a7e9f5 into main Nov 18, 2025
@deanq
deanq deleted the deanq/ae-1471-01-04-example branch November 18, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants