Skip to content

Commit 1ebb896

Browse files
Cross-product deepcopy fix (#106)
Co-authored-by: Maxime Gasse <[email protected]>
1 parent 3e94570 commit 1ebb896

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- name: Check MiniWob availability
5959
run: curl -I "http://localhost:8080/miniwob/" || echo "MiniWob not reachable"
6060

61+
- name: Pre-download nltk ressources
62+
run: python -c "import nltk; nltk.download('punkt_tab')"
63+
6164
- name: Run AgentLab Unit Tests
6265
env:
6366
MINIWOB_URL: "http://localhost:8080/miniwob/"

src/agentlab/experiments/args.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,19 @@ def expand_cross_product(obj: Any | list[Any]):
105105
for obj in obj_list:
106106
cprod_paths = _find_cprod_with_paths(obj)
107107
if not cprod_paths:
108-
return [copy.deepcopy(obj)]
108+
result.append(copy.deepcopy(obj))
109+
continue
109110

110111
paths, cprod_objects = zip(*cprod_paths)
111112
combinations = product(*[cprod_obj.elements for cprod_obj in cprod_objects])
112113

114+
# create a base object with empty fields to make fast deep copies from
115+
base_obj = copy.deepcopy(obj)
116+
for path in paths:
117+
_set_value(base_obj, path, None)
118+
113119
for combo in combinations:
114-
new_obj = copy.deepcopy(obj)
120+
new_obj = copy.deepcopy(base_obj)
115121
for path, value in zip(paths, combo):
116122
_set_value(new_obj, path, value)
117123
result.append(new_obj)

0 commit comments

Comments
 (0)