Commit 402a7416 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

improved docstrings in models.py

parent 8d7d7a8c
......@@ -20,22 +20,36 @@ protocolPurpose_file_association = Table('protocolPurpose_file_association', Bas
Column('protocolPurpose_id', Integer, ForeignKey('protocolPurpose.id')),
Column('file_id', Integer, ForeignKey('file.id')))
class Client(Base):
"""Database clients, marked by an integer identifier and the set they belong
to"""
__tablename__ = 'client'
"""Database clients.
id = Column(Integer, primary_key=True)
Clients are marked by an integer identifier and the set they belong to.
# Possible groups to which clients may belong to
Attributes
----------
id: int
The client (subject) id.
group: str
The group this client belongs to (either 'world', 'dev' or 'eval')
"""
__tablename__ = 'client'
id = Column(Integer, primary_key=True)
group_choices = ('world', 'dev', 'eval')
# Group to which this client belongs to"""
group = Column(Enum(*group_choices))
def __init__(self, id, group):
""" Init function
Parameters
----------
id: int
The client (subject) id.
group: str
The group this client belongs to (either 'world', 'dev' or 'eval')
"""
self.id = id
self.group = group
......@@ -44,7 +58,28 @@ class Client(Base):
class File(Base, bob.db.base.File):
"""Generic file container"""
"""Generic file container
Class that defines an image file of the FARGO database.
Attributes
----------
client_id: int
The id of the client associated to this file
light: str
The light condition of the image
device: str
The device with which this file was acquired
recording: str
The recording from which this file originated
modalitiy: str
The modality from which this file was recorded
pose: str
The pose of the face in the image
path: str
The path on the disk where this file is stored.
"""
__tablename__ = 'file'
......@@ -53,7 +88,6 @@ class File(Base, bob.db.base.File):
# client id of this file
client_id = Column(Integer, ForeignKey('client.id'))
# A direct link to the client object that this file belongs to
client = relationship(Client, backref=backref('files', order_by=id))
# illumination conditions
......@@ -80,6 +114,26 @@ class File(Base, bob.db.base.File):
path = Column(String(100), unique=True)
def __init__(self, client_id, path, light, device, pose, modality, recording):
""" Init function
Parameters
----------
client_id: int
The id of the client associated to this file
path: str
The path on the disk where this file is stored.
light: str
The light condition of the image
device: str
The device with which this file was acquired
pose: str
The pose of the face in the image
modalitiy: str
The modality from which this file was recorded
recording: str
The recording from which this file originated
"""
bob.db.base.File.__init__(self, path=path)
self.client_id = client_id
self.light = light
......@@ -88,34 +142,44 @@ class File(Base, bob.db.base.File):
self.modality = modality
self.pose = pose
def __repr__(self):
return "File('%s')" % self.path
def make_path(self, directory=None, extension=None):
"""Wraps the current path so that a complete path is formed
Keyword parameters:
Parameters
----------
directory
An optional directory name that will be prefixed to the returned result.
extension
An optional extension that will be suffixed to the returned filename. The
extension normally includes the leading ``.`` character as in ``.jpg`` or
``.hdf5``.
Returns a string containing the newly generated file path.
An optional extension that will be suffixed to the returned filename.
extension normally includes the leading ``.`` character
Returns
-------
str:
the newly generated file path.
"""
if not directory:
directory = ''
if not extension:
extension = ''
return str(os.path.join(directory, self.path + extension))
class Protocol(Base):
"""FARGO protocols
The class representing the protocols
Attributes
----------
name:
The name of the protocol
"""
__tablename__ = 'protocol'
......@@ -124,6 +188,14 @@ class Protocol(Base):
name = Column(String(20), unique=True)
def __init__(self, name):
""" Init function
Parameters
----------
name:
The name of the protocol
"""
self.name = name
def __repr__(self):
......@@ -131,7 +203,23 @@ class Protocol(Base):
class ProtocolPurpose(Base):
"""FARGO protocol purposes"""
"""FARGO protocol purposes
This class represent the protocol purposes, and
more importantly, contains the set of files
associated with each group and each purpose
for each protocol.
Attributes
----------
protocol_id: str
The associated protocol
group: str
The group in the associated protocol ('world', 'dev' or 'eval')
purpose: str
The purpose of the group in this protocol ('train', 'enroll' or 'probe')
"""
__tablename__ = 'protocolPurpose'
......@@ -150,6 +238,18 @@ class ProtocolPurpose(Base):
files = relationship("File", secondary=protocolPurpose_file_association, backref=backref("protocolPurposes", order_by=id))
def __init__(self, protocol_id, group, purpose):
""" Init function
Parameters
----------
protocol_id: str
The associated protocol
group: str
The group in the associated protocol ('world', 'dev' or 'eval')
purpose: str
The purpose of the group in this protocol ('train', 'enroll' or 'probe')
"""
self.protocol_id = protocol_id
self.group = group
self.purpose = purpose
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment