fix(testdata): 工料机池按 x_hash_exact 同口径去重——不同 code 的同名同规格同单位会撞 lmes (batch_id,x_hash_exact) 唯一约束(真实库底子必现)
This commit is contained in:
11
release/testdata/gen_testdata.py
vendored
11
release/testdata/gen_testdata.py
vendored
@@ -762,9 +762,16 @@ def build_project_data(rng, cfg, words, m_idx, bid_local=True):
|
|||||||
nrm_lo, nrm_hi = int(cfg["norm_lo"]), max(int(cfg["norm_lo"]), int(cfg["norm_hi"]))
|
nrm_lo, nrm_hi = int(cfg["norm_lo"]), max(int(cfg["norm_lo"]), int(cfg["norm_hi"]))
|
||||||
res_lo, res_hi = int(cfg["res_lo"]), max(int(cfg["res_lo"]), int(cfg["res_hi"]))
|
res_lo, res_hi = int(cfg["res_lo"]), max(int(cfg["res_lo"]), int(cfg["res_hi"]))
|
||||||
_u = {} # 真实库同 code 跨批次重复,lme_lib 有
|
_u = {} # 真实库同 code 跨批次重复,lme_lib 有
|
||||||
for it in words.lmes: # (batch_id, code) 唯一约束 → 先去重再抽样
|
for it in words.lmes: # (batch_id, code) 唯一约束 → 先按 code 去重
|
||||||
_u.setdefault(it[0], it)
|
_u.setdefault(it[0], it)
|
||||||
_uniq = list(_u.values())
|
_seen = set() # lmes 还有 (batch_id, x_hash_exact) 唯一约束:
|
||||||
|
_uniq = [] # 不同 code 的同名同规格同单位也要去重
|
||||||
|
for it in _u.values():
|
||||||
|
k = md5(it[1], it[2], it[3]) # 与落库 x_hash_exact 同口径
|
||||||
|
if k in _seen:
|
||||||
|
continue
|
||||||
|
_seen.add(k)
|
||||||
|
_uniq.append(it)
|
||||||
lme_pool = rng.sample(_uniq, min(len(_uniq), rng.randint(260, 520)))
|
lme_pool = rng.sample(_uniq, min(len(_uniq), rng.randint(260, 520)))
|
||||||
lme_by_kind = {1: [], 2: [], 3: []}
|
lme_by_kind = {1: [], 2: [], 3: []}
|
||||||
for it in lme_pool:
|
for it in lme_pool:
|
||||||
|
|||||||
Reference in New Issue
Block a user