diff --git a/LIReC/jobs/config.py b/LIReC/jobs/config.py index bad29e1..44af8f9 100644 --- a/LIReC/jobs/config.py +++ b/LIReC/jobs/config.py @@ -9,18 +9,6 @@ }, 'run_async': True, 'async_cores': 2 - }),#, - #'poly_pslq_v2', { - # 'args': { - # 'degree': 2, 'order': 1, - # 'min_precision': 50, 'min_roi': 2, - # 'testing_precision': 15, # replaces min_precision when fed to pslq - # 'bulk': 10, # if testing lots of constants, can instead limit discovery to 'bulk' constants at a time until no relevant relation is found, then another 'bulk' constants are added - # #'filters': { # the existence of filters disables antirelation logging - # # 'PcfCanonical': { 'balanced_only': True } - # #} - # }, - # 'run_async': True, - # 'iterations': 1 + }) ] } diff --git a/LIReC/jobs/run.py b/LIReC/jobs/run.py index c773243..aa89815 100644 --- a/LIReC/jobs/run.py +++ b/LIReC/jobs/run.py @@ -13,43 +13,27 @@ MOD_PATH = 'LIReC.jobs.job_%s' def validate_config(config): - if not isinstance(config, dict): - return False, "Configuration should be a dictionary." - - if 'jobs_to_run' not in config: - return False, "Missing 'jobs_to_run' key in configuration." - - if not isinstance(config['jobs_to_run'], list): - return False, "'jobs_to_run' should be a list." + if "jobs_to_run" not in config or not isinstance(config['jobs_to_run'], list): + return False, "Invalid configuration: Missing or incorrect 'jobs_to_run'" for job in config['jobs_to_run']: - if not isinstance(job, tuple) or len(job) != 2: - return False, "'jobs_to_run' should contain tuples of (job_name, job_info)." + if not isinstance(job, list) or len(job) != 2: + return False, "Each job must be a list containing two elements" - job_name, job_info = job + job_name, job_details = job if not isinstance(job_name, str): - return False, "Job name should be a string." - - if not isinstance(job_info, dict): - return False, "Job info should be a dictionary." + return False, "Job name must be a string" - required_keys = {'args', 'run_async', 'async_cores'} - if not all(key in job_info for key in required_keys): - return False, "Missing required keys in job info." + if not isinstance(job_details, dict): + return False, "Job details must be a dictionary" - args = job_info['args'] - if not isinstance(args, dict): - return False, "'args' should be a dictionary." + # Check required keys in job_details + required_keys = ["args", "run_async", "async_cores"] + for key in required_keys: + if key not in job_details: + return False, f"Missing key '{key}' in job details" - expected_args_keys = {'degree', 'order', 'bulk', 'filters'} - if not all(key in args for key in expected_args_keys): - return False, "Missing required keys in args." - - filters = args['filters'] - if not isinstance(filters, dict): - return False, "'filters' should be a dictionary." - - # Further checks can be added for filters' inner structure if necessary + # Additional detailed checks can be implemented here as needed return True, "Configuration is valid." @@ -98,6 +82,8 @@ def main() -> None: job_config = json.load(file) logger.info("Loaded job configuration: %s", json.dumps(job_config, indent=4)) valid, message = validate_config(job_config) + job_config['jobs_to_run'] = [tuple(job) for job in job_config['jobs_to_run']] + logger.info("validate_config job configuration: %s", message) if valid: config_data = job_config