Interface Classes#

Tools for ingesting data into a datajoint database.

Model a datajoint schema, tagging properties of the model as needed

class wehrdj.interface.interface.SchemaInterface[source]#

Metaclass for making interfaces from existing data structures to datajoint schema.

To use:

  • Assign the relevant schema as a schema class attribute

  • Write code to either assign values from your particular data structure as attributes or properties with the same names as the fields in the database

  • Connect and hopefully it will be able to insert your row!

For an example, see Session

property field_names: List[str]#

List of fields that must be defined for this schema

Returns

list[str] = list of field names

property field_values: Dict[str, Any]#

Values that have been given, either as attrs or properties, for all the items in the schema

Returns

dict[str, Any]

insert(**kwargs)[source]#

Insert this schema entry into the table. You must have already called wehrcj.connect() or else datajoint will prompt you.

Parameters

**kwargs – passed on to insert()

Raises

wehrdj.exceptions.ValidationError

property name: str#

Name of this schema (gotten from the schema’s __name__ attr)

Returns

str

abstract property schema: UserTable#

The schema that this class models.

(Should be overridden as a class attribute rather than a property, this is just how the abc interface works)

property table: datajoint_babel.model.table.Table#

The abstract representation of the datajoint model in the definition

eg. for session:

Table(
  name='Session',
  tier='Manual',
  comment=None,
  keys=[
    Dependency(dependency='Subject'),
    Attribute(
      name='session_datetime',
      datatype=DJ_Type(datatype='datetime', args=3, unsigned=False),
      comment='',
      default=None
    )
  ],
  attributes=[]
)
Returns

Table

validate() bool[source]#

Validate that all the required fields of this schema have been provided

Returns

True if they have all been declared

Return type

bool