Repository navigation
perf(chart): preserve ordered export de-duplication in linear time #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
52
commits into
bolt-performance-chart-export-13223013812255847379
Choose a base branch
from
perf/optimize-chart-dict-5599475227084278792
base: bolt-performance-chart-export-13223013812255847379
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 19 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
1ec43e6
⚡ Bolt: O(N^2) 파이썬 룩업을 O(1) 딕셔너리로 성능 개선
seonghobae f53a772
Trigger CI retry
seonghobae b0c7e84
Trigger CI retry
seonghobae 5d0cbd4
Trigger CI retry
seonghobae 5988186
Trigger CI retry 3
seonghobae ebd77f4
Trigger CI retry 4
seonghobae 7480596
Trigger CI retry 5
seonghobae 5570bb8
test(export): cover duplicate cue-sheet fields
seonghobae 5e49826
Trigger CI retry 6
seonghobae d3a3727
test(chart): cover order-preserving export deduplication
seonghobae e33e184
style(chart): keep dedup regression canonical
seonghobae e51e379
Trigger CI retry 7
seonghobae 289f635
test(chart): reject unhashable export text safely
seonghobae b9452c8
fix(exports): reject unhashable text at dedup boundaries
seonghobae 326b5e7
test(exports): preserve hashable text subclasses
seonghobae 529ebc4
fix(chart): preserve hashable string subclasses
seonghobae bf497a4
test(chart): reject subclass truthiness at export boundary
seonghobae fb76f93
fix(chart): normalize safe string subclass keys
seonghobae afa3614
test(chart): use semantic bool failure exception
seonghobae d534ceb
test(export): reject priority truthiness override
seonghobae 93bda7a
fix(export): normalize rehearsal priority text
seonghobae 10ae79a
Trigger CI retry 9
seonghobae 6770e35
Trigger CI retry 10
seonghobae a6ce02d
Trigger CI retry 10
seonghobae 2084217
test(chart): preserve ordered dedup succession contract
seonghobae c7ed3ee
Trigger CI retry 11
seonghobae ad1f202
Trigger CI retry 12
seonghobae 5677582
test(chart): preserve dedup succession evidence
seonghobae 8ea9c99
Trigger CI retry 13
seonghobae b0d403e
Merge protected develop into chart export dedup owner
seonghobae 3e34efe
chore(perf): adopt protected develop without losing chart dedup delta
seonghobae 4d154e6
docs(changelog): retain protected workflow consolidation during restack
seonghobae b3ece4b
Trigger CI retry 16
seonghobae fbdb701
Trigger CI retry 17
seonghobae 3193f80
Trigger CI retry 18
seonghobae efb0b07
Trigger CI retry 19
seonghobae 2b59955
Trigger CI retry 20
seonghobae 4fb38b5
Trigger CI retry 21
seonghobae 7cda784
repair(chart): restore canonical export optimization scope
seonghobae a3ac980
test(chart): require semantic deduplication identifiers
seonghobae d2238a5
fix(chart): satisfy semantic identifier contract
seonghobae 9f25341
test(chart): require semantic footer collection name
seonghobae f376c63
refactor(chart): name footer collection by export role
seonghobae 1fde9cc
Trigger CI retry 24
seonghobae 8bcc2a2
fix(chart): restore semantic dedup identifiers
seonghobae d2fd1ec
test(chart): restore semantic naming regression
seonghobae bd50b95
docs(chart): restore semantic dedup guidance
seonghobae b94b310
docs(chart): restore semantic changelog claim
seonghobae ac187e9
docs(chart): preserve unrelated changelog text
seonghobae 602e381
refactor(chart): adopt canonical formatter prerequisite
seonghobae 7e5ae7e
Trigger CI retry 33
seonghobae b3c46d1
repair(chart): restore canonical semantic owner tree
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 193 additions & 0 deletions
193
services/analysis-engine/tests/test_chart_export_dedup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| """Regression tests for order-preserving chart export de-duplication.""" | ||
|
|
||
| from typing import Any | ||
|
|
||
| from bandscope_analysis.exports import build_chart_text, build_cue_sheet_rows | ||
|
|
||
|
|
||
| class _UnhashableText(str): | ||
| """String-like malformed payload value that cannot be a mapping key.""" | ||
|
|
||
| __hash__: Any = None | ||
|
|
||
|
|
||
| class _HashableText(str): | ||
| """Compatible string subclass that remains safe as a mapping key.""" | ||
|
|
||
|
|
||
| class _ExplodingTruthText(str): | ||
| """Hashable string-like payload whose custom truth check must never run.""" | ||
|
|
||
| def __bool__(self) -> bool: | ||
|
github-code-quality[bot] marked this conversation as resolved.
Fixed
|
||
| """Raise if production accidentally delegates truthiness to the subclass.""" | ||
| raise TypeError("subclass truthiness must not execute") | ||
|
|
||
|
|
||
| def _role(role_id: str, name: str, cue: str, priority: str = "") -> dict[str, Any]: | ||
| """Build the minimal role evidence consumed by the chart export boundary.""" | ||
| return { | ||
| "id": role_id, | ||
| "name": name, | ||
| "cue": {"kind": "entrance", "value": cue}, | ||
| "rehearsalPriority": priority, | ||
| } | ||
|
|
||
|
|
||
| def _section( | ||
| section_id: str, | ||
| label: str, | ||
| start: int, | ||
| end: int, | ||
| roles: list[dict[str, Any]], | ||
| ) -> dict[str, Any]: | ||
| """Build a valid section whose part graph activates roles in list order.""" | ||
| part_graph = [{"role_id": role["id"], "is_active": True} for role in roles] | ||
| return { | ||
| "id": section_id, | ||
| "label": label, | ||
| "timeRange": {"start": start, "end": end}, | ||
| "roles": roles, | ||
| "partGraph": part_graph, | ||
| } | ||
|
|
||
|
|
||
| def test_duplicate_display_names_and_cues_keep_first_occurrence_order() -> None: | ||
| """Distinct role ids may share display/cue text without duplicating export output.""" | ||
| section = _section( | ||
| "verse", | ||
| "verse", | ||
| 0, | ||
| 16, | ||
| [ | ||
| _role("guitar-left", "Guitar", "Count in"), | ||
| _role("guitar-right", "Guitar", "Count in"), | ||
| _role("bass", "Bass", "Hold root"), | ||
| _role("guitar-double", "Guitar", "Count in"), | ||
| ], | ||
| ) | ||
|
|
||
| rows = build_cue_sheet_rows({"sections": [section]}) | ||
|
|
||
| assert rows == [ | ||
| { | ||
| "section": "verse", | ||
| "start": "00:00", | ||
| "end": "00:16", | ||
| "cue": "Count in; Hold root", | ||
| "roles": ["Guitar", "Bass"], | ||
| } | ||
| ] | ||
|
|
||
|
|
||
| def test_duplicate_priorities_across_sections_keep_first_occurrence_order() -> None: | ||
| """Repeated name/priority entries collapse once without reordering later entries.""" | ||
| song: dict[str, Any] = { | ||
| "title": "Order regression", | ||
| "sections": [ | ||
| _section( | ||
| "verse", | ||
| "verse", | ||
| 0, | ||
| 16, | ||
| [ | ||
| _role("guitar", "Guitar", "Count in", "Lock chorus"), | ||
| _role("bass", "Bass", "Hold root", "Watch cutoff"), | ||
| ], | ||
| ), | ||
| _section( | ||
| "chorus", | ||
| "chorus", | ||
| 16, | ||
| 32, | ||
| [ | ||
| _role("guitar-2", "Guitar", "Count in", "Lock chorus"), | ||
| _role("bass-2", "Bass", "Hold root", "Watch cutoff"), | ||
| ], | ||
| ), | ||
| ], | ||
| } | ||
|
|
||
| text = build_chart_text(song) | ||
| priority_lines = text.split("Priorities:\n", maxsplit=1)[1].splitlines() | ||
|
|
||
| assert priority_lines == [ | ||
| " - Guitar: Lock chorus", | ||
| " - Bass: Watch cutoff", | ||
| ] | ||
|
|
||
|
|
||
| def test_unhashable_string_subclasses_fail_closed_in_public_exports() -> None: | ||
| """Malformed unhashable text is skipped while a valid role id remains usable.""" | ||
| section = _section( | ||
| "verse", | ||
| "verse", | ||
| 0, | ||
| 16, | ||
| [ | ||
| _role(_UnhashableText("bad-id"), "Bad id", "Bad id cue"), | ||
| _role("guitar", _UnhashableText("Guitar"), _UnhashableText("Count in")), | ||
| _role("bass", "Bass", "Hold root"), | ||
| ], | ||
| ) | ||
| song = {"sections": [section]} | ||
|
|
||
| assert build_cue_sheet_rows(song) == [ | ||
| { | ||
| "section": "verse", | ||
| "start": "00:00", | ||
| "end": "00:16", | ||
| "cue": "Hold root", | ||
| "roles": ["guitar", "Bass"], | ||
| } | ||
| ] | ||
| assert "roles: guitar, Bass" in build_chart_text(song) | ||
|
|
||
|
|
||
| def test_hashable_string_subclasses_remain_compatible_export_values() -> None: | ||
| """Hashable string subclasses retain pre-optimization role and cue semantics.""" | ||
| section = _section( | ||
| "verse", | ||
| "verse", | ||
| 0, | ||
| 16, | ||
| [ | ||
| _role(_HashableText("guitar"), _HashableText("Guitar"), _HashableText("Count in")), | ||
| _role("bass", "Bass", "Hold root"), | ||
| ], | ||
| ) | ||
|
|
||
| assert build_cue_sheet_rows({"sections": [section]}) == [ | ||
| { | ||
| "section": "verse", | ||
| "start": "00:00", | ||
| "end": "00:16", | ||
| "cue": "Count in; Hold root", | ||
| "roles": ["Guitar", "Bass"], | ||
| } | ||
| ] | ||
|
|
||
|
|
||
| def test_string_subclass_truthiness_cannot_abort_public_exports() -> None: | ||
| """Hashable text is normalized without invoking subclass-defined truthiness.""" | ||
| section = _section( | ||
| "verse", | ||
| "verse", | ||
| 0, | ||
| 16, | ||
| [ | ||
| _role("guitar", _ExplodingTruthText("Guitar"), _ExplodingTruthText("Count in")), | ||
| _role("bass", "Bass", "Hold root"), | ||
| ], | ||
| ) | ||
| song = {"sections": [section]} | ||
|
|
||
| assert build_cue_sheet_rows(song) == [ | ||
| { | ||
| "section": "verse", | ||
| "start": "00:00", | ||
| "end": "00:16", | ||
| "cue": "Count in; Hold root", | ||
| "roles": ["Guitar", "Bass"], | ||
| } | ||
| ] | ||
| assert "roles: Guitar, Bass" in build_chart_text(song) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.