Exemplo n.º 1
0
 def qdel(self,jid):
     """delete job jid from the queue"""
     #try:
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     del db.jobs[jid]
     db.commit()
     db.close()
Exemplo n.º 2
0
 def _set_state(self,jid,state):
     """update state of job"""
     self.mutex.acquire()
     db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir)
     db.jobs[jid] = dict(state=state)
     db.commit()
     db.close()
     self.mutex.release()
Exemplo n.º 3
0
 def qsub(self,app,cid,user,np,pry,desc=""):
     """queue job ... really just set state to 'Q'."""
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     jid = db.jobs.insert(user=user, app=app, cid=cid, state=STATE_QUEUED, 
                           description=desc, time_submit=time.asctime(), np=np, priority=pry)
     db.commit()
     db.close()
     return str(jid)
Exemplo n.º 4
0
 def __init__(self):
     # if any jobs marked in run state when scheduler starts 
     # replace their state with X to mark that they have been shutdown
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     myset = db(db.jobs.state == 'R')
     myset.update(state='X')
     db.commit()
     self.sem = BoundedSemaphore(config.np) 
     self.mutex = Lock()
Exemplo n.º 5
0
 def __init__(self):
     # if any jobs marked in run state when scheduler starts
     # replace their state with X to mark that they have been shutdown
     db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir)
     myset = db(db.jobs.state == STATE_RUN)
     myset.update(state=STATE_STOPPED)
     db.commit()
     self.sem = BoundedSemaphore(config.np)
     self.mutex = Lock()
     # set time zone
     try:
         os.environ['TZ'] = config.time_zone
         time.tzset()
     except: pass
class dal(object):
    def __init__(self, uri=config.uri, migrate=False):
        #self.db = DAL(uri, auto_import=True, migrate=migrate, folder=config.dbdir)
        self.db = DAL(uri, migrate=migrate, folder=config.dbdir)
        # must define these here because need to use the db instance
        self.users = self.db.define_table('users', Field('id', 'integer'),
                                          Field('user', 'string'),
                                          Field('passwd', 'string'),
                                          Field('email', 'string'),
                                          Field('priority', 'integer'))
        self.apps = self.db.define_table('apps', Field('id', 'integer'),
                                         Field('name', 'string'),
                                         Field('description', 'string'),
                                         Field('category', 'string'),
                                         Field('language', 'string'),
                                         Field('input_format', 'string'),
                                         Field('command', 'string'),
                                         Field('preprocess', 'string'),
                                         Field('postprocess', 'string'),
                                         Field('uid', 'integer'))
        self.jobs = self.db.define_table('jobs', Field('id', 'integer'),
                                         Field('user', 'string'),
                                         Field('app', 'string'),
                                         Field('cid', 'string'),
                                         Field('state', 'string'),
                                         Field('time_submit', 'string'),
                                         Field('description', 'string'),
                                         Field('np', 'integer'),
                                         Field('priority', 'integer'),
                                         Field('shared', 'string'))

        self.plots = self.db.define_table('plots', Field('id', 'integer'),
                                          Field('appid', self.db.apps),
                                          Field('ptype', 'string'),
                                          Field('title', 'string'),
                                          Field('options', 'string'),
                                          Field('datadef', 'string'))

        self.datasource = self.db.define_table('datasource',
                                               Field('id', 'integer'),
                                               Field('pltid', 'integer'),
                                               Field('label', 'string'),
                                               Field('ptype', 'string'),
                                               Field('color', 'string'),
                                               Field('filename', 'string'),
                                               Field('cols', 'string'),
                                               Field('line_range', 'string'))

        self.aws_creds = self.db.define_table('aws_creds',
                                              Field('id', 'integer'),
                                              Field('key', 'string'),
                                              Field('secret', 'string'),
                                              Field('account_id', 'string'),
                                              Field('uid', 'integer'))

        self.aws_instances = self.db.define_table('aws_instances',
                                                  Field('id', 'integer'),
                                                  Field('region', 'string'),
                                                  Field('instance', 'string'),
                                                  Field('itype', 'string'),
                                                  Field('rate', 'double'),
                                                  Field('uid', 'integer'))

        self.containers = self.db.define_table('containers',
                                               Field('id', 'integer'),
                                               Field('containerid', 'string'),
                                               Field('image', 'string'),
                                               Field('command', 'string'),
                                               Field('uid', 'integer'))

        self.disciplines = self.db.define_table('disciplines', Field('name'))

    def commit(self):
        return self.db.commit()
Exemplo n.º 7
0
class dal(object):
    def __init__(self, uri=config.uri, migrate=False):

        self.db = DAL(uri, migrate=migrate, folder=config.dbdir)

        # must define these here because need to use the db instance
        self.groups =  self.db.define_table('groups', Field('id', 'integer'),
                                         Field('name', 'string'))

        self.users = self.db.define_table('users', Field('id', 'integer'),
                                         Field('user', 'string'),
                                         Field('passwd', 'string'),
                                         Field('email', 'string'),
                                         Field('new_shared_jobs', 'integer'),
                                         Field('priority', 'integer'),
                                         Field('gid', self.db.groups, ondelete="SET NULL"))

        self.user_meta = self.db.define_table('user_meta', Field('id', 'integer'),
                                         Field('uid', self.db.users),
                                         Field('new_shared_jobs', 'integer'),
                                         Field('theme', 'string'))

        self.apps = self.db.define_table('apps', Field('id', 'integer'),
                                       Field('name', 'string'),
                                       Field('description', 'string'),
                                       Field('category', 'string'),
                                       Field('language', 'string'),
                                       Field('input_format', 'string'),
                                       Field('command', 'string'),
                                       Field('assets', 'string'),
                                       Field('preprocess', 'string'),
                                       Field('postprocess', 'string'))

        self.app_user = self.db.define_table('app_user', Field('id', 'integer'),
                                       Field('appid', 'integer'),
                                       Field('uid', 'integer'))

        self.jobs = self.db.define_table('jobs', Field('id', 'integer'),
                                       Field('uid', self.db.users),
                                       Field('app', 'string'),
                                       Field('cid', 'string'),
                                       Field('gid', self.db.groups),
                                       Field('command', 'string'),
                                       Field('state', 'string'),
                                       Field('time_submit', 'string'),
                                       Field('walltime', 'string'),
                                       Field('description', 'string'),
                                       Field('np', 'integer'),
                                       Field('priority', 'integer'),
                                       Field('starred', 'string'),
                                       Field('shared', 'string'))

        self.plots = self.db.define_table('plots', Field('id', 'integer'),
                                         # need to turn on unique in the future, but will cause migration probs for old DBs
                                         # this is needed for running "spc update" b/c primary keys are not specified in spc.json
                                         Field('appid', self.db.apps), # unique=True),
                                         Field('ptype', 'string'),
                                         Field('title', 'string'),
                                         Field('options', 'string'))

        self.datasource = self.db.define_table('datasource', Field('id', 'integer'),
                                                   Field('label', 'string'), # unique=True),
                                                   Field('pltid', self.db.plots),
                                                   Field('filename', 'string'),
                                                   Field('cols', 'string'),
                                                   Field('line_range', 'string'),
                                                   Field('data_def', 'string'))

        self.aws_creds = self.db.define_table('aws_creds', Field('id', 'integer'),
                                                 Field('key', 'string'),
                                                 Field('secret', 'string'),
                                                 Field('account_id', 'string'),
                                                 Field('uid', self.db.users))

        self.aws_instances = self.db.define_table('aws_instances',
                                                        Field('id', 'integer'),
                                                        Field('region', 'string'),
                                                        Field('instance', 'string'),
                                                        Field('itype', 'string'),
                                                        Field('rate', 'double'),
                                                        Field('uid', self.db.users))

        self.disciplines = self.db.define_table('disciplines', Field('name'))

    def commit(self):
        return self.db.commit()