DataJointError: Class ________ is not properly declared (schema decorator not applied?) when trying to diagram

56 Views Asked by At

DataJoint version 0.13.4

Python 3.9, running in PyCharm 2022.1.1 Pro Edition

MacOS 12.3.1

I've been working with several of the datajoint-elements packages just trying to get an overall schema created so I can see what new schema's, if any, need to be created for hosting our lab's data. The blank for the class in the title is because I have seen this with several different classes while trying to get this setup, such as Class Session or Class SessionNote. In the code below, Class SessionNote is what the actual error was for, but I figured a more general question may help others in the future!

What I especially find interesting is that this error occurs when just calling the draw function for lab which by itself does not have any reference to SessionNote. I also tried not activating the other schema by commenting them out, and then would instead get the same error, but for Class Subject not being properly declared. I have double checked and all the classes that are claiming to not be properly declared are active within the namespace of the environment. I have also gotten this error when trying to insert data into a table, though that seems fixed after I updated one of the elements packages straight from github instead of PyPi. Let me know if there is any additional information I can provide to help! It's my first submission to Stack Overflow

import datetime

import datajoint as dj
import wehrdj
from element_session import session
from element_animal import subject, genotyping
from element_lab import lab


from element_animal.subject import Subject
from element_animal.genotyping import Sequence, BreedingPair, Cage,\
                                      SubjectCaging, GenotypeTest
from element_lab.lab import Source, Lab, Protocol, User, Project, ProjectUser, \
                            ProjectKeywords, ProjectPublication, ProjectSourceCode
from element_session.session_with_datetime import Session, SessionDirectory, \
                            SessionExperimenter, SessionNote, \
                            ProjectSession
from element_animal.export.nwb import subject_to_nwb
from element_lab.export.nwb import element_lab_to_nwb_dict

wehrdj.connect()  # Wrapper for dj.connect(), can be replaced with the normal DJ function if needed

db_prefix = dj.config['custom'].get('database.prefix', '')

__all__ = ['genotyping', 'session', 'Subject', 'Source', 'Lab', 'Protocol', 'User',
           'Project', 'ProjectKeywords', 'ProjectPublication', 'ProjectSourceCode',
           'ProjectUser', 'Session', 'SessionDirectory', 'SessionExperimenter',
           'SessionNote', 'ProjectSession', 'Sequence', 'BreedingPair', 'Cage',
           'SubjectCaging', 'GenotypeTest']

Experimenter = lab.User

# Testing activations
lab.activate(db_prefix + "lab")
subject.activate(db_prefix + "subject", linking_module=__name__)
session.activate(db_prefix + "session", linking_module=__name__)
genotyping.activate(db_prefix + "genotyping", db_prefix + "subject", linking_module=__name__)

# Testing drawing schema
dj.Diagram(lab).draw()

0

There are 0 best solutions below