Skip to content

Add interactive task support for GitHub-hosted task definitions (Ollama + Gradio)#1503

Merged
aliasaria merged 27 commits intomainfrom
add/interact-modal-component
Mar 12, 2026
Merged

Add interactive task support for GitHub-hosted task definitions (Ollama + Gradio)#1503
aliasaria merged 27 commits intomainfrom
add/interact-modal-component

Conversation

@aliasaria
Copy link
Copy Markdown
Member

Summary

This PR adds full support for interactive gallery entries that source their task definitions from GitHub repositories, replacing the previous local filesystem approach. The first entry to use this is the Ollama + Gradio interactive task, which launches an Ollama model server with a Gradio chat UI.

What was created

  • Ollama + Gradio interactive gallery entry (interactive-gallery.json): A new interactive task that starts Ollama, pulls a model, and launches a Gradio chat interface. It sources its task.yaml (setup/run commands, parameters, etc.) from transformerlab-examples/inference-ollama-gradio-chat.
  • InteractIframeModal: A near-fullscreen modal with a refresh button for rendering interactive task UIs in an iframe.
  • Interact button on InteractiveJobCard: Lets users open the interactive modal directly from a running job card.
  • Custom URL pattern matching (url_patterns field in gallery entries): Allows gallery entries to define regex patterns for extracting URLs from provider logs (e.g., Gradio's Running on ... output).

Key changes to support GitHub-sourced interactive tasks

Previously, interactive gallery entries could only use inline setup/command fields or a local_task_dir pointing to a directory on the local filesystem. This PR extends the system so interactive entries can use github_repo_url + github_repo_dir — the same pattern used by the regular task gallery.

Frontend (Interactive.tsx)

  • The condition that decides whether to use the ImportFromGallery API now triggers on template.github_repo_url in addition to template.local_task_dir. This routes GitHub-sourced interactive entries through the proper import flow that fetches task.yaml and stores the task with all its metadata.

Backend (task.py)

  • The interactive import path in import_task_from_gallery now handles three source types:
    1. github_repo_url + github_repo_dir → fetches task.yaml from GitHub via fetch_task_yaml_from_github()
    2. local_task_dir → reads task.yaml from local filesystem (existing behavior)
    3. Inline fields → uses setup/command directly from the gallery entry (existing behavior)
  • GitHub repo info (github_repo_url, github_directory, github_branch) is stored on the task so the runner clones the repo files at launch time.
  • The fetched task.yaml content is saved to the task directory, matching the behavior of regular task imports.

Other changes

  • Tunnel parser (tunnel_parser.py): Extended to support custom url_patterns for extracting dynamic URLs from provider logs.
  • Interactive gallery utils: Simplified to work with the new gallery structure.
  • Task schema: Added is_interactive field to the import request.
  • Gallery ID referencing: Tasks are now consistently referenced by id rather than interactive_type, supporting multiple entries of the same type.
  • Interact button: Disabled until tunnel_info is ready, preventing premature clicks.

Gallery entry diff

- "local_task_dir": "/Users/ali/.../tmp/ollama-gradio-chat",
+ "github_repo_url": "https://github.com/transformerlab/transformerlab-examples",
+ "github_repo_dir": "inference-ollama-gradio-chat",

Testing

  • Verified that the Ollama + Gradio interactive task can be created and launched from the Interactive tab.
  • Ollama server starts, pulls the specified model, and the Gradio chat UI launches successfully.
  • The Gradio URL is extracted from logs via url_patterns and displayed in the interactive modal.

When an interactive gallery entry specifies a local_task_dir path, the
files are copied into the task directory (inside a subdirectory matching
the source directory name) on import, mirroring the github_repo_dir
clone behavior. The task is marked with file_mounts=True so files are
copied to the job at launch.
When a local_task_dir has a task.yaml, its setup, run, parameters,
env_vars, and resource fields are now parsed and used to populate the
interactive task. This fixes the 'Task is missing a command to run'
error since command was previously left empty for local_task_dir entries.
When a gallery template has local_task_dir, the frontend now calls the
ImportFromGallery API instead of NewTemplate. This ensures the task gets
its command/setup populated from the directory's task.yaml and the files
are copied into the task directory. Fixes 'Task is missing a command to
run' error for local_task_dir gallery entries.
Tasks imported from local_task_dir gallery entries have their command
in the copied task.yaml rather than in the gallery JSON. Skip the
frontend command-required check when file_mounts is set.
For local_task_dir gallery entries, call ImportFromGallery instead of
NewTemplate so the task gets created with command/setup from task.yaml
and files copied — matching the regular 'Upload from Local Directory'
flow. Revert launch-time and command-check workarounds.
@paragon-review
Copy link
Copy Markdown

Paragon Summary

This pull request review identified 6 issues across 3 categories in 16 files. The review analyzed code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools.

This PR adds support for interactive gallery entries that source their task definitions from GitHub repositories (replacing the previous local filesystem approach), with the first implementation being an Ollama + Gradio chat interface. It extends both frontend and backend to fetch task.yaml from GitHub, store task metadata, and render interactive task UIs in a fullscreen iframe modal with URL extraction from provider logs.

Key changes:

  • GitHub-sourced interactive task support: Backend and frontend now handle github_repo_url + github_repo_dir for interactive gallery entries, previously limited to local filesystem
  • Ollama + Gradio interactive gallery entry: New task sourcing task.yaml from GitHub, launching Ollama model server with Gradio chat UI
  • InteractIframeModal component: Near-fullscreen modal with refresh button for rendering interactive task UIs in an iframe
  • Custom URL pattern matching: New url_patterns field for extracting dynamic URLs from provider logs (e.g., Gradio's Running on ... output)
  • Interact button on InteractiveJobCard: Button to open interactive modal directly from running job cards (disabled until tunnel_info ready)

Confidence score: 3/5

  • This PR has moderate risk due to 3 high-priority issues that should be addressed
  • Score reflects significant bugs, performance issues, or architectural concerns
  • Review high-priority findings carefully before merging

16 files reviewed, 6 comments

Severity breakdown: High: 3, Medium: 2, Low: 1


Tip: @paragon-run <instructions> to chat with our agent or push fixes!

Dashboard

provider_name: providerMeta.name,
env_vars: Object.keys(envVars).length > 0 ? envVars : undefined,
};
if (template.local_task_dir) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Tasks

Tasks.tsx checks only local_task_dir, missing github_repo_url. GitHub-sourced interactive tasks silently get empty commands. Add || template.github_repo_url.

View Details

Location: src/renderer/components/Experiment/Tasks/Tasks.tsx (lines 743)

Analysis

Tasks.tsx checks only local_task_dir, missing github_repo_url

What fails GitHub-sourced interactive tasks (like ollama_gradio) created from the Tasks tab get routed to the wrong code path, producing tasks with empty setup/command.
Result Task is created via the NewTemplate endpoint with empty command/setup fields instead of going through ImportFromGallery which fetches task.yaml from GitHub.
Expected Tasks.tsx should check `template.local_task_dir
Impact Every GitHub-sourced interactive task created from the Tasks view will fail at runtime with no command to execute.
How to reproduce
1. Open Tasks tab
2. Create a new interactive task using the ollama_gradio gallery entry (which has github_repo_url but no local_task_dir)
3. Observe the created task has no command/setup
Patch Details
-      if (template.local_task_dir) {
+      if (template.local_task_dir || template.github_repo_url) {
AI Fix Prompt
Fix this issue: Tasks.tsx checks only `local_task_dir`, missing `github_repo_url`. GitHub-sourced interactive tasks silently get empty commands. Add `|| template.github_repo_url`.

Location: src/renderer/components/Experiment/Tasks/Tasks.tsx (lines 743)
Problem: GitHub-sourced interactive tasks (like ollama_gradio) created from the Tasks tab get routed to the wrong code path, producing tasks with empty setup/command.
Current behavior: Task is created via the NewTemplate endpoint with empty command/setup fields instead of going through ImportFromGallery which fetches task.yaml from GitHub.
Expected: Tasks.tsx should check `template.local_task_dir || template.github_repo_url` (matching Interactive.tsx) and route GitHub-sourced entries through ImportFromGallery.
Steps to reproduce: 1. Open Tasks tab
2. Create a new interactive task using the ollama_gradio gallery entry (which has github_repo_url but no local_task_dir)
3. Observe the created task has no command/setup

Provide a code fix.


Tip: Reply with @paragon-run to automatically fix this issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is wrong


venv_bin = venv_path / "bin"
env = os.environ.copy()
print(f"[DEBUG LocalProvider] config.env_vars = {config.env_vars}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Debug print() statements dump env_vars containing secrets to stdout

Debug print() statements dump env_vars containing secrets to stdout. Credentials leak to logs and aggregators. Remove all [DEBUG print statements.

View Details

Location: api/transformerlab/compute_providers/local.py (lines 276)

Analysis

Debug print() statements dump env_vars containing secrets to stdout

What fails Debug print statements output full env_vars dicts containing NGROK_AUTH_TOKEN, {{secret.*}} references, and user-supplied values to stdout/logs in production.
Result Secrets and API tokens are written in plaintext to stdout, which is often forwarded to log aggregators, container runtimes, or returned via API log endpoints.
Expected No debug print statements should be present in production code. Secrets should never appear in logs.
Impact Credentials and API tokens exposed in plaintext logs. Violates the project's secret-management pattern where secrets use {{secret.}} placeholders.
How to reproduce
1. Launch any interactive task with env_vars (e.g. ollama_gradio with MODEL_NAME)
2. Check server stdout/logs
3. Observe full env_vars dicts printed in plaintext
AI Fix Prompt
Fix this issue: Debug print() statements dump env_vars containing secrets to stdout. Credentials leak to logs and aggregators. Remove all `[DEBUG` print statements.

Location: api/transformerlab/compute_providers/local.py (lines 276)
Problem: Debug print statements output full env_vars dicts containing NGROK_AUTH_TOKEN, {{secret.*}} references, and user-supplied values to stdout/logs in production.
Current behavior: Secrets and API tokens are written in plaintext to stdout, which is often forwarded to log aggregators, container runtimes, or returned via API log endpoints.
Expected: No debug print statements should be present in production code. Secrets should never appear in logs.
Steps to reproduce: 1. Launch any interactive task with env_vars (e.g. ollama_gradio with MODEL_NAME)
2. Check server stdout/logs
3. Observe full env_vars dicts printed in plaintext

Provide a code fix.


Tip: Reply with @paragon-run to automatically fix this issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

resolved

cpus: 2
memory: 4
setup: |
echo "=== SETUP DEBUG ==="
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: task

task.yaml ships debug echo blocks exposing PATH and VIRTUAL_ENV. These pollute user-facing logs. Strip debug echo statements before merge.

View Details

Location: tmp/ollama-gradio-chat/task.yaml (lines 8)

Analysis

task.yaml ships debug echo blocks exposing PATH and VIRTUAL_ENV. These pollute user-facing logs

What fails The task.yaml file contains extensive debug echo statements in both setup and run sections that print internal Python paths, sys.path, VIRTUAL_ENV, and PATH to job logs.
Result User-facing job logs are cluttered with internal debug information including Python paths and environment variables.
Expected Task definitions shipped to users should contain only functional commands. Debug echo blocks should be removed before merge.
Impact Noisy logs degrade UX. PATH and VIRTUAL_ENV disclosure is a minor information leak in production logs.
How to reproduce
1. Create and launch the ollama-gradio-chat interactive task
2. View the job logs
3. Observe debug output like 'which python:', 'sys.path:', 'VIRTUAL_ENV:', 'PATH:' polluting the log stream
AI Fix Prompt
Fix this issue: task.yaml ships debug echo blocks exposing PATH and VIRTUAL_ENV. These pollute user-facing logs. Strip debug echo statements before merge.

Location: tmp/ollama-gradio-chat/task.yaml (lines 8)
Problem: The task.yaml file contains extensive debug echo statements in both setup and run sections that print internal Python paths, sys.path, VIRTUAL_ENV, and PATH to job logs.
Current behavior: User-facing job logs are cluttered with internal debug information including Python paths and environment variables.
Expected: Task definitions shipped to users should contain only functional commands. Debug echo blocks should be removed before merge.
Steps to reproduce: 1. Create and launch the ollama-gradio-chat interactive task
2. View the job logs
3. Observe debug output like 'which python:', 'sys.path:', 'VIRTUAL_ENV:', 'PATH:' polluting the log stream

Provide a code fix.


Tip: Reply with @paragon-run to automatically fix this issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

resolved

… stdout

Debug print() statements dump env_vars containing secrets to stdout. Credentials leak to logs and aggregators. Remove all [DEBUG print statements.
The local_task_dir branch in Tasks.tsx was missing env_vars in the
POST body, causing user-provided environment parameters (e.g.
MODEL_NAME) to be silently dropped. Matches the Interactive.tsx
implementation.
Replace single iframeRef with a ref Map keyed by tab index and track
the active tab. handleRefresh() now resolves the correct iframe for
the currently selected tab.
Gate the SWR polling URL on isInteractive instead of showActions so
WAITING/LAUNCHING jobs no longer trigger 3s polling for tunnel info
that doesn't exist yet.
@aliasaria aliasaria merged commit d61bb73 into main Mar 12, 2026
5 of 7 checks passed
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.

1 participant