|
4 | 4 | import logging |
5 | 5 | import os |
6 | 6 | import re |
| 7 | +import shutil |
7 | 8 | import tarfile |
8 | 9 | from typing import Any, cast, override |
9 | 10 |
|
@@ -72,6 +73,20 @@ def _CreateWorkloadTarball( |
72 | 73 | full_local_workload_data_path, |
73 | 74 | arcname=workload_name, |
74 | 75 | ) |
| 76 | + common_utils_path = data.ResourcePath('agentic_framework/common_utils.py') |
| 77 | + tar.add( |
| 78 | + common_utils_path, |
| 79 | + arcname=f'{workload_name}/common_utils.py', |
| 80 | + ) |
| 81 | + |
| 82 | + framework_utils_name = f'{self.spec.framework}_utils.py' |
| 83 | + utils_path = data.ResourcePath( |
| 84 | + f'agentic_framework/{framework_utils_name}' |
| 85 | + ) |
| 86 | + tar.add( |
| 87 | + utils_path, |
| 88 | + arcname=f'{workload_name}/{framework_utils_name}', |
| 89 | + ) |
75 | 90 | return tar_filename, tar_local_path |
76 | 91 |
|
77 | 92 |
|
@@ -222,9 +237,21 @@ def _StageAgentCode(self): |
222 | 237 | workload_data_path = ( |
223 | 238 | f'agentic_framework/{self.spec.workload}/{self.spec.framework}' |
224 | 239 | ) |
| 240 | + |
| 241 | + temp_dir = vm_util.PrependTempDir(f'custom_job_{self.spec.workload}') |
| 242 | + |
| 243 | + full_workload_path = data.ResourcePath(workload_data_path) |
| 244 | + shutil.copytree(full_workload_path, temp_dir, dirs_exist_ok=True) |
| 245 | + common_utils_path = data.ResourcePath('agentic_framework/common_utils.py') |
| 246 | + shutil.copy2(common_utils_path, os.path.join(temp_dir, 'common_utils.py')) |
| 247 | + |
| 248 | + framework_utils_name = f'{self.spec.framework}_utils.py' |
| 249 | + utils_path = data.ResourcePath(f'agentic_framework/{framework_utils_name}') |
| 250 | + shutil.copy2(utils_path, os.path.join(temp_dir, framework_utils_name)) |
| 251 | + |
225 | 252 | benchmark_spec = context.GetThreadBenchmarkSpec() |
226 | 253 | self._image_uri = benchmark_spec.container_registry.GetOrBuild( |
227 | | - os.path.basename(workload_data_path), workload_data_path |
| 254 | + os.path.basename(workload_data_path), temp_dir |
228 | 255 | ) |
229 | 256 |
|
230 | 257 | @override |
|
0 commit comments