Skip to content

Commit 9c0fe83

Browse files
Fix key error on getting the "testing" key on older contexts and bump context serialize_version (#1863)
Signed-off-by: Jean-Christophe Morin <[email protected]>
1 parent 09bf497 commit 9c0fe83

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"append_sys_path": true,
3+
"arch": "x86_64",
4+
"building": false,
5+
"caching": false,
6+
"created": 1729961872,
7+
"default_patch_lock": "no_lock",
8+
"failure_description": null,
9+
"from_cache": false,
10+
"graph": "{'nodes': [((('fillcolor', '#FFFFAA'), ('fontsize', 10), ('style', 'filled,dashed')), [('_1', 'hello_world')]), ((('fillcolor', '#AAFFAA'), ('fontsize', 10), ('style', 'filled')), [('_2', 'hello_world-1.0[]')])], 'edges': [((('arrowsize', '0.5'),), [('_1', '_2')])]}",
11+
"host": "arch01",
12+
"implicit_packages": [],
13+
"load_time": 0.0,
14+
"num_loaded_packages": 1,
15+
"os": "arch",
16+
"package_cache_async": true,
17+
"package_caching": true,
18+
"package_filter": [],
19+
"package_orderers": null,
20+
"package_paths": [
21+
"/tmp/rez_selftest_ec71iu0a/packages"
22+
],
23+
"package_requests": [
24+
"hello_world"
25+
],
26+
"parent_suite_path": null,
27+
"patch_locks": {},
28+
"platform": "linux",
29+
"requested_timestamp": null,
30+
"resolved_ephemerals": [],
31+
"resolved_packages": [
32+
{
33+
"key": "filesystem.variant",
34+
"variables": {
35+
"index": null,
36+
"location": "/tmp/rez_selftest_ec71iu0a/packages",
37+
"name": "hello_world",
38+
"repository_type": "filesystem",
39+
"version": "1.0"
40+
}
41+
}
42+
],
43+
"rez_path": "/home/jcmorin/jcmenv/aswf/rez/src/rez",
44+
"rez_version": "3.1.1",
45+
"serialize_version": "4.8",
46+
"solve_time": 0.00042057037353515625,
47+
"status": "solved",
48+
"suite_context_name": null,
49+
"timestamp": 1729961872,
50+
"user": "jcmorin"
51+
}

src/rez/resolved_context.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ResolvedContext(object):
134134
command within a configured python namespace, without spawning a child
135135
shell.
136136
"""
137-
serialize_version = (4, 8)
137+
serialize_version = (4, 9)
138138
tmpdir_manager = TempDirs(config.context_tmpdir, prefix="rez_context_")
139139
context_tracking_payload = None
140140
context_tracking_lock = threading.Lock()
@@ -1630,7 +1630,6 @@ def _print_version(value):
16301630

16311631
r.timestamp = d["timestamp"]
16321632
r.building = d["building"]
1633-
r.testing = d["testing"]
16341633
r.caching = d["caching"]
16351634
r.implicit_packages = [PackageRequest(x) for x in d["implicit_packages"]]
16361635
r._package_requests = [PackageRequest(x) for x in d["package_requests"]]
@@ -1725,6 +1724,9 @@ def _print_version(value):
17251724

17261725
r.package_cache_async = d.get("package_cache_async", True)
17271726

1727+
# -- SINCE SERIALIZE 4.9
1728+
r.testing = d.get("testing", False)
1729+
17281730
# <END SERIALIZATION>
17291731

17301732
# track context usage

src/rez/tests/test_context.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def test_serialize(self):
129129
env = r2.get_environ()
130130
self.assertEqual(env.get("OH_HAI_WORLD"), "hello")
131131

132+
def test_deserialize_older_versions(self):
133+
"""Test deserialization of older contexts."""
134+
baked_contexts_path = self.data_path("contexts")
135+
136+
for context_file in os.listdir(baked_contexts_path):
137+
# load
138+
_ = ResolvedContext.load(os.path.join(baked_contexts_path, context_file))
139+
132140
def test_retarget(self):
133141
"""Test that a retargeted context behaves identically."""
134142
self.inject_python_repo()

0 commit comments

Comments
 (0)