Remove the retired artist overrides layer and the mixed artist type
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,8 +8,8 @@ Rebuilds the working store from scratch out of the committed
|
||||
inputs: the year-end chart CSV and the output directory for the
|
||||
review CSV files, given as the two positional command-line
|
||||
arguments, and the optional capture inputs, each given as an
|
||||
option: the lyrics cache directory, the Wikidata artist snapshot
|
||||
CSV, and the manual artist overrides CSV. An omitted option
|
||||
option: the lyrics cache directory and the Wikidata artist
|
||||
snapshot CSV. An omitted option
|
||||
leaves its capture layer unloaded; a given option whose path does
|
||||
not exist fails the build. Missing tables
|
||||
are created on a fresh store; existing tables are never altered,
|
||||
@@ -188,9 +188,6 @@ def parse_args(argv: list[str] | None) -> argparse.Namespace:
|
||||
parser.add_argument(
|
||||
"--wikidata-csv", type=Path, default=None,
|
||||
help="the Wikidata artist snapshot CSV file to apply")
|
||||
parser.add_argument(
|
||||
"--overrides-csv", type=Path, default=None,
|
||||
help="the manual artist override CSV file to apply")
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
@@ -215,8 +212,7 @@ def parse_artist_credit(credit: str) -> list[tuple[str, Role]]:
|
||||
word or punctuation.
|
||||
|
||||
Known limitation: a compound act name that contains one of the
|
||||
delimiters, other than the protected names, is over-split;
|
||||
such cases are corrected later via the human override layer.
|
||||
delimiters, other than the protected names, is over-split.
|
||||
|
||||
:param credit: The combined artist credit string.
|
||||
:return: The (name, role) pairs in credit order, primary side
|
||||
@@ -407,8 +403,7 @@ def apply_artist_csv(session: Session, path: Path) -> None:
|
||||
"""Apply an artist attribute CSV onto the artist rows.
|
||||
|
||||
Artists match by exact name. Only the non-empty cells are
|
||||
applied, so a later CSV overrides an earlier one field by
|
||||
field. The note column is ignored.
|
||||
applied, field by field. The note column is ignored.
|
||||
|
||||
:param session: The database session, with the artists
|
||||
flushed.
|
||||
@@ -727,8 +722,6 @@ def main(argv: list[str] | None = None) -> int:
|
||||
load_lyrics(session, args.lyrics_dir)
|
||||
if args.wikidata_csv is not None:
|
||||
apply_artist_csv(session, args.wikidata_csv)
|
||||
if args.overrides_csv is not None:
|
||||
apply_artist_csv(session, args.overrides_csv)
|
||||
session.flush()
|
||||
violations: list[str] = find_violations(
|
||||
session, YEARS, RANKS_PER_YEAR)
|
||||
|
||||
@@ -106,9 +106,6 @@ class ArtistType(enum.StrEnum):
|
||||
"""A solo artist: a human."""
|
||||
GROUP = "group"
|
||||
"""A musical ensemble."""
|
||||
MIXED = "mixed"
|
||||
"""A mixed act, assigned manually via the overrides; never
|
||||
derived by the fetcher."""
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -78,7 +78,7 @@ class Artist(Base):
|
||||
gender: Mapped[str | None]
|
||||
"""The gender of the artist."""
|
||||
type: Mapped[str | None]
|
||||
"""The artist type: solo, group, or mixed."""
|
||||
"""The artist type: solo or group."""
|
||||
genre: Mapped[str | None]
|
||||
"""The music genre of the artist."""
|
||||
country: Mapped[str | None]
|
||||
|
||||
@@ -258,8 +258,6 @@ class TestBuildDB(unittest.TestCase):
|
||||
self.__lyrics: Path = self.__dir / "lyrics"
|
||||
self.__wikidata: Path = \
|
||||
self.__dir / "artists_wikidata.csv"
|
||||
self.__overrides: Path = \
|
||||
self.__dir / "artists_overrides.csv"
|
||||
self.__write_chart(self.CHART_CSV)
|
||||
url: str = f"sqlite:///{self.__dir}/store.sqlite3"
|
||||
config.set_settings(config.Settings(
|
||||
@@ -573,42 +571,6 @@ class TestBuildDB(unittest.TestCase):
|
||||
list(session.scalars(sa.select(ChartEntry))), [])
|
||||
self.assertEqual(list(session.scalars(sa.select(Song))), [])
|
||||
|
||||
def test_overrides_apply_over_wikidata(self) -> None:
|
||||
"""Test that the overrides win over the Wikidata snapshot."""
|
||||
self.__wikidata.write_text(
|
||||
"name,qid,gender,type,genre,country,note\n"
|
||||
"Adele,Q2831,female,solo,pop,GB,\n",
|
||||
encoding="utf-8")
|
||||
self.__overrides.write_text(
|
||||
"name,qid,gender,type,genre,country,note\n"
|
||||
"Adele,,,,soul,,manually checked\n",
|
||||
encoding="utf-8")
|
||||
self.assertEqual(self.__run_build(
|
||||
"--wikidata-csv", str(self.__wikidata),
|
||||
"--overrides-csv", str(self.__overrides))[0], 0)
|
||||
session: Session = self.__session()
|
||||
artist: Artist | None = session.scalar(
|
||||
sa.select(Artist).where(Artist.name == "Adele"))
|
||||
assert artist is not None
|
||||
self.assertEqual(artist.genre, "soul")
|
||||
self.assertEqual(artist.gender, "female")
|
||||
self.assertEqual(artist.wikidata_qid, "Q2831")
|
||||
self.assertEqual(artist.country, "GB")
|
||||
|
||||
def test_unknown_override_name_fails(self) -> None:
|
||||
"""Test that an unknown override name fails the build."""
|
||||
self.__overrides.write_text(
|
||||
"name,qid,gender,type,genre,country,note\n"
|
||||
"Adel,,female,,,,typo\n", encoding="utf-8")
|
||||
status: int
|
||||
stderr: str
|
||||
status, stderr = self.__run_build(
|
||||
"--overrides-csv", str(self.__overrides))
|
||||
self.assertNotEqual(status, 0)
|
||||
self.assertIn("Adel", stderr)
|
||||
session: Session = self.__session()
|
||||
self.assertEqual(list(session.scalars(sa.select(Song))), [])
|
||||
|
||||
def test_lyrics_loaded(self) -> None:
|
||||
"""Test loading the lyrics cache into the songs."""
|
||||
self.__lyrics.mkdir()
|
||||
@@ -676,18 +638,6 @@ class TestBuildDB(unittest.TestCase):
|
||||
session: Session = self.__session()
|
||||
self.assertEqual(list(session.scalars(sa.select(Song))), [])
|
||||
|
||||
def test_missing_overrides_csv_fails(self) -> None:
|
||||
"""Test that a given but missing override CSV fails."""
|
||||
status: int
|
||||
stderr: str
|
||||
status, stderr = self.__run_build(
|
||||
"--overrides-csv", str(self.__overrides))
|
||||
self.assertNotEqual(status, 0)
|
||||
self.assertIn("error:", stderr)
|
||||
self.assertIn(str(self.__overrides), stderr)
|
||||
session: Session = self.__session()
|
||||
self.assertEqual(list(session.scalars(sa.select(Song))), [])
|
||||
|
||||
REVIEW_CHART_CSV: str = (
|
||||
"year,rank,title,artist\n"
|
||||
"2016,1,banana,Artist B\n"
|
||||
|
||||
Reference in New Issue
Block a user