Skip to content

feat(export): install server requirements - #10473

Open
peter-gy wants to merge 1 commit into
mainfrom
ptr/install-export-requirements
Open

feat(export): install server requirements#10473
peter-gy wants to merge 1 commit into
mainfrom
ptr/install-export-requirements

Conversation

@peter-gy

@peter-gy peter-gy commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a server-owned installation contract for export requirements.

The client sends an export format. The server resolves its missing packages and setup requirements, installs them into the server Python environment, and returns refreshed availability for every server-backed export format.

  • Uses uv when available and pip otherwise.
  • Runs package installation outside the event loop.
  • Installs Playwright Chromium through a typed setup requirement with a 10-minute timeout.
  • Requires edit capability and verifies the requested format after installation.

The export dialog consumes this contract in #10471.

Install the packages and setup requirements owned by an export format, then return refreshed server availability.
@github-actions github-actions Bot added the bash-focus Area to focus on during release bug bash label Aug 6, 2026
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 6, 2026 12:04pm

Request Review

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 78.81% 81571 / 103492
🔵 Statements 78.81% 81571 / 103492
🔵 Functions 71.22% 693 / 973
🔵 Branches 79.37% 4858 / 6120
File CoverageNo changed files found.
Generated in workflow #20262 for commit adc1c8f by the Vitest Coverage Report Action

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 14 files

Architecture diagram
sequenceDiagram
    participant Client as Export Dialog (Client)
    participant API as Export API Endpoint
    participant Util as Server Utils
    participant UV as UvPackageManager
    participant Pip as PipPackageManager
    participant Deps as Export Dependencies
    participant Sub as subprocess

    Note over Client,Sub: NEW: Install Export Requirements Flow

    Client->>API: POST /api/export/requirements/install {format: "pdf"}
    API->>API: enforce_consumer_capability("edit")
    
    API->>Deps: _get_export_format_availability("pdf")
    Deps->>Deps: get_missing_export_packages()
    Deps->>Deps: get_missing_export_setup()
    Deps-->>API: {missing_packages: ["nbconvert[webpdf]"], missing_setup: [...]}

    alt Missing packages exist
        API->>Util: install_packages_on_server({"nbconvert[webpdf]": ""})
        
        Note over Util: Try uv first, then pip
        
        Util->>UV: is_manager_installed()
        alt uv available
            UV-->>Util: True
            Util->>UV: install("nbconvert[webpdf]", version=None)
            UV->>UV: _install_with_cache_fallback()
            Note over UV: Runs via asyncio.to_thread to avoid blocking event loop
            UV-->>Util: True
        else uv not available
            UV-->>Util: False
            Util->>Pip: is_manager_installed()
            Pip-->>Util: True
            Util->>Pip: install("nbconvert[webpdf]", version=None)
            Pip-->>Util: True
        end
        Util-->>API: Success
        
        API->>Deps: _get_export_format_availability("pdf")
        Deps-->>API: {missing_packages: [], missing_setup: [{"name": "playwright-chromium"}]}
    end

    alt Missing setup exists
        API->>Deps: install_export_setup("playwright-chromium")
        Deps->>Sub: subprocess.run([python, -m, playwright, install, chromium])
        Note over Deps,Sub: Runs via asyncio.to_thread with 600s timeout
        Sub-->>Deps: CompletedProcess(returncode=0)
        Deps-->>API: Success
    end

    API->>Deps: _get_export_availability()
    Deps-->>API: {"formats": [{"format":"html",...}, {"format":"pdf","dependenciesAvailable":true},...]}

    alt Target format still unresolved
        API-->>Client: 500 SERVER_ERROR
    else All requirements resolved
        API-->>Client: 200 ExportAvailabilityResponse
    end

    Note over Client,Sub: Failure paths
    alt Playwright install fails
        Deps->>Sub: subprocess.run()
        Sub-->>Deps: TimeoutExpired or returncode != 0
        Deps->>Deps: raise RuntimeError
        Deps-->>API: Error
        API-->>Client: 500 SERVER_ERROR
    else Package install fails
        Util->>Pip: install()
        Pip-->>Util: False
        Util->>Util: raise RuntimeError
        Util-->>API: Error
        API-->>Client: 500 SERVER_ERROR
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/openapi/api.yaml
Comment thread tests/_server/api/test_api_utils.py
@peter-gy
peter-gy marked this pull request as ready for review August 6, 2026 12:15
@peter-gy
peter-gy requested review from Copilot and mscolnick August 6, 2026 12:15

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change bash-focus Area to focus on during release bug bash enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants