added json save button and remove history button. Added logging to save process
This commit is contained in:
@@ -21,21 +21,74 @@ def select_aligned_histories(
|
||||
result_history: list[ResultCollection],
|
||||
last_n: int,
|
||||
) -> tuple[list[SweepCollection], list[SweepCollection], list[ResultCollection], dict[str, Any]]:
|
||||
"""Select history tails prioritizing currently displayed processed results."""
|
||||
raw_index, _ = _index_by_collection_sequence(raw_history)
|
||||
pre_index, _ = _index_by_collection_sequence(preprocessed_history)
|
||||
"""Select aligned tails with `results` as preferred anchor stage."""
|
||||
raw_index, raw_pos = _index_by_collection_sequence(raw_history)
|
||||
pre_index, pre_pos = _index_by_collection_sequence(preprocessed_history)
|
||||
result_index, result_pos = _index_by_collection_sequence(result_history)
|
||||
|
||||
if result_index:
|
||||
ordered_result_keys = sorted(result_index, key=lambda key: result_pos[key])
|
||||
selected_keys = ordered_result_keys[-last_n:]
|
||||
selected_raw = [raw_index[key] for key in selected_keys if key in raw_index]
|
||||
selected_pre = [pre_index[key] for key in selected_keys if key in pre_index]
|
||||
selected_results = [result_index[key] for key in selected_keys]
|
||||
raw_missing = len(selected_keys) - len(selected_raw)
|
||||
pre_missing = len(selected_keys) - len(selected_pre)
|
||||
return (
|
||||
[raw_index[key] for key in selected_keys if key in raw_index],
|
||||
[pre_index[key] for key in selected_keys if key in pre_index],
|
||||
[result_index[key] for key in selected_keys],
|
||||
selected_raw,
|
||||
selected_pre,
|
||||
selected_results,
|
||||
{
|
||||
"selection_mode": "result_tail_with_optional_alignment",
|
||||
"anchor_stage": "results",
|
||||
"selected_collection_ids": [int(key[0]) for key in selected_keys],
|
||||
"aligned_key_count": len(selected_keys),
|
||||
"raw_missing_count": raw_missing,
|
||||
"preprocessed_missing_count": pre_missing,
|
||||
},
|
||||
)
|
||||
|
||||
if raw_index:
|
||||
ordered_raw_keys = sorted(raw_index, key=lambda key: raw_pos[key])
|
||||
selected_keys = ordered_raw_keys[-last_n:]
|
||||
selected_raw = [raw_index[key] for key in selected_keys]
|
||||
selected_pre = [pre_index[key] for key in selected_keys if key in pre_index]
|
||||
selected_results = [result_index[key] for key in selected_keys if key in result_index]
|
||||
pre_missing = len(selected_keys) - len(selected_pre)
|
||||
result_missing = len(selected_keys) - len(selected_results)
|
||||
return (
|
||||
selected_raw,
|
||||
selected_pre,
|
||||
selected_results,
|
||||
{
|
||||
"selection_mode": "raw_tail_with_optional_alignment",
|
||||
"anchor_stage": "raw",
|
||||
"selected_collection_ids": [int(key[0]) for key in selected_keys],
|
||||
"aligned_key_count": len(selected_keys),
|
||||
"preprocessed_missing_count": pre_missing,
|
||||
"result_missing_count": result_missing,
|
||||
},
|
||||
)
|
||||
|
||||
if pre_index:
|
||||
ordered_pre_keys = sorted(pre_index, key=lambda key: pre_pos[key])
|
||||
selected_keys = ordered_pre_keys[-last_n:]
|
||||
selected_raw = [raw_index[key] for key in selected_keys if key in raw_index]
|
||||
selected_pre = [pre_index[key] for key in selected_keys]
|
||||
selected_results = [result_index[key] for key in selected_keys if key in result_index]
|
||||
raw_missing = len(selected_keys) - len(selected_raw)
|
||||
result_missing = len(selected_keys) - len(selected_results)
|
||||
return (
|
||||
selected_raw,
|
||||
selected_pre,
|
||||
selected_results,
|
||||
{
|
||||
"selection_mode": "preprocessed_tail_with_optional_alignment",
|
||||
"anchor_stage": "preprocessed",
|
||||
"selected_collection_ids": [int(key[0]) for key in selected_keys],
|
||||
"aligned_key_count": len(selected_keys),
|
||||
"raw_missing_count": raw_missing,
|
||||
"result_missing_count": result_missing,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -45,7 +98,9 @@ def select_aligned_histories(
|
||||
result_history[-last_n:],
|
||||
{
|
||||
"selection_mode": "independent_tail",
|
||||
"anchor_stage": "none",
|
||||
"selected_collection_ids": [],
|
||||
"aligned_key_count": 0,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user