remove firm that denied request from candidate list

This commit is contained in:
2023-05-15 13:37:05 +08:00
parent aac2607284
commit 7e8980d0c6
15 changed files with 82 additions and 53 deletions

23
orm.py
View File

@@ -23,9 +23,11 @@ with open('conf_db_prefix.yaml') as file:
str_login = 'mysql://{}:{}@{}:{}/{}'.format(dct_conf_db['user_name'], dct_conf_db['password'],
dct_conf_db['address'], dct_conf_db['port'], dct_conf_db['db_name'])
print('DB is {}:{}/{}'.format(dct_conf_db['address'], dct_conf_db['port'], dct_conf_db['db_name']))
print('DB is {}:{}/{}'.format(dct_conf_db['address'],
dct_conf_db['port'], dct_conf_db['db_name']))
engine = create_engine(str_login, poolclass=NullPool) # must be null pool to avoid connection lost error
# must be null pool to avoid connection lost error
engine = create_engine(str_login, poolclass=NullPool)
ins = inspect(engine)
Base = declarative_base()
@@ -48,7 +50,8 @@ class Experiment(Base):
dct_lst_init_remove_firm_prod = Column(PickleType, nullable=False)
g_bom = Column(Text(4294000000), nullable=False)
sample = relationship('Sample', back_populates='experiment', lazy='dynamic')
sample = relationship(
'Sample', back_populates='experiment', lazy='dynamic')
def __repr__(self):
return f'<Experiment: {self.id}>'
@@ -57,18 +60,21 @@ class Experiment(Base):
class Sample(Base):
__tablename__ = f"{db_name_prefix}_sample"
id = Column(Integer, primary_key=True, autoincrement=True)
e_id = Column(Integer, ForeignKey('{}.id'.format(f"{db_name_prefix}_experiment")), nullable=False)
e_id = Column(Integer, ForeignKey('{}.id'.format(
f"{db_name_prefix}_experiment")), nullable=False)
idx_sample = Column(Integer, nullable=False)
seed = Column(BigInteger, nullable=False)
is_done_flag = Column(Integer, nullable=False) # -1, waiting; 0, running; 1, done
# -1, waiting; 0, running; 1, done
is_done_flag = Column(Integer, nullable=False)
computer_name = Column(String(64), nullable=True)
ts_done = Column(DateTime(timezone=True), onupdate=func.now())
stop_t = Column(Integer, nullable=True)
g_firm = Column(Text(4294000000), nullable=True)
experiment = relationship('Experiment', back_populates='sample', uselist=False)
experiment = relationship(
'Experiment', back_populates='sample', uselist=False)
result = relationship('Result', back_populates='sample', lazy='dynamic')
def __repr__(self):
@@ -78,7 +84,8 @@ class Sample(Base):
class Result(Base):
__tablename__ = f"{db_name_prefix}_result"
id = Column(Integer, primary_key=True, autoincrement=True)
s_id = Column(Integer, ForeignKey('{}.id'.format(f"{db_name_prefix}_sample")), nullable=False)
s_id = Column(Integer, ForeignKey('{}.id'.format(
f"{db_name_prefix}_sample")), nullable=False)
id_firm = Column(String(10), nullable=False)
id_product = Column(String(10), nullable=False)