From dc59a22c73dbb7f8732bea0778859e5428f1457d Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:02:58 +0000 Subject: [PATCH 01/10] Modified machines.py to work with new style plugins. Now need to make backwards compatible. --- fabsim/deploy/machines.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index 6555aeed..b4284f12 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -237,7 +237,7 @@ def load_plugins() -> None: with add_print_prefix(prefix="loading plugin", color=28): print("{} ...".format(key)) - plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) plugin_dict = plugin.__dict__ try: @@ -252,6 +252,10 @@ def load_plugins() -> None: ) env.localplugins.update({key: plugin_dir}) + except ModuleNotFoundError as e: + print(e) + #raise ModuleNotFoundError(e) + except ImportError as e: print(e) raise ImportError(e) From 9aa9db7469f827d98e88301fa6e8d484b2c85caf Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:11:39 +0000 Subject: [PATCH 02/10] Backward-compatible discovery of new and old-style plugins in plugins/ directory. --- fabsim/deploy/machines.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index b4284f12..2843cf5d 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -237,7 +237,23 @@ def load_plugins() -> None: with add_print_prefix(prefix="loading plugin", color=28): print("{} ...".format(key)) - plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + plugin = None + + #print(os.path.join(plugin_dir, key.lower())) + #print(os.path.join(plugin_dir, key)) + if os.path.isdir(os.path.join(plugin_dir, key.lower())): + # Check for new style plugins + plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + + elif os.path.isfile(os.path.join(plugin_dir, f"{key}.py")): + # Check for old style plugins + plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + + else: + print(f"ERROR: Plugin {key} is not recognised by FabSim3.") + print(f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + sys.exit() + plugin_dict = plugin.__dict__ try: From bf056ac465b6c081234000e858668962baf58997 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:22:53 +0000 Subject: [PATCH 03/10] Pep-8 --- fabsim/deploy/machines.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index 2843cf5d..ecdf718b 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -239,19 +239,23 @@ def load_plugins() -> None: plugin = None - #print(os.path.join(plugin_dir, key.lower())) - #print(os.path.join(plugin_dir, key)) + # print(os.path.join(plugin_dir, key.lower())) + # print(os.path.join(plugin_dir, key)) if os.path.isdir(os.path.join(plugin_dir, key.lower())): # Check for new style plugins - plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + plugin = importlib.import_module( + "plugins.{}.{}.{}".format( + key, key.lower(), key.lower())) elif os.path.isfile(os.path.join(plugin_dir, f"{key}.py")): # Check for old style plugins - plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + plugin = importlib.import_module( + "plugins.{}.{}".format(key, key)) else: print(f"ERROR: Plugin {key} is not recognised by FabSim3.") - print(f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + print( + f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") sys.exit() plugin_dict = plugin.__dict__ @@ -270,7 +274,7 @@ def load_plugins() -> None: except ModuleNotFoundError as e: print(e) - #raise ModuleNotFoundError(e) + # raise ModuleNotFoundError(e) except ImportError as e: print(e) From df50769e2a9d3647ba2acbb96d033be2bbb539b4 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:37:05 +0000 Subject: [PATCH 04/10] Pep8 --- fabsim/deploy/machines.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index ecdf718b..713cef17 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -254,8 +254,9 @@ def load_plugins() -> None: else: print(f"ERROR: Plugin {key} is not recognised by FabSim3.") - print( - f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + print(f"It may not contain either a {key}/{key}.py file") + print(f"or a {key}/{key.lower()} package,") + print(f"with a {key.lower()}.py file in it.") sys.exit() plugin_dict = plugin.__dict__ From 0b68670017ecc83357a40cac14426733fd9276e9 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 15:09:37 +0000 Subject: [PATCH 05/10] Pep8 --- fabsim/base/fab.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabsim/base/fab.py b/fabsim/base/fab.py index 1c5527be..24077d64 100644 --- a/fabsim/base/fab.py +++ b/fabsim/base/fab.py @@ -1056,7 +1056,7 @@ def job_submission(*job_args): @task @beartype def ensemble2campaign( - results_dir: str, campaign_dir: str, skip: Optional[Union[int, str]]=0 + results_dir: str, campaign_dir: str, skip: Optional[Union[int, str]] = 0 ) -> None: """ Converts FabSim3 ensemble results to EasyVVUQ campaign definition. @@ -1090,7 +1090,7 @@ def ensemble2campaign( @task @beartype def campaign2ensemble( - config: str, campaign_dir: str, skip: Optional[Union[int, str]]=0 + config: str, campaign_dir: str, skip: Optional[Union[int, str]] = 0 ) -> None: """ Converts an EasyVVUQ campaign run set TO a FabSim3 ensemble definition. From a04910e5b655ca1cf5b398e2a78f8e7c099362b6 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:02:58 +0000 Subject: [PATCH 06/10] Modified machines.py to work with new style plugins. Now need to make backwards compatible. --- fabsim/deploy/machines.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index 6555aeed..b4284f12 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -237,7 +237,7 @@ def load_plugins() -> None: with add_print_prefix(prefix="loading plugin", color=28): print("{} ...".format(key)) - plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) plugin_dict = plugin.__dict__ try: @@ -252,6 +252,10 @@ def load_plugins() -> None: ) env.localplugins.update({key: plugin_dir}) + except ModuleNotFoundError as e: + print(e) + #raise ModuleNotFoundError(e) + except ImportError as e: print(e) raise ImportError(e) From af9e60fcd19f00f811f756da4430227c529d9f90 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:11:39 +0000 Subject: [PATCH 07/10] Backward-compatible discovery of new and old-style plugins in plugins/ directory. --- fabsim/deploy/machines.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index b4284f12..2843cf5d 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -237,7 +237,23 @@ def load_plugins() -> None: with add_print_prefix(prefix="loading plugin", color=28): print("{} ...".format(key)) - plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + plugin = None + + #print(os.path.join(plugin_dir, key.lower())) + #print(os.path.join(plugin_dir, key)) + if os.path.isdir(os.path.join(plugin_dir, key.lower())): + # Check for new style plugins + plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + + elif os.path.isfile(os.path.join(plugin_dir, f"{key}.py")): + # Check for old style plugins + plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + + else: + print(f"ERROR: Plugin {key} is not recognised by FabSim3.") + print(f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + sys.exit() + plugin_dict = plugin.__dict__ try: From 2dac326289c554fe82d4e0e358b427ca966889d2 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:22:53 +0000 Subject: [PATCH 08/10] Pep-8 --- fabsim/deploy/machines.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index 2843cf5d..ecdf718b 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -239,19 +239,23 @@ def load_plugins() -> None: plugin = None - #print(os.path.join(plugin_dir, key.lower())) - #print(os.path.join(plugin_dir, key)) + # print(os.path.join(plugin_dir, key.lower())) + # print(os.path.join(plugin_dir, key)) if os.path.isdir(os.path.join(plugin_dir, key.lower())): # Check for new style plugins - plugin = importlib.import_module("plugins.{}.{}.{}".format(key, key.lower(), key.lower())) + plugin = importlib.import_module( + "plugins.{}.{}.{}".format( + key, key.lower(), key.lower())) elif os.path.isfile(os.path.join(plugin_dir, f"{key}.py")): # Check for old style plugins - plugin = importlib.import_module("plugins.{}.{}".format(key, key)) + plugin = importlib.import_module( + "plugins.{}.{}".format(key, key)) else: print(f"ERROR: Plugin {key} is not recognised by FabSim3.") - print(f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + print( + f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") sys.exit() plugin_dict = plugin.__dict__ @@ -270,7 +274,7 @@ def load_plugins() -> None: except ModuleNotFoundError as e: print(e) - #raise ModuleNotFoundError(e) + # raise ModuleNotFoundError(e) except ImportError as e: print(e) From 34398ce3dc7f319c97cca545a5cceda1cc197749 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 14:37:05 +0000 Subject: [PATCH 09/10] Pep8 --- fabsim/deploy/machines.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index ecdf718b..713cef17 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -254,8 +254,9 @@ def load_plugins() -> None: else: print(f"ERROR: Plugin {key} is not recognised by FabSim3.") - print( - f"It may not contain either a {key}/{key}.py file or a {key}/{key.lower()} package with a {key.lower()}.py file in it.") + print(f"It may not contain either a {key}/{key}.py file") + print(f"or a {key}/{key.lower()} package,") + print(f"with a {key.lower()}.py file in it.") sys.exit() plugin_dict = plugin.__dict__ From d386702fd096fc36006a61ca58c53468e0464233 Mon Sep 17 00:00:00 2001 From: Derek Groen Date: Tue, 5 Dec 2023 15:31:13 +0000 Subject: [PATCH 10/10] pep8 --- fabsim/deploy/machines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabsim/deploy/machines.py b/fabsim/deploy/machines.py index 713cef17..6cb5b84c 100644 --- a/fabsim/deploy/machines.py +++ b/fabsim/deploy/machines.py @@ -254,7 +254,7 @@ def load_plugins() -> None: else: print(f"ERROR: Plugin {key} is not recognised by FabSim3.") - print(f"It may not contain either a {key}/{key}.py file") + print(f"It may not contain either a {key}/{key}.py file") print(f"or a {key}/{key.lower()} package,") print(f"with a {key.lower()}.py file in it.") sys.exit()