<commit_before>from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker,backref
from passlib.hash import sha512_crypt
import haas_dao

Base=declarative_base()
Session = sessionmaker()

user_groups = Table('user_groups', Base.metadata,
                    Column('user_id', Integer, ForeignKey('users.id')),
                    Column('group_id', Integer, ForeignKey('groups.id')))


def init_db(create=False):
    uri = cfg.get('database', 'uri')
    engine = create_engine(uri)
    if create:
        Base.metadata.create_all(engine)
    Session.configure(bind=engine)




class Nic(Base):
    __tablename__ = 'nics'
    meta      = ["id", "label", "mac_addr", "node_label", "port_label"]
    id        = Column(Integer, primary_key = True)
    label     = Column(String)
    mac_addr  = Column(String)

    port_label   = Column(Integer,ForeignKey('ports.label'))
    node_label   = Column(Integer,ForeignKey('nodes.label'))
    
    # One to one mapping port
    port      = relationship("Port",backref=backref('nic',uselist=False))
    node      = relationship("Node",backref=backref('nics',order_by=label)) 
    <commit_msg>haas.model: Added a comment about the meta attribute.<commit_after>from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker,backref
from passlib.hash import sha512_crypt
import haas_dao

Base=declarative_base()
Session = sessionmaker()

user_groups = Table('user_groups', Base.metadata,
                    Column('user_id', Integer, ForeignKey('users.id')),
                    Column('group_id', Integer, ForeignKey('groups.id')))


def init_db(create=False):
    uri = cfg.get('database', 'uri')
    engine = create_engine(uri)
    if create:
        Base.metadata.create_all(engine)
    Session.configure(bind=engine)




class Nic(Base):
    __tablename__ = 'nics'
    # The "meta" attribute is for the benefit of the cli, which uses it to
    # display column names. There's probably a better way to do this, but the
    # intent going forward is for the cli to be talking to the rest api, rather
    # than this module, so let's not bother for now, and just remember to remove
    # this (as well as the same attribute in other classes) when we can.
    meta      = ["id", "label", "mac_addr", "node_label", "port_label"]
    id        = Column(Integer, primary_key = True)
    label     = Column(String)
    mac_addr  = Column(String)

    port_label   = Column(Integer,ForeignKey('ports.label'))
    node_label   = Column(Integer,ForeignKey('nodes.label'))
    
    # One to one mapping port
    port      = relationship("Port",backref=backref('nic',uselist=False))
    node      = relationship("Node",backref=backref('nics',order_by=label)) 
    
{'fraction_non_alphanumeric': 0.11369236184442098, 'fraction_numerical': 0.0021119324181626186, 'mean_word_length': 3.6136363636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5123212', 'n_tokens_mistral': 874, 'n_tokens_neox': 842, 'n_words': 220}