datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

`context` required for parent tables having `AttributeAdapter` type

Open ttngu207 opened this issue 4 years ago • 1 comments

For parent tables with attributes of adapted type, the context is required to find the adapter object. But when declare tables with dj.FreeTable, context was not provided. This bug prevents getting key_source (thus calling .populate()) on any tables with parents containing adapted type.

Minimal example:

import datajoint as dj
from pipeline import subject
from pipeline.nwb_adapter import nwb_file

schema = dj.schema('test')

@schema
class Session(dj.Manual):
    definition = """
    -> subject.Subject
    session_time: datetime    # session time
    ---
    session_note = "" : varchar(256) 
    nwb_file: <nwb_file>  # pynwb.file.NWBFile, filepath
    """

@schema
class SessionNWBFile(dj.Imported):
    definition = """
     -> Session
    ---
    note: varchar(128)
    """

calling SessionNWBFile.key_source will result in 'context' not set error

ttngu207 avatar Jun 04 '20 17:06 ttngu207

Related https://github.com/datajoint/datajoint-python/issues/687

guzman-raphael avatar Jun 09 '20 16:06 guzman-raphael