File size: 2,024 Bytes
e479c46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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.

from __future__ import annotations

import os
import sys

import pytest
from test_support.readme import extract_code_blocks, find_block
from test_support.runtime import get_root, run_subprocess_step


REPO_ROOT = get_root()
DATA_CONFIG_README = REPO_ROOT / "getting_started" / "data_config.md"

_IMPORTS = (
    "from gr00t.data.types import ModalityConfig, ActionConfig, ActionFormat, ActionRepresentation, ActionType\n"
    "from gr00t.data.embodiment_tags import EmbodimentTag\n"
    "from gr00t.configs.data.embodiment_configs import MODALITY_CONFIGS, register_modality_config\n"
    "MODALITY_CONFIGS.pop(EmbodimentTag.NEW_EMBODIMENT.value, None)\n"
)
_REGISTER = "register_modality_config(so100_config, embodiment_tag=EmbodimentTag.NEW_EMBODIMENT)\n"


@pytest.mark.serial
def test_complete_so100_config() -> None:
    """The complete SO-100 config example in data_config.md executes without error."""
    blocks = extract_code_blocks(DATA_CONFIG_README)
    so100 = find_block(blocks, "so100_config = {", language="python", occurrence=2)
    code = _IMPORTS + "\n" + so100.code + "\n" + _REGISTER
    env = {**os.environ}
    # Inherit the parent venv; `uv run` here would rebuild gr00t every call.
    run_subprocess_step(
        [sys.executable, "-c", code],
        step="so100_config",
        cwd=REPO_ROOT,
        env=env,
    )