From 14231433c5c177220f2cabf696f6d1e7b0d934c4 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 11 May 2023 15:23:23 -0600 Subject: [PATCH 1/2] Add more verbose error messages --- pysqa/ext/modular.py | 5 ++++- pysqa/queueadapter.py | 8 ++++++-- pysqa/utils/basic.py | 8 ++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pysqa/ext/modular.py b/pysqa/ext/modular.py index 3e7ab94b..e24f8643 100644 --- a/pysqa/ext/modular.py +++ b/pysqa/ext/modular.py @@ -16,7 +16,10 @@ def __init__(self, config, directory="~/.queues", execute_command=execute_comman } for v in self._queue_to_cluster_dict.values(): if v not in self._config["cluster"]: - raise ValueError() + raise ValueError( + "The cluster " + v + " was not found in the list of clusters " + + str(list(self._config["cluster"].keys())) + ) def submit_job( self, diff --git a/pysqa/queueadapter.py b/pysqa/queueadapter.py index b975de40..725901a8 100644 --- a/pysqa/queueadapter.py +++ b/pysqa/queueadapter.py @@ -69,7 +69,7 @@ def __init__(self, directory="~/.queues", execute_command=execute_command): } primary_queue = config["cluster_primary"] else: - raise ValueError + raise ValueError("Neither a queue.yaml file nor a clusters.yaml file were found in " + directory) self._adapter = self._queue_dict[primary_queue] def list_clusters(self): @@ -321,4 +321,8 @@ def set_queue_adapter(config, directory, execute_command=execute_command): config=config, directory=directory, execute_command=execute_command ) else: - raise ValueError + raise ValueError( + "The queue_type " + config["queue_type"] + + " is not found in the list of supported queue types " + + str(["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"]) + ) diff --git a/pysqa/utils/basic.py b/pysqa/utils/basic.py index 24932830..f61e8902 100644 --- a/pysqa/utils/basic.py +++ b/pysqa/utils/basic.py @@ -70,7 +70,11 @@ def __init__(self, config, directory="~/.queues", execute_command=execute_comman class_name = "FluxCommands" module_name = "pysqa.wrapper.flux" else: - raise ValueError() + raise ValueError( + "The queue_type " + self._config["queue_type"] + + " is not found in the list of supported queue types " + + str(["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"]) + ) if self._config["queue_type"] != "REMOTE": self._commands = getattr(importlib.import_module(module_name), class_name)() self._queues = Queues(self.queue_list) @@ -391,7 +395,7 @@ def _job_submission_template( queue = self._config["queue_primary"] self._value_error_if_none(value=command) if queue not in self.queue_list: - raise ValueError() + raise ValueError("The queue " + queue + " was not found in the list of queues: " + str(self.queue_list)) active_queue = self._config["queues"][queue] cores, run_time_max, memory_max = self.check_queue_parameters( queue=None, From b8ee8a5fb41210c4f45beaa5d552f638c580ce13 Mon Sep 17 00:00:00 2001 From: pyiron-runner Date: Thu, 11 May 2023 21:25:10 +0000 Subject: [PATCH 2/2] Format black --- pysqa/ext/modular.py | 6 ++++-- pysqa/queueadapter.py | 12 ++++++++---- pysqa/utils/basic.py | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pysqa/ext/modular.py b/pysqa/ext/modular.py index e24f8643..95736624 100644 --- a/pysqa/ext/modular.py +++ b/pysqa/ext/modular.py @@ -17,8 +17,10 @@ def __init__(self, config, directory="~/.queues", execute_command=execute_comman for v in self._queue_to_cluster_dict.values(): if v not in self._config["cluster"]: raise ValueError( - "The cluster " + v + " was not found in the list of clusters " + - str(list(self._config["cluster"].keys())) + "The cluster " + + v + + " was not found in the list of clusters " + + str(list(self._config["cluster"].keys())) ) def submit_job( diff --git a/pysqa/queueadapter.py b/pysqa/queueadapter.py index 725901a8..f06888a1 100644 --- a/pysqa/queueadapter.py +++ b/pysqa/queueadapter.py @@ -69,7 +69,10 @@ def __init__(self, directory="~/.queues", execute_command=execute_command): } primary_queue = config["cluster_primary"] else: - raise ValueError("Neither a queue.yaml file nor a clusters.yaml file were found in " + directory) + raise ValueError( + "Neither a queue.yaml file nor a clusters.yaml file were found in " + + directory + ) self._adapter = self._queue_dict[primary_queue] def list_clusters(self): @@ -322,7 +325,8 @@ def set_queue_adapter(config, directory, execute_command=execute_command): ) else: raise ValueError( - "The queue_type " + config["queue_type"] + - " is not found in the list of supported queue types " + - str(["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"]) + "The queue_type " + + config["queue_type"] + + " is not found in the list of supported queue types " + + str(["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"]) ) diff --git a/pysqa/utils/basic.py b/pysqa/utils/basic.py index f61e8902..78c120d5 100644 --- a/pysqa/utils/basic.py +++ b/pysqa/utils/basic.py @@ -71,9 +71,12 @@ def __init__(self, config, directory="~/.queues", execute_command=execute_comman module_name = "pysqa.wrapper.flux" else: raise ValueError( - "The queue_type " + self._config["queue_type"] + - " is not found in the list of supported queue types " + - str(["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"]) + "The queue_type " + + self._config["queue_type"] + + " is not found in the list of supported queue types " + + str( + ["SGE", "TORQUE", "SLURM", "LSF", "MOAB", "FLUX", "GENT", "REMOTE"] + ) ) if self._config["queue_type"] != "REMOTE": self._commands = getattr(importlib.import_module(module_name), class_name)() @@ -395,7 +398,12 @@ def _job_submission_template( queue = self._config["queue_primary"] self._value_error_if_none(value=command) if queue not in self.queue_list: - raise ValueError("The queue " + queue + " was not found in the list of queues: " + str(self.queue_list)) + raise ValueError( + "The queue " + + queue + + " was not found in the list of queues: " + + str(self.queue_list) + ) active_queue = self._config["queues"][queue] cores, run_time_max, memory_max = self.check_queue_parameters( queue=None,