-
Notifications
You must be signed in to change notification settings - Fork 20
feat(gen_sim): add Scene Engine and Gradio workspace #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
61001a7
ad708e8
b664562
fe6c1af
4c0cfc7
a67ac77
c630f16
8ae888d
c38c0fc
b86c3b5
c99182c
e7f3fbe
79442f5
a0f6797
db438e7
d1b363a
23947e5
b0774a4
ede8172
73e285e
244ab1b
930af9b
05f8a1a
d0d39ca
114734d
b61ef2f
693e1eb
ab2ad30
93096a5
93abb7a
a6a3219
3b1abc2
dd66de8
e4bc9e3
bbf2a06
c45be97
fbe72ee
c3f672d
2436a37
5eb9134
2c9477d
2d64a80
f51bc5d
82acb65
8979f68
4f4102b
d710331
4347d6e
44539f3
9b0c5eb
3ef309e
3e3c50b
e5d9d20
f508f18
14bbf52
b5ad4fa
0d78765
edbe95c
d8862e8
2c9a023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Shared GenSim configuration | ||
| # Copy this file to .env and set deployment-specific values. Values exported | ||
| # by the shell, container, or CI environment take precedence over this file. | ||
|
|
||
| # Common OpenAI-compatible LLM endpoint used by Scene Engine. | ||
| OPENAI_API_KEY="" | ||
| OPENAI_MODEL="" | ||
| OPENAI_BASE_URL="" | ||
| SCENE_ENGINE_OPENAI_DEFAULT_QUERY="{}" | ||
| OPENAI_MAX_ATTEMPTS=3 | ||
|
|
||
| # Scene Engine services. | ||
| SCENE_ENGINE_IMAGE_SEGMENTATION_BASE_URL="" | ||
| SCENE_ENGINE_IMAGE_SEGMENTATION_TIMEOUT_S=30 | ||
| SCENE_ENGINE_IMAGE_SEGMENTATION_MAX_ATTEMPTS=3 | ||
| SCENE_ENGINE_IMAGE_SEGMENTATION_HEALTH_PATH="/health" | ||
| SCENE_ENGINE_IMAGE_SEGMENTATION_SINGLE_OBJECT_PATH="/predict" | ||
| SCENE_ENGINE_GEOMETRY_GENERATION_BASE_URL="" | ||
| SCENE_ENGINE_GEOMETRY_GENERATION_TIMEOUT_S=600 | ||
| SCENE_ENGINE_GEOMETRY_GENERATION_MAX_ATTEMPTS=3 | ||
| SCENE_ENGINE_GEOMETRY_GENERATION_HEALTH_PATH="/health" | ||
| SCENE_ENGINE_GEOMETRY_GENERATION_OBJECTS_PATH="/generate_multiple_objects" | ||
|
|
||
| # Gradio application and local workbench settings. The EmbodiChain repository | ||
| # root is derived automatically from the installed source tree. | ||
| GRADIO_SERVER_NAME="127.0.0.1" | ||
| GRADIO_SERVER_PORT=7860 | ||
| # Both values are required when GRADIO_SERVER_NAME is not a loopback address. | ||
| GRADIO_AUTH_USERNAME="" | ||
| GRADIO_AUTH_PASSWORD="" | ||
| SCENE_ENGINE_VISER_PORT=8080 | ||
| ARTICRAFT_VISER_PORT=8081 | ||
| ACTION_ENGINE_VISER_PORT=8082 | ||
| ARTICRAFT_ROOT="" | ||
| ARTICRAFT_REPOSITORY_URL="https://github.com/mattzh72/articraft.git" | ||
| ARTICRAFT_CONDA_ENV="articraft" | ||
| ARTICRAFT_OUTPUT_ROOT="" | ||
|
|
||
| # Optional SimReady endpoint. These values are mapped to OPENAI_* only for | ||
| # SimReady subprocesses, leaving Scene Engine settings unchanged. | ||
| SIMREADY_OPENAI_API_KEY="" | ||
| SIMREADY_OPENAI_MODEL="" | ||
| SIMREADY_OPENAI_BASE_URL="" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| """Load the shared GenSim environment configuration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| from typing import MutableMapping | ||
|
|
||
| __all__ = ["find_gen_sim_env_file", "get_embodichain_root", "load_gen_sim_env"] | ||
|
|
||
|
|
||
| def get_embodichain_root() -> Path: | ||
| """Return the repository containing the installed GenSim source tree. | ||
|
|
||
| The Gradio app always launches its local tools from this directory. It is | ||
| derived from this module instead of a machine-specific dotenv value, so a | ||
| checkout continues to work after it is moved or cloned elsewhere. | ||
| """ | ||
| return Path(__file__).resolve().parents[2] | ||
|
|
||
|
|
||
| def find_gen_sim_env_file() -> Path | None: | ||
| """Return the configured shared ``.env`` file path. | ||
|
|
||
| ``EMBODICHAIN_ENV_FILE`` is useful for deployments that keep secrets outside | ||
| the source tree. Otherwise GenSim uses ``embodichain/gen_sim/.env``. | ||
|
|
||
| Returns: | ||
| The configured or default dotenv path, or ``None`` when neither exists. | ||
| """ | ||
| configured_path = os.environ.get("EMBODICHAIN_ENV_FILE") | ||
| if configured_path: | ||
| return Path(configured_path).expanduser().resolve() | ||
| default_path = Path(__file__).resolve().parent / ".env" | ||
| if default_path.is_file(): | ||
| return default_path | ||
| return None | ||
|
|
||
|
|
||
| def load_gen_sim_env(env: MutableMapping[str, str] | None = None) -> Path | None: | ||
| """Load missing variables from the shared GenSim ``.env`` file. | ||
|
|
||
| Existing process environment variables are never overwritten so container, | ||
| CI, and shell-provided settings retain precedence over the local file. | ||
|
|
||
| Args: | ||
| env: Environment mapping to populate. Defaults to :data:`os.environ`. | ||
|
|
||
| Returns: | ||
| The loaded path, or ``None`` when no local ``.env`` file exists. | ||
|
|
||
| Raises: | ||
| 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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When neither |
||
| if env_path is None or not env_path.is_file(): | ||
| return None | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
| for line_number, raw_line in enumerate( | ||
| env_path.read_text(encoding="utf-8").splitlines(), start=1 | ||
| ): | ||
| parsed = _parse_env_line(raw_line) | ||
| if parsed is None: | ||
| continue | ||
| key, value = parsed | ||
| if not key.isidentifier(): | ||
| raise ValueError( | ||
| f"Invalid environment variable name at {env_path}:{line_number}: {key!r}" | ||
| ) | ||
| target_env.setdefault(key, value) | ||
| return env_path | ||
|
|
||
|
|
||
| def _parse_env_line(line: str) -> tuple[str, str] | None: | ||
| """Parse one conventional dotenv line without requiring a third-party package.""" | ||
| stripped = line.strip() | ||
| if not stripped or stripped.startswith("#"): | ||
| return None | ||
| if stripped.startswith("export "): | ||
| stripped = stripped.removeprefix("export ").lstrip() | ||
| if "=" not in stripped: | ||
| raise ValueError(f"Expected KEY=VALUE entry, got: {line!r}") | ||
|
|
||
| key, value = stripped.split("=", maxsplit=1) | ||
| key = key.strip() | ||
| value = value.strip() | ||
| if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}: | ||
| value = value[1:-1] | ||
| elif " #" in value: | ||
| value = value.split(" #", maxsplit=1)[0].rstrip() | ||
| return key, value | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Gradio dependancies