in covid19_spread/lib/slurm_pool_executor.py [0:0]
def __init__(self, *args, **kwargs):
db_pth = kwargs.pop("db_pth", None)
super().__init__(*args, **kwargs)
self.launched = False
self.nested = False
os.makedirs(self.folder, exist_ok=True)
if db_pth is None:
# Place the actual database in ~/.slurm_pool/<unique_id>.db
unique_filename = str(uuid.uuid4())
self.db_pth = os.path.expanduser(f"~/.slurm_pool/{unique_filename}.db")
os.makedirs(os.path.dirname(self.db_pth), exist_ok=True)
if not os.path.exists(os.path.join(str(self.folder), ".job.db")):
os.symlink(self.db_pth, os.path.join(str(self.folder), ".job.db"))
else:
self.db_pth = db_pth
print(self.db_pth)
self.transaction_manager = TransactionManager(self.db_pth)
with self.transaction_manager as conn:
conn.execute(
"CREATE TABLE IF NOT EXISTS jobs(status int, pickle text, job_id text, worker_id text, id TEXT, retry_count INT)"
)
conn.execute("CREATE INDEX IF NOT EXISTS jobs_p_idx ON jobs(pickle)")
conn.execute("CREATE INDEX IF NOT EXISTS jobs_id_idx ON jobs(id)")
conn.execute(
"CREATE TABLE IF NOT EXISTS dependencies(pickle text, depends_on text, id TEXT)"
)
conn.execute("CREATE INDEX IF NOT EXISTS dep_p_idx ON dependencies(pickle)")
conn.execute(
"CREATE INDEX IF NOT EXISTS dep_d_idx ON dependencies(depends_on)"
)
conn.execute("CREATE INDEX IF NOT EXISTS dep_id_idx ON dependencies(id)")