-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per #2299, update check for deprecated MET config env vars by using t…
…he list of deprecated env vars found in each wrapper to determine the list to check. I had to move _get_wrapper_instance to another util file so that it can be imported by config_validate and run_util without creating a circular dependency
- Loading branch information
1 parent
962bb8a
commit 21bb0b5
Showing
5 changed files
with
68 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from importlib import import_module | ||
|
||
from . import camel_to_underscore | ||
|
||
|
||
def get_wrapper_instance(config, process, instance=None): | ||
"""!Initialize METplus wrapper instance. | ||
@param config METplusConfig object to pass to wrapper constructor | ||
@param process name of wrapper in camel case, e.g. GridStat | ||
@param instance (optional) instance identifier for creating multiple | ||
instances of a wrapper. Set to None (default) if no instance is specified | ||
@returns CommandBuilder sub-class object or None if something went wrong | ||
""" | ||
try: | ||
package_name = ('metplus.wrappers.' | ||
f'{camel_to_underscore(process)}_wrapper') | ||
module = import_module(package_name) | ||
metplus_wrapper = ( | ||
getattr(module, f"{process}Wrapper")(config, instance=instance) | ||
) | ||
except AttributeError as err: | ||
config.logger.error(f"There was a problem loading {process} wrapper: {err}") | ||
return None | ||
except ModuleNotFoundError: | ||
config.logger.error(f"Could not load {process} wrapper. " | ||
"Wrapper may have been disabled.") | ||
return None | ||
|
||
return metplus_wrapper |