Skip to content

Commit

Permalink
Improved batching config obtaining
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeulette committed Nov 28, 2024
1 parent 106e6e6 commit e45e008
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/imio/updates/update_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,17 @@ def get_instance_home(buildout_path):
return os.path.join(buildout_path, "parts", instance)


def get_batch_config(ih_dir=None):
def get_batch_config(dirs=()):
"""Get latest batching config file"""
if ih_dir is None:
ih_dir = os.getenv("INSTANCE_HOME", ".")
files = read_dir_filter(ih_dir, with_path=True, patterns=[r".*_config\.txt$"])
if not files:

dirs.extend([os.getenv("INSTANCE_HOME", ".")])
all_files = []
for adir in dirs:
files = read_dir_filter(adir, with_path=True, patterns=[r".*_config\.txt$"])
all_files.extend(files)
if not all_files:
return None
latest_file = max(files, key=os.path.getmtime)
latest_file = max(all_files, key=os.path.getmtime)
if latest_file:
config = {}
load_var(latest_file, config)
Expand Down Expand Up @@ -412,10 +415,10 @@ def run_function_parts(func_parts, batches_conf, params):
if part in batches_conf.get("batching", ""):
# get batching dict
if doit:
homedir = get_instance_home(params["buildouts"][params["bldt"]]["path"])
batch_config = get_batch_config(homedir)
bldtdir = params["buildouts"][params["bldt"]]["path"]
batch_config = get_batch_config([bldtdir, get_instance_home(bldtdir)])
if batch_config is None:
error(append(messages, "Cannot get batching config file in '{}'".format(homedir)))
error(append(messages, "Cannot get batching config file in '{}'".format(bldtdir)))
error(
append(
messages,
Expand Down

0 comments on commit e45e008

Please sign in to comment.