|
40 | 40 | from rdagent.core.experiment import RD_AGENT_SETTINGS
|
41 | 41 | from rdagent.log import rdagent_logger as logger
|
42 | 42 | from rdagent.oai.llm_utils import md5_hash
|
| 43 | +from rdagent.utils.agent.tpl import T |
43 | 44 | from rdagent.utils.workflow import wait_retry
|
44 | 45 |
|
45 | 46 |
|
@@ -240,15 +241,32 @@ def run_ret_code(
|
240 | 241 | # FIXME: the input path and cache path is hard coded here.
|
241 | 242 | # We don't want to change the content in input and cache path.
|
242 | 243 | # Otherwise, it may produce large amount of warnings.
|
| 244 | + def _get_chmod_cmd(workspace_path: str) -> str: |
| 245 | + def _get_path_stem(path: str) -> str | None: |
| 246 | + # If the input path is relative, keep only the first component |
| 247 | + p = Path(path) |
| 248 | + if not p.is_absolute() and p.parts: |
| 249 | + return p.parts[0] |
| 250 | + return None |
| 251 | + |
| 252 | + chmod_cmd = f"chmod -R 777 $(find {workspace_path} -mindepth 1 -maxdepth 1" |
| 253 | + for name in [ |
| 254 | + _get_path_stem(T("scenarios.data_science.share:scen.cache_path").r()), |
| 255 | + _get_path_stem(T("scenarios.data_science.share:scen.input_path").r()), |
| 256 | + ]: |
| 257 | + chmod_cmd += f" ! -name {name}" |
| 258 | + chmod_cmd += ")" |
| 259 | + return chmod_cmd |
| 260 | + |
243 | 261 | entry_add_timeout = (
|
244 | 262 | f"/bin/sh -c 'timeout --kill-after=10 {self.conf.running_timeout_period} {entry}; "
|
245 | 263 | + "entry_exit_code=$?; "
|
246 | 264 | + (
|
247 |
| - f"chmod -R 777 $(find {self.conf.mount_path} -mindepth 1 -maxdepth 1 ! -name cache ! -name input); " |
| 265 | + f"{_get_chmod_cmd(self.conf.mount_path)}" |
248 | 266 | # We don't have to change the permission of the cache and input folder to remove it
|
249 | 267 | # + f"if [ -d {self.conf.mount_path}/cache ]; then chmod 777 {self.conf.mount_path}/cache; fi; " +
|
250 | 268 | # f"if [ -d {self.conf.mount_path}/input ]; then chmod 777 {self.conf.mount_path}/input; fi; "
|
251 |
| - if hasattr(self.conf, "mount_path") |
| 269 | + if isinstance(self.conf, DockerConf) |
252 | 270 | else ""
|
253 | 271 | )
|
254 | 272 | + "exit $entry_exit_code'"
|
@@ -409,7 +427,7 @@ def _run_ret_code(
|
409 | 427 | volumes[lp] = rp
|
410 | 428 | cache_path = "/tmp/sample" if "/sample/" in "".join(self.conf.extra_volumes.keys()) else "/tmp/full"
|
411 | 429 | Path(cache_path).mkdir(parents=True, exist_ok=True)
|
412 |
| - volumes[cache_path] = "./cache" |
| 430 | + volumes[cache_path] = T("scenarios.data_science.share:scen.cache_path").r() |
413 | 431 | for lp, rp in running_extra_volume.items():
|
414 | 432 | volumes[lp] = rp
|
415 | 433 |
|
@@ -821,7 +839,7 @@ def _run_ret_code(
|
821 | 839 | volumes[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
822 | 840 | cache_path = "/tmp/sample" if "/sample/" in "".join(self.conf.extra_volumes.keys()) else "/tmp/full"
|
823 | 841 | Path(cache_path).mkdir(parents=True, exist_ok=True)
|
824 |
| - volumes[cache_path] = {"bind": "./cache", "mode": "rw"} |
| 842 | + volumes[cache_path] = {"bind": T("scenarios.data_science.share:scen.cache_path").r(), "mode": "rw"} |
825 | 843 | for lp, rp in running_extra_volume.items():
|
826 | 844 | volumes[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
827 | 845 |
|
|
0 commit comments