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

Inconsistent handling of errors for non-activated UserTables #1039

Open
iamamutt opened this issue Jun 28, 2022 · 1 comment
Open

Inconsistent handling of errors for non-activated UserTables #1039

iamamutt opened this issue Jun 28, 2022 · 1 comment
Labels

Comments

@iamamutt
Copy link

iamamutt commented Jun 28, 2022

Bug Report

Description

Calling class methods, properties, or instance methods derived from parent classes of UserTable creates inconsistent and confusing error messages when schema is not activated for a set of tables.

import datajoint as dj

dj.config["loglevel"] = "INFO"
schema = dj.Schema()


@schema
class TableA(dj.Manual):
    definition = """
    # TableA example
    table_a : UUID
    ---
    label : VARCHAR(100)
    """


# printing of some properties is ok:
print(TableA.definition)  # ok -> No error.

#   # TableA example
#     table_a : UUID
#     ---
#     label : VARCHAR(100)


# Error description is valid for these cases:
TableA().describe()  # ok -> DataJointError: Class TableA is not properly declared (schema decorator not applied?)

TableA.describe()  # ok -> DataJointError: Class TableA is not properly declared (schema decorator not applied?)

# Uninformative error:
TableA()  # bad -> AttributeError: 'NoneType' object has no attribute 'non_blobs'


# Additional situations of inconsistent errors when printing from an non-activated `Table`.


@schema
class TableB(dj.Manual):
    definition = """
    thing : INT
    ----
    label : VARCHAR(200)
    """


instance = TableB()

# ok -> no error
print(TableB.definition)

#    thing : INT
#    ---
#    label : VARCHAR(200)

# preview.py:51, AttributeError: 'NoneType' object has no attribute 'non_blobs'
instance

# condition.py:154, AttributeError: 'NoneType' object has no attribute 'names'
instance & {}

# expression.py:96, AttributeError: 'NoneType' object has no attribute 'primary_key'
instance.fetch("KEY")

# expression.py:96, AttributeError: 'NoneType' object has no attribute 'primary_key'
instance.head()
TableB.head()

# condition.py:75, AttributeError: 'NoneType' object has no attribute 'secondary_attributes'
TableB & TableA

# issues with `__repr__`` and `_repr_html_`
# preview.py:8, AttributeError: 'NoneType' object has no attribute 'non_blobs'
instance.head
TableB.head


dj.config["loglevel"] = "DEBUG"

# ok -> <bound method QueryExpression.head of <__main__.TableB object at 0x1231b3cd0>>
instance.head

# diff error than before (closer to indication about activation) -> # expression.py:96, AttributeError: 'NoneType' object has no attribute 'primary_key'
instance.head()
@guzman-raphael
Copy link
Collaborator

Thanks for the report @iamamutt! 🤝

This does seem like unintentional behavior although it doesn't seem like it would be too much to patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants