Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions cravat/cravat_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,25 +684,31 @@ def get_dbpaths(dbpaths, path):
def result2gui(args):
dbpath = args.path
user = args.user
job_id = args.jobid
jobs_dir = Path(au.get_jobs_dir())
user_dir = jobs_dir / user
if not user_dir.is_dir():
exit(f"User {user} not found")
attempts = 0
while (
True
): # TODO this will currently overwrite if called in parallel. is_dir check and creation is not atomic
job_id = datetime.datetime.now().strftime(r"%y%m%d-%H%M%S")
if job_id is None:
while (
True
): # TODO this will currently overwrite if called in parallel. is_dir check and creation is not atomic
job_id = datetime.datetime.now().strftime(r"%y%m%d-%H%M%S")
job_dir = user_dir / job_id
if not job_dir.is_dir():
break
else:
attempts += 1
time.sleep(1)
if attempts >= 5:
exit(
"Could not acquire a job id. Too many concurrent job submissions. Wait, or reduce submission frequency."
)
else:
job_dir = user_dir / job_id
if not job_dir.is_dir():
break
else:
attempts += 1
time.sleep(1)
if attempts >= 5:
exit(
"Could not acquire a job id. Too many concurrent job submissions. Wait, or reduce submission frequency."
)
if job_dir.is_dir():
exit(f"Job id {job_id} you selected already exists. Please select another one.")
job_dir.mkdir()
new_dbpath = job_dir / dbpath.name
shutil.copyfile(dbpath, new_dbpath)
Expand Down Expand Up @@ -1188,6 +1194,13 @@ def jobtopackage(args):
type=str,
default="default",
)
parser_result2gui.add_argument(
"-j",
"--jobid",
help="Optional job ID. Defaults to current timestamp",
type=str,
default=None,
)
parser_result2gui.set_defaults(func=result2gui)
# Merge SQLite files
parser_mergesqlite = subparsers.add_parser(
Expand Down