Skip to content
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

Importer bug fixes #327

Merged
merged 5 commits into from Dec 10, 2023
Merged

Importer bug fixes #327

merged 5 commits into from Dec 10, 2023

Conversation

tony
Copy link
Member

@tony tony commented Dec 10, 2023

Cherry-picked out of #324

Fix imports for kXHC1983, kHanyuPinyin, kHanyuPinlu, kCCCII

src/unihan_db/importer.py:75: in import_char
    assert isinstance(kci, dict)
E   AssertionError
        c          = <unihan_db.tables.Unhn object at 0x7faab7c60dd0>
        char       = {'char': '一', 'kCCCII': ['213021'], 'kCangjie': 'M', 'kCantonese': ['jat1'], ...}
        kc         = 'jat1'
        kci        = '213021'
        kd         = 'alone'
unihan-db/src/unihan_db/importer.py:254: in import_char
    assert isinstance(_khp['location'], dict)
E   KeyError: 'location'
        _kaj       = {'cid': 1200, 'radical': 1, 'strokes': 1, 'strokes-residue': 0, ...}
        _kct       = {'character': 1, 'page': 1, 'row': 1}
        _kdj       = {'character': 1, 'page': 129, 'virtual': 0}
        _kf        = {'frequency': 'A', 'phonetic': '1'}
        _khp       = {'frequency': 32747, 'phonetic': 'yī'}
        _khy       = {'character': 1, 'page': 1, 'virtual': 0, 'volume': 1}
        _kidj      = {'character': 1, 'page': 129, 'virtual': 0}
        _kidj_locations = [<unihan_db.tables.UnhnLocation object at 0x7fb8aafb5880>]
        _kiic      = {'priority': 'A', 'sources': ['G', 'T', 'J', 'H', 'K', 'M', ...]}
        _kiic_source = 'P'
        _kikx      = {'character': 1, 'page': 75, 'virtual': 0}
        _kikx_locations = [<unihan_db.tables.UnhnLocation object at 0x7fb8aafb5820>]
        c          = <unihan_db.tables.Unhn object at 0x7fb8aafb4dd0>
        char       = {'char': '一', 'kCCCII': ['213021'], 'kCangjie': 'M', 'kCantonese': ['jat1'], ...}
        k_sources  = [<unihan_db.tables.kIICoreSource object at 0x7fb8aafb5640>, <unihan_db.tables.kIICoreSource object at 0x7fb8aafb56d0>,...ihan_db.tables.kIICoreSource object at 0x7fb8aafb5760>, <unihan_db.tables.kIICoreSource object at 0x7fb8aafb5790>, ...]
        kc         = 'jat1'
        kci        = '213021'
        kd         = 'alone'
        khp_locations = [<unihan_db.tables.UnhnLocation object at 0x7fb8aafb5310>]
        khp_readings = [<unihan_db.tables.UnhnReading object at 0x7fb8aafb5340>]
        khy_locations = [<unihan_db.tables.UnhnLocation object at 0x7fb8aafb5400>]
        km         = {'zh-Hans': 'yī', 'zh-Hant': 'yī'}
        kts        = {'zh-Hans': 1, 'zh-Hant': 1}
        kxhc       = {'locations': [{'character': 16, 'entry': 0, 'page': 1368, 'substituted': False}], 'reading': 'yì'}
        kxhc_locations = [<unihan_db.tables.UnhnLocationkXHC1983 object at 0x7fb8aafb5550>]
        loc        = {'character': 16, 'entry': 0, 'page': 1368, 'substituted': False}
        reading    = 'yī'
python3.12/site-packages/sqlalchemy/orm/relationships.py:1536: in cascade_iterator
    raise AssertionError(
E   AssertionError: Attribute 'locations' on class '<class 'unihan_db.tables.GenericReading'>' doesn't handle objects of type '<class 'unihan_db.tables.UnhnReading'>'
        c          = <unihan_db.tables.UnhnReading object at 0x7f55ed9a1af0>
        dict_      = {'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7f55ecd617f0>, 'locations': [<unihan_db.tables....ect at 0x7f55ed9a1af0>], 'readings': [<unihan_db.tables.UnhnReading object at 0x7f55ed9a1af0>], 'type': 'kHanyuPinyin'}
        halt_on    = <bound method Session._contains_state of <sqlalchemy.orm.session.Session object at 0x7f55f124d190>>
        instance_dict = {'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7f55ecd61af0>, 'reading': 'tiàn'}
        instance_mapper = <Mapper at 0x7f55f1b9dee0; UnhnReading>
        instance_state = <sqlalchemy.orm.state.InstanceState object at 0x7f55ecd61af0>
        passive    = symbol('PASSIVE_NO_INITIALIZE')
        self       = <Relationship at 0x7f55f1cedc70; locations>
        skip_pending = False
        state      = <sqlalchemy.orm.state.InstanceState object at 0x7f55ecd617f0>
        tuples     = [(<sqlalchemy.orm.state.InstanceState object at 0x7f55ecd61af0>, <unihan_db.tables.UnhnReading object at 0x7f55ed9a1af0>)]
        type_      = 'save-update'
        visited_states = {<sqlalchemy.orm.state.InstanceState object at 0x7f55ecd61c10>, <sqlalchemy.orm.state.InstanceState object at 0x7f55ec....orm.state.InstanceState object at 0x7f55ecd61970>, <sqlalchemy.orm.state.InstanceState object at 0x7f55ecd61d90>, ...}
lib/python3.12/site-packages/sqlalchemy/orm/relationships.py:1536: in cascade_iterator
    raise AssertionError(
E   AssertionError: Attribute 'readings' on class '<class 'unihan_db.tables.GenericReading'>' doesn't handle objects of type '<class 'unihan_db.tables.UnhnLocationkXHC1983'>'
        c          = <unihan_db.tables.UnhnLocationkXHC1983 object at 0x7f70eef2c5c0>
        dict_      = {'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7f70e18e62d0>, 'readings': [<unihan_db.tables.UnhnLocationkXHC1983 object at 0x7f70eef2c5c0>], 'type': 'kXHC1983'}
        halt_on    = <bound method Session._contains_state of <sqlalchemy.orm.session.Session object at 0x7f70f26a5a30>>
        instance_dict = {'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7f70e18e6210>, 'character': 16, 'entry': 0, 'page': 1506, ...}
        instance_mapper = <Mapper at 0x7f70f2ff1550; UnhnLocationkXHC1983>
        instance_state = <sqlalchemy.orm.state.InstanceState object at 0x7f70e18e6210>
        passive    = symbol('PASSIVE_NO_INITIALIZE')
        self       = <Relationship at 0x7f70f3145d10; readings>
        skip_pending = False
        state      = <sqlalchemy.orm.state.InstanceState object at 0x7f70e18e62d0>
        tuples     = [(<sqlalchemy.orm.state.InstanceState object at 0x7f70e18e6210>, <unihan_db.tables.UnhnLocationkXHC1983 object at 0x7f70eef2c5c0>)]
        type_      = 'save-update'
        visited_states = {<sqlalchemy.orm.state.InstanceState object at 0x7f70e18e6030>, <sqlalchemy.orm.state.InstanceState object at 0x7f70e1....orm.state.InstanceState object at 0x7f70e18e6390>, <sqlalchemy.orm.state.InstanceState object at 0x7f70e18e5d30>, ...}
Copy link

codecov bot commented Dec 10, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (b7d1c84) 69.77% compared to head (aa7c268) 69.87%.

Files Patch % Lines
src/unihan_db/importer.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
+ Coverage   69.77%   69.87%   +0.10%     
==========================================
  Files           9        9              
  Lines         655      654       -1     
  Branches       88       88              
==========================================
  Hits          457      457              
+ Misses        192      191       -1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tony tony merged commit 8d4bc74 into master Dec 10, 2023
10 checks passed
@tony tony deleted the importer-bug-fixes branch December 10, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant