Skip to content

Conversation

@deanq
Copy link
Member

@deanq deanq commented Oct 31, 2025

Merge the prerequisite first: #96

Summary

Adds flash build command to package Flash applications into self-contained tarballs with dependencies as local modules.

Changes

New Files

  • src/tetra_rp/cli/commands/build.py - Main build command implementation
  • src/tetra_rp/cli/utils/ignore.py - Gitignore-style pattern matching utility

Modified Files

  • pyproject.toml - Added pathspec>=0.11.0 dependency
  • src/tetra_rp/cli/main.py - Registered build command
  • src/tetra_rp/cli/utils/skeleton.py - Added .flashignore template to project scaffolding

Features

Command Options

flash build                  # Build with all dependencies
flash build --no-deps        # Skip transitive dependencies  
flash build --keep-build     # Keep temporary build directory
flash build -o custom.tar.gz # Custom archive name

Usage Example

# Initialize project
flash init my-app
cd my-app

# Build for deployment
flash build

# Output:
# ✓ Loaded ignore patterns          
# ✓ Found 7 files to package        
# ✓ Created .tetra/.build/my-app/ 
# ✓ Copied 7 files                  
# ✓ Installed 6 packages            
# ✓ Created archive.tar.gz (33.2 MB)

# Archive ready at .tetra/archive.tar.gz

Build Process

flowchart TD
    A[flash build] --> B[Load .flashignore + .gitignore]
    B --> C[Collect project files]
    C --> D[Create .tetra/.build/app-name/]
    D --> E[Copy files to build dir]
    E --> F[Collect requirements.txt]
    F --> G[Extract @remote dependencies]
    G --> H[pip install --target build_dir]
    H --> I[Create tarball]
    I --> J{--keep-build?}
    J -->|No| K[Delete .build/]
    J -->|Yes| L[Keep .build/]
    K --> M[.tetra/archive.tar.gz]
    L --> M
Loading

Implements tarball-based packaging for Flash applications with automatic
dependency management and gitignore-style file filtering.

Features:
- Package Flash apps into self-contained tarballs
- Install pip dependencies as local modules
- Respect .flashignore and .gitignore patterns
- Extract dependencies from @Remote decorators automatically
- Multiple pip command fallback support

Command options:
- flash build: Build with all dependencies
- flash build --no-deps: Skip transitive dependencies
- flash build --keep-build: Keep temporary build directory
- flash build -o custom.tar.gz: Custom archive name

Implementation:
- Add build.py command (496 lines)
- Add ignore.py utility for pattern matching (140 lines)
- Add .flashignore template to project scaffolding
- Add pathspec>=0.11.0 dependency for gitignore parsing
- Register build command in CLI main

Archive structure:
- .tetra/archive.tar.gz with app folder at root
- All pip packages installed alongside application code
- Clean extraction to single app directory
Copy link
Contributor

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

Adds a flash build command to package Flash applications into self-contained tarballs with all dependencies bundled as local modules, similar to AWS Lambda deployment packages.

Key Changes:

  • Implements build command with support for ignore patterns (.flashignore/.gitignore)
  • Adds dependency collection from requirements.txt and @Remote decorators
  • Provides CLI options for controlling transitive dependencies and build artifact retention

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/tetra_rp/cli/commands/build.py Core build command implementation with file collection, dependency installation, and tarball creation
src/tetra_rp/cli/utils/ignore.py Gitignore-style pattern matching utilities using pathspec library
src/tetra_rp/cli/utils/skeleton.py Added .flashignore template to project scaffolding
src/tetra_rp/cli/main.py Registered build command in CLI
pyproject.toml Added pathspec dependency for pattern matching

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

Address PR #104 review comments from GitHub Copilot by adding explicit
encoding='utf-8' parameter to all read_text() calls in flash build
command implementation.

Changes:
- cli/utils/ignore.py: Add encoding to ignore file parsing
- cli/commands/build.py: Add encoding to main.py, requirements.txt,
  and worker file parsing

Ensures consistent cross-platform file reading behavior regardless of
system default encoding (Windows cp1252 vs Linux/Mac UTF-8).
@deanq deanq requested a review from Copilot October 31, 2025 07:39
Copy link
Contributor

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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.


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

Address PR #104 review comments from GitHub Copilot:
- Modern type hint use
- Use only sys.executable -m pip to ensure correct environment
- PIP_INSTALL_TIMEOUT_SECONDS constant
@deanq deanq merged commit 55111c5 into ae-flash-init Oct 31, 2025
@deanq deanq deleted the deanq/ae-1251-flash-build-packager branch October 31, 2025 18:31
deanq added a commit that referenced this pull request Oct 31, 2025
* feat: AE-1202 add flash cli cmd init and run

* feat(client): add local execution mode to @Remote decorator

Adds optional 'local' parameter to @Remote decorator enabling local function/class execution without remote server provisioning. This facilitates testing and development by bypassing remote execution while maintaining the same decorator interface. Also adds detection for RunPod worker mode to return unwrapped functions when already running on the platform.

* feat(cpu): add CpuInstanceType.ANY with auto-expansion

Add support for CpuInstanceType.ANY which automatically expands to all
available CPU instance types, providing flexibility similar to GPU
endpoint behavior.

Changes:
- Add CpuInstanceType.ANY enum value
- Add CpuInstanceType.all() classmethod to return all types except ANY
- Update CpuServerlessEndpoint default from CPU3G_2_8 to ANY
- Add field validator to expand [ANY] to all instance types
- Exclude ANY from CPU_INSTANCE_DISK_LIMITS dict

Test coverage:
- Test ANY enum value and all() method behavior
- Test validator expansion and explicit list preservation
- Update existing tests for new default behavior
- Verify ANY exclusion from disk limits calculation

* fix(dev): enable flash CLI in editable mode for local development

Changes:
- Add editable install to make dev target
- Configure setuptools to find packages in src/ directory
- Update CLI branding to "Runpod Flash CLI"

The flash CLI now works correctly in development mode while
maintaining proper packaging for end users. Editable install
ensures src/ changes are immediately active without reinstall.

* test: fix CPU LiveServerless default to use ANY (all instances)

The default for CpuLiveServerless is CpuInstanceType.ANY which expands
to all available CPU instance types. Updated test expectations to match
actual behavior where ANY expands to all instances with minimum disk
size of 10GB.

* build: fix broken build

* chore: local dev changes

* build: make update

* feat(cli): add flash build command for packaging application artifact (#104)

* feat(cli): add flash build command for AWS Lambda-style packaging

Implements tarball-based packaging for Flash applications with automatic
dependency management and gitignore-style file filtering.

Features:
- Package Flash apps into self-contained tarballs
- Install pip dependencies as local modules
- Respect .flashignore and .gitignore patterns
- Extract dependencies from @Remote decorators automatically
- Multiple pip command fallback support

Command options:
- flash build: Build with all dependencies
- flash build --no-deps: Skip transitive dependencies
- flash build --keep-build: Keep temporary build directory
- flash build -o custom.tar.gz: Custom archive name

Implementation:
- Add build.py command (496 lines)
- Add ignore.py utility for pattern matching (140 lines)
- Add .flashignore template to project scaffolding
- Add pathspec>=0.11.0 dependency for gitignore parsing
- Register build command in CLI main

Archive structure:
- .tetra/archive.tar.gz with app folder at root
- All pip packages installed alongside application code
- Clean extraction to single app directory

* fix: add explicit UTF-8 encoding to file reads

Address PR #104 review comments from GitHub Copilot by adding explicit
encoding='utf-8' parameter to all read_text() calls in flash build
command implementation.

Changes:
- cli/utils/ignore.py: Add encoding to ignore file parsing
- cli/commands/build.py: Add encoding to main.py, requirements.txt,
  and worker file parsing

Ensures consistent cross-platform file reading behavior regardless of
system default encoding (Windows cp1252 vs Linux/Mac UTF-8).

* fix: more feedback cleanup

Address PR #104 review comments from GitHub Copilot:
- Modern type hint use
- Use only sys.executable -m pip to ensure correct environment
- PIP_INSTALL_TIMEOUT_SECONDS constant

---------

Co-authored-by: Dean Quiñanola <[email protected]>
Co-authored-by: Dean Quiñanola <[email protected]>
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