MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / check_taskset_path

Function check_taskset_path

benchmark/bench.py:81–175  ·  view source on GitHub ↗

Ensures the taskset path exists for the given dataset; generates it if necessary. This function checks whether `taskset_path` exists. If not, it uses a corresponding data generation script (e.g., gen_countdown_data.py) to create the dataset at the default or provided location. The gener

(dataset_name: str, taskset_path: str)

Source from the content-addressed store, hash-verified

79
80
81def check_taskset_path(dataset_name: str, taskset_path: str) -> str:
82 """Ensures the taskset path exists for the given dataset; generates it if necessary.
83
84 This function checks whether `taskset_path` exists. If not,
85 it uses a corresponding data generation script (e.g., gen_countdown_data.py) to create
86 the dataset at the default or provided location. The generator scripts are expected
87 to be located in the 'scripts/' subdirectory relative to this file.
88
89 Args:
90 dataset_name: Name of the dataset (e.g., "countdown", "guru").
91 Must be one of the supported datasets defined in `dataset_script_map`.
92 taskset_path: Path to the dataset.
93
94 Returns:
95 str: The resolved path to the dataset.
96
97 Raises:
98 ValueError: If the `dataset_name` is not supported.
99 FileNotFoundError: If the corresponding generator script does not exist.
100 ImportError: If the generator module fails to load.
101 AttributeError: If the loaded module does not define 'DEFAULT_DATA_PATH'.
102 subprocess.CalledProcessError: If the generation script fails (due to check=True).
103
104 Side Effects:
105 - May create directories and files on disk via the external generation script.
106 - Executes a subprocess to run the dataset generation script.
107
108 Examples:
109 For dataset_name='guru_math' and taskset_path=None, this function will runs the
110 following command and generate the guru_math dataset to default location
111 (DEFAULT_DATA_PATH in scripts/gen_guru_math_data.py):
112
113 ```bash
114 python scripts/gen_guru_math_data.py --local_dir DEFAULT_DATA_PATH
115 ```
116 """
117 if taskset_path:
118 if os.path.exists(taskset_path):
119 return taskset_path
120 if dataset_name == "gsm8k" and taskset_path == "openai/gsm8k":
121 return taskset_path
122
123 base_dir = os.path.dirname(__file__)
124 frozenlake_data_script_path = os.path.abspath(
125 os.path.join(
126 base_dir,
127 "..",
128 "examples",
129 "grpo_frozen_lake",
130 "get_frozen_lake_data.py",
131 )
132 )
133 dataset_script_map = {
134 "countdown": "gen_countdown_data.py",
135 "guru_math": "gen_guru_math_data.py",
136 "alfworld": "get_alfworld_full_data.py",
137 "frozenlake": frozenlake_data_script_path,
138 }

Callers 1

prepare_configsFunction · 0.70

Calls 1

runMethod · 0.45

Tested by

no test coverage detected