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
SOLR-61: Bring Recording to search parity #40
Conversation
Here as well, having links to see what is going on helps. |
This PR is really hard to follow since so many things changed and the ticket also lists a pile of things that are wrong. And the outputs from the two calls in the ticket are also really hard to compare. |
|
||
|
||
def convert_format(obj): | ||
return models.format(id=str(obj.id)) | ||
return models.format(valueOf_=obj.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fixing medium format(format)
See https://musicbrainz.org/ws/2/recording?query=format:CD&limit=1 vs
http://35.193.119.46:8983/solr/recording/select?q=format:CD&rows=1
Expected-
<format>CD</format>
Result-
<format id="1"/>
|
||
|
||
def convert_release_status(obj): | ||
""" | ||
:type obj: :class:`mbdata.models.ReleaseStatus` | ||
""" | ||
return models.status(id=str(obj.id)) | ||
return models.status(valueOf_=obj.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fixing release status output(format)
See https://musicbrainz.org/ws/2/recording?query=status:official&limit=1 vs
http://35.193.119.46:8983/solr/recording/select?q=format:CD&rows=1
Expected-
<status>Official</status>
Result-
<status id="1"/>
|
||
|
||
def convert_gender(obj): | ||
return models.gender(valueOf_=str(obj.name.lower())) | ||
return models.gender(valueOf_=obj.name.lower()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply removes the unnecessary str type conversion
@@ -992,19 +1020,19 @@ def convert_release_group_primary_type(obj): | |||
""" | |||
:type obj: :class:`mbdata.models.ReleaseGroupPrimaryType` | |||
""" | |||
return models.primary_type(id=str(obj.id)) | |||
return models.primary_type(valueOf_=obj.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes primary type output of a release (pt)
see https://musicbrainz.org/ws/2/recording?query=primarytype:album&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=primarytype:album&rows=1
<primary-type>Album</primary-type>
vs
<primary-type id="1"/>
sir/wscompat/convert.py
Outdated
|
||
for release in recording.release_list.release: | ||
if release.artist_credit == recording.artist_credit: | ||
release.set_artist_credit(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes label (ac)
See
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1
release output. Lot of extra unnecessary information.
@@ -483,7 +509,7 @@ def convert_release_group_for_release(obj): | |||
|
|||
if obj.type is not None: | |||
rg.set_primary_type(convert_release_group_primary_type(obj.type)) | |||
rg.set_type(obj.type.name) | |||
rg.set_type(calculate_type(obj.type, obj.secondary_types)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes labels st and type
see the output for type of the release in
https://musicbrainz.org/ws/2/recording?query=reid:e5da47bc-9a97-4682-8294-ef7458cd3984&limit=1
and
http://35.193.119.46:8983/solr/recording/select?q=reid:e5da47bc-9a97-4682-8294-ef7458cd3984&rows=1
for release id e5da47bc-9a97-4682-8294-ef7458cd3984
@@ -445,7 +471,7 @@ def convert_release_from_track(obj): | |||
# same as the recording artist credit, but we've already built it so just | |||
# set it | |||
release.set_artist_credit(convert_artist_credit(rel.artist_credit, | |||
include_aliases=True)) | |||
include_aliases=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aliases are not needed in the output for related release artist credit
See
https://musicbrainz.org/ws/2/recording?query=reid:0722a81b-dc18-4c19-9d36-fc28cd450a63&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=reid:0722a81b-dc18-4c19-9d36-fc28cd450a63&rows=1
You are looking at the output of artist credit for the release 0722a81b-dc18-4c19-9d36-fc28cd450a63
sir/wscompat/convert.py
Outdated
@@ -50,6 +58,28 @@ def datetime_to_string(obj): | |||
return obj.strftime(TIME_FORMAT) | |||
|
|||
|
|||
def calculate_type(primary_type, secondary_types): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to fixing label type in the ticket
@@ -128,8 +158,7 @@ def convert_name_credit(obj, include_aliases=True): | |||
""" | |||
:type obj: :class:`mbdata.models.ArtistCreditName` | |||
""" | |||
nc = models.name_credit(name=obj.name, | |||
artist=convert_artist_simple(obj.artist, | |||
nc = models.name_credit(artist=convert_artist_simple(obj.artist, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to fixing label name in the ticket
No need for name output in artist credit
see the output of artist-credit in
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1
@@ -325,9 +354,6 @@ def convert_medium(obj): | |||
if obj.format is not None: | |||
m.set_format(convert_format(obj.format)) | |||
|
|||
dl = models.disc_list(count=len(obj.cdtocs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No disc list is shown in the current ws output
see
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1
Specifically
<disc-list count="1"/>
is not there in current output so removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by convert_release
as well, where http://musicbrainz.org/ws/2/release?query=heino has a disc-list attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have fixed it properly in the PR for release.
@@ -359,7 +385,7 @@ def convert_medium_list(obj): | |||
""" | |||
:type obj: :class:`[mbdata.models.Medium]` | |||
""" | |||
ml = models.medium_list(count=len(obj)) | |||
ml = models.medium_list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to label count on the ticket.
Current medium output does not have a count attribute
see
https://musicbrainz.org/ws/2/recording?query=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&limit=1
vs
http://35.193.119.46:8983/solr/recording/select?q=rid:4b3003ee-dbd6-48de-8dfe-073e1c7c9cf1&rows=1
this translates to a bad json output (similar to the tag PR we merged #38 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explaining these -- looks pretty sane!
Fixed the commits into something more manageable for future git history/ git bisect. |
sir/wscompat/convert.py
Outdated
@@ -50,6 +58,28 @@ def datetime_to_string(obj): | |||
return obj.strftime(TIME_FORMAT) | |||
|
|||
|
|||
def calculate_type(primary_type, secondary_types): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add lru_cache
tu this function because (compared to the amount of recordings) the number of primary / secondary type combinations is very small (and constant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -325,9 +354,6 @@ def convert_medium(obj): | |||
if obj.format is not None: | |||
m.set_format(convert_format(obj.format)) | |||
|
|||
dl = models.disc_list(count=len(obj.cdtocs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by convert_release
as well, where http://musicbrainz.org/ws/2/release?query=heino has a disc-list attribute.
Release type has to be handled specially when the primary type is 'Album' and the secondary type list has values as defined in `SECONDARY_TYPE_ORDER`
See https://tickets.metabrainz.org/browse/SOLR-61 for the list of errors