1212 calibration_package_artifact_paths ,
1313 resolve_target_config_identity ,
1414)
15+ from policyengine_us_data .stage_contracts .calibration_package import (
16+ CalibrationPackageParameters ,
17+ )
1518from policyengine_us_data .utils .manifest import compute_file_checksum
1619
1720
21+ def _sha256_digest (path : Path ) -> str :
22+ return f"sha256:{ compute_file_checksum (path )} "
23+
24+
1825def _write_default_target_config (repo_root : Path , body : str = "include: []\n " ) -> Path :
1926 config_path = repo_root / DEFAULT_TARGET_CONFIG_PATH
2027 config_path .parent .mkdir (parents = True )
@@ -29,13 +36,13 @@ def test_default_target_config_identity_resolution(tmp_path):
2936
3037 assert identity == TargetConfigIdentity (
3138 path = DEFAULT_TARGET_CONFIG_PATH ,
32- sha256 = compute_file_checksum (config_path ),
39+ sha256 = _sha256_digest (config_path ),
3340 mode = "default" ,
3441 resolved_path = str (config_path .resolve ()),
3542 )
3643 assert identity .to_parameters () == {
3744 "target_config" : DEFAULT_TARGET_CONFIG_PATH ,
38- "target_config_sha256" : compute_file_checksum (config_path ),
45+ "target_config_sha256" : _sha256_digest (config_path ),
3946 "target_config_mode" : "default" ,
4047 }
4148
@@ -49,11 +56,33 @@ def test_explicit_target_config_identity_resolution(tmp_path):
4956 )
5057
5158 assert identity .path == DEFAULT_TARGET_CONFIG_PATH
52- assert identity .sha256 == compute_file_checksum (config_path )
59+ assert identity .sha256 == _sha256_digest (config_path )
5360 assert identity .mode == "explicit"
5461 assert identity .resolved_path == str (config_path .resolve ())
5562
5663
64+ def test_resolved_target_config_identity_is_contract_compatible (tmp_path ):
65+ _write_default_target_config (tmp_path )
66+ identity = resolve_target_config_identity (repo_root = tmp_path )
67+
68+ params = CalibrationPackageParameters .from_runtime_args (
69+ workers = 8 ,
70+ n_clones = 430 ,
71+ target_config_path = identity .path ,
72+ target_config_sha256 = identity .sha256 ,
73+ target_config_mode = identity .mode ,
74+ skip_county = True ,
75+ skip_source_impute = True ,
76+ skip_takeup_rerandomize = False ,
77+ chunked_matrix = False ,
78+ chunk_size = 25_000 ,
79+ parallel = False ,
80+ num_matrix_workers = 50 ,
81+ )
82+
83+ assert params .target_config_sha256 == identity .sha256
84+
85+
5786def test_all_active_targets_identity_resolution ():
5887 identity = resolve_target_config_identity (all_active_targets = True )
5988
0 commit comments