DataJoint Error: A table must have dependencies from its primary key for auto-populate to work

19 Views Asked by At

I am getting the following error when trying to populate a table in DataJoint:

"DataJointError: A table must have dependencies from its primary key for auto-populate to work"

I have been using the same code for a while and all of the sudden I am getting this error when trying to populate a table. I have not changed anything in the code.

I have first manual tables with file information then want to populate Imported tables with data from those files. Even when I run it on data that was previously loaded and is already in the tables I get the same error.

@schema
class Subsession(dj.Imported):
    definition = """
        -> Session
        subsession_id: int
        ---
        config_name = "VEIDB_laura" : varchar(16)
   """

    def make(self, key):

        cfg = configs.get_config((Experiment() & key).fetch1('config_name'))
        base_path = os.path.join(data_path, cfg['session_path'].format(**key))

        subsessions = [sub for sub in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, sub))]
        if subsessions:
            # video_files = [os.path.splitext(f)[0] for f in os.listdir(base_path) if f.endswith('.avi')]
            #   For each video in folder location:
            print(subsessions)
            for subsess in subsessions:
                key['subsession_id'] = int(subsess)
                self.insert1(key)
        else:
            video_files = [os.path.splitext(f)[0] for f in os.listdir(base_path) if f.endswith('.avi')]
            for i, video_file in enumerate(video_files):
                subsess_path = os.path.join(base_path, str(i))
                os.mkdir(subsess_path)
                for file in [f for f in os.listdir(base_path) if video_file in f]:
                    os.replace(os.path.join(base_path, file), os.path.join(subsess_path, file))
                key['subsession_id'] = i
                self.insert1(key)
0

There are 0 best solutions below