Skip to content

feat(gen_sim): add Scene Engine and Gradio workspace - #457

Open
XuanchaoPENG wants to merge 60 commits into
mainfrom
xuanchao/gradio
Open

feat(gen_sim): add Scene Engine and Gradio workspace#457
XuanchaoPENG wants to merge 60 commits into
mainfrom
xuanchao/gradio

Conversation

@XuanchaoPENG

Copy link
Copy Markdown
Collaborator

Description

This PR introduces an image-to-scene generation workflow for EmbodiChain, together with a Gradio-based workspace for running and previewing generative-simulation workflows.

Key changes:

  • Add Scene Engine, which reconstructs tabletop scenes from an input image by performing scene understanding, segmentation, geometry generation, layout refinement, and scene export.
  • Add embodichain scene-engine and embodichain preview-scene CLI commands.
  • Add a Gradio workspace with managed pipeline execution and Viser scene previews.
  • Add Scene Engine configuration through embodichain/gen_sim/.env and an example environment file.
  • Add the scene-engine optional dependency group; extend the gensim extra with Scene Engine dependencies.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

MuziWong and others added 30 commits July 29, 2026 11:30
@yuecideng
yuecideng self-requested a review August 6, 2026 08:23
# Conflicts:
#	.github/workflows/main.yml
#	embodichain/gen_sim/scene_engine/pipeline/utils/scene_exporter.py
#	pyproject.toml
#	tests/gen_sim/scene_engine/test_scene_core_and_export.py
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds an image-to-scene generation workflow and a Gradio workspace for running, managing, and previewing Scene Engine, SimReady, Articraft, and Action Engine pipelines.

  • Adds shared GenSim environment loading and configuration.
  • Adds session-aware subprocess lifecycle management and Viser previews.
  • Adds Articraft/Codex and SimReady asset-generation interfaces.
  • Adds optional dependency groups and focused configuration/UI tests.

Confidence Score: 4/5

The PR is not yet safe to merge because Articraft preview readiness can still accept an unrelated listener and Codex still has write access to other sessions’ records.

The current preview check proves only that some service is listening on the selected port, while the released probe socket leaves the ownership race reachable. Codex is also granted workspace-write access to the entire shared Articraft output directory, so prompt instructions do not prevent cross-session record modification.

Files Needing Attention: embodichain/gen_sim/gradio_ui/app_articraft.py

Important Files Changed

Filename Overview
embodichain/gen_sim/env.py Adds optional shared dotenv discovery and loading; the missing-file startup failure is now guarded and tested.
embodichain/gen_sim/gradio_ui/app_processes.py Adds per-session subprocess ownership, termination helpers, output redaction, and credential-minimized Codex environments.
embodichain/gen_sim/gradio_ui/app_articraft.py Adds Codex-backed articulation generation and Viser previews, but previously reported listener-ownership and shared-output write boundaries remain unresolved.
embodichain/gen_sim/gradio_ui/app_asset_engine.py Adds session-scoped SimReady execution and Articraft integration; the prior missing import and cross-session reset failures are fixed.
embodichain/gen_sim/gradio_ui/app_workflows.py Implements Scene and Action Engine execution, generated-scene management, and Viser preview orchestration.
pyproject.toml Adds Scene Engine dependencies and extends the GenSim optional dependency group.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    U[Gradio workspace] --> S[Scene Engine]
    U --> A[Asset Engine]
    U --> X[Action Engine]
    A --> R[SimReady]
    A --> C[Articraft and Codex]
    S --> E[Scene exports]
    R --> M[Processed assets]
    C --> M
    E --> V[Viser previews]
    M --> V
    X --> V
Loading

Reviews (4): Last reviewed commit: "delete gradio test" | Re-trigger Greptile

Comment thread embodichain/gen_sim/env.py
Comment thread embodichain/gen_sim/gradio_ui/app_articraft.py Outdated
Comment thread embodichain/gen_sim/gradio_ui/app_articraft.py Outdated
Comment thread embodichain/gen_sim/gradio_ui/app_asset_engine.py Outdated
Comment thread embodichain/__main__.py
target="embodichain.workspace_cache_cli:main",
help="Inspect and clean workspace analyzer caches.",
),
Command(

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.

Recovery this command

@yuecideng yuecideng 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.

Review focused on the new Gradio workspace. The inline comments cover security, data-loss, runtime, packaging, and CI blockers. Local validation also found that pytest tests/test_main.py fails because analyze-workspace is no longer registered, while pytest tests/gen_sim fails during collection because of the duplicate test_config.py module name. The existing inline thread on embodichain/__main__.py already calls out restoring that command, so I did not duplicate it.

server_name=SERVER_NAME,
server_port=SERVER_PORT,
allowed_paths=[
str(EMBODICHAIN_ROOT),

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.

Blocking security issue: this exposes the entire repository through Gradio while the server defaults to 0.0.0.0 and no authentication is configured. Gradio treats every file below an allowed directory as publicly servable, so this includes embodichain/gen_sim/.env and its API credentials. Please whitelist only the generated artifact/assets directories, explicitly block secret paths, and either bind to localhost by default or require authentication.

key=lambda item: len(item.parts),
reverse=True,
):
if path.is_file() and path.suffix.lower() not in VIDEO_SUFFIXES:

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.

OUTPUTS_DIR is the repository-wide outputs/ directory, so this loop deletes every non-video file below it whenever Reset or Auto cleanup runs. That includes unrelated RL checkpoints, debug reports, trajectories, and datasets. Please track and remove only artifacts created by the current Gradio run instead of recursively cleaning this shared directory.


def configured_lerobot_roots() -> list[Path]:
roots: list[Path] = []
env_root = os.environ.get("EMBODICHAIN_DATASET_ROOT")

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.

This function cannot run: os is not imported, and CURRENT_PATHS referenced below is not defined or imported by this module either. monitor_simulation() calls this path after DexSim exits but before clearing runtime.sim_process, so every completion raises NameError and leaves the UI/Auto loop stuck in a running state. Please import or pass these dependencies explicitly and make the runtime cleanup execute in a finally path.

f"Port {self._port} is unavailable without a visible listener."
)

self._signal_listeners(listener_pids, signal.SIGTERM, "stop")

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.

This treats every process listening on the configured port as a stale Articraft preview and sends it SIGTERM, later escalating to SIGKILL, without verifying ownership. A normal port collision can therefore terminate an unrelated user service. Please terminate only self._process (or another registered child owned by this app); otherwise report that the port is already in use.

ValueError: If the file contains an invalid ``KEY=VALUE`` entry.
"""
target_env = os.environ if env is None else env
env_path = find_gen_sim_env_file()

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.

When neither EMBODICHAIN_ENV_FILE nor embodichain/gen_sim/.env exists, find_gen_sim_env_file() falls through and returns None, so this immediately raises AttributeError: 'NoneType' object has no attribute 'is_file'. A clean checkout only contains .env.example. Please return Path | None and guard None here, or always return the documented fallback path.

def build_pipeline_env() -> dict[str, str]:
env = os.environ.copy()
configure_direct_network_env(env)
configure_simready_llm_env(env)

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.

build_pipeline_env() is used by Scene Engine, DexSim, Viser, and Articraft preview processes as well as SimReady, but this unconditionally maps SIMREADY_OPENAI_* over OPENAI_*. If separate endpoints are configured as supported by .env.example, Scene Engine will receive the SimReady model, URL, and key. Please apply this mapping only to the SimReady command.

return "stopped"

with runtime_lock:
simulation_completed = (

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.

sim_returncode is recorded by the monitor but never checked here. A non-zero DexSim exit still satisfies sim_started && sim_finished && sim_process is None, so Auto records the round as completed and continues to later phases. Please require runtime.sim_returncode == 0 and also propagate a non-zero exit to the failed phase/last_error.


import pytest

from embodichain.gen_sim.scene_engine.cli import start

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.

This new test module has the same basename as tests/gen_sim/simready_pipeline/test_config.py, and neither parent directory is a Python package. With the repository's default pytest import mode, pytest tests/gen_sim fails during collection with an import-file-mismatch error. Please rename this file (for example, test_scene_engine_cli_config.py) or make the test directories packages/use importlib mode.

from pathlib import Path
from typing import Any, Iterable

import gradio as gr

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.

Gradio is now a direct runtime dependency of this feature, but neither the core dependency list nor the gensim extra declares it. A clean pip install .[gensim] therefore cannot reliably launch this UI. Please add a supported Gradio version to an appropriate optional extra and document that installation path.

Comment thread .gitignore
/gym_project/
.debug_engine/

# Local Gradio UI dependencies, generated Articraft records, and bytecode

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.

Add Gradio dependancies

Comment thread embodichain/gen_sim/gradio_ui/app_asset_engine.py
Comment thread embodichain/gen_sim/gradio_ui/app_articraft.py
Comment thread embodichain/gen_sim/gradio_ui/app_articraft.py
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