integrated threadsafe status updates

This commit is contained in:
PatchOfScotland
2023-04-18 13:50:20 +02:00
parent 3f28b11be9
commit ddca1f6aa4
11 changed files with 196 additions and 120 deletions

View File

@ -6,9 +6,10 @@ Author(s): David Marchant
import os
from distutils.dir_util import copy_tree
from typing import List
from meow_base.core.vars import DEFAULT_JOB_OUTPUT_DIR, \
DEFAULT_JOB_QUEUE_DIR
DEFAULT_JOB_QUEUE_DIR, LOCK_EXT
from meow_base.functionality.file_io import make_dir, rmtree
from meow_base.patterns.file_event_pattern import FileEventPattern
from meow_base.recipes.jupyter_notebook_recipe import JupyterNotebookRecipe
@ -37,7 +38,9 @@ def teardown():
rmtree(DEFAULT_JOB_QUEUE_DIR)
rmtree("first")
for f in [
"temp_phantom_info.h5", "temp_phantom.h5", "doesNotExist.lock"
"temp_phantom_info.h5",
"temp_phantom.h5",
f"doesNotExist{LOCK_EXT}"
]:
if os.path.exists(f):
os.remove(f)
@ -46,6 +49,14 @@ def backup_before_teardown(backup_source:str, backup_dest:str):
make_dir(backup_dest, ensure_clean=True)
copy_tree(backup_source, backup_dest)
# Necessary, as the creation of locks is not deterministic
def list_non_locks(dir:str)->List[str]:
return [f for f in os.listdir(dir) if not f.endswith(LOCK_EXT)]
# Necessary, as the creation of locks is not deterministic
def count_non_locks(dir:str)->int:
return len(list_non_locks(dir))
# Bash scripts
BAREBONES_BASH_SCRIPT = [