geoips package#
Subpackages#
- geoips.commandline package
- Subpackages
- Submodules
- geoips.commandline.args module
- geoips.commandline.cmd_instructions module
- geoips.commandline.commandline_interface module
- geoips.commandline.geoips_command module
- geoips.commandline.geoips_config module
- geoips.commandline.geoips_describe module
- geoips.commandline.geoips_list module
- geoips.commandline.geoips_run module
- geoips.commandline.geoips_test module
- geoips.commandline.geoips_tree module
- geoips.commandline.geoips_validate module
- geoips.commandline.list_available_plugins module
- geoips.commandline.log_setup module
- geoips.commandline.run_procflow module
- geoips.commandline.update_tc_tracks_database module
- Module contents
- geoips.data_manipulations package
- geoips.dev package
- Submodules
- geoips.dev.output_config module
get_filename_formatter_kwargs()
get_filename_formatters()
get_metadata_filename_formatter()
get_metadata_filename_formatter_kwargs()
get_metadata_output_formatter()
get_metadata_output_formatter_kwargs()
get_minimum_coverage()
get_output_config_type()
get_output_formatter()
get_output_formatter_kwargs()
is_valid_output_config()
produce_current_time()
set_lonlat_spacing()
test_output_config_interface()
- geoips.dev.product module
- Module contents
- geoips.filenames package
- geoips.image_utils package
- geoips.interfaces package
- Subpackages
- geoips.interfaces.module_based package
- Submodules
- geoips.interfaces.module_based.algorithms module
- geoips.interfaces.module_based.colormappers module
- geoips.interfaces.module_based.coverage_checkers module
- geoips.interfaces.module_based.databases module
- geoips.interfaces.module_based.filename_formatters module
- geoips.interfaces.module_based.interpolators module
- geoips.interfaces.module_based.output_checkers module
- geoips.interfaces.module_based.output_formatters module
- geoips.interfaces.module_based.procflows module
- geoips.interfaces.module_based.readers module
- geoips.interfaces.module_based.sector_adjusters module
- geoips.interfaces.module_based.sector_metadata_generators module
- geoips.interfaces.module_based.sector_spec_generators module
- geoips.interfaces.module_based.title_formatters module
- Module contents
- geoips.interfaces.yaml_based package
- Submodules
- geoips.interfaces.yaml_based.feature_annotators module
- geoips.interfaces.yaml_based.gridline_annotators module
- geoips.interfaces.yaml_based.product_defaults module
- geoips.interfaces.yaml_based.products module
- geoips.interfaces.yaml_based.sectors module
- geoips.interfaces.yaml_based.workflows module
- Module contents
- geoips.interfaces.module_based package
- Submodules
- geoips.interfaces.base module
- Module contents
- Subpackages
- geoips.plugins package
- geoips.pydantic package
- Submodules
- geoips.pydantic.bases module
- geoips.pydantic.feature_annotators module
- geoips.pydantic.gridline_annotators module
GridlineAnnotatorPluginModel
GridlineAnnotatorSpec
Labels
Labels.alpha
Labels.backgroundcolor
Labels.bottom
Labels.color
Labels.fontfamily
Labels.fontsize
Labels.fontstretch
Labels.fontstyle
Labels.fontvariant
Labels.fontweight
Labels.left
Labels.linespacing
Labels.model_config
Labels.mouseover
Labels.position
Labels.right
Labels.rotation
Labels.rotation_mode
Labels.snap
Labels.top
Labels.wrap
Labels.xpadding
Labels.ypadding
Labels.zorder
Lines
Spacing
- geoips.pydantic.sectors module
AreaDefinitionSpec
BoxMetadata
EarthConstants
RegionMetadata
SectorAreaExtent
SectorPluginModel
SectorProjection
SectorProjection.R
SectorProjection.a
SectorProjection.ellipsoid
SectorProjection.h
SectorProjection.k_0
SectorProjection.lat_0
SectorProjection.lat_1
SectorProjection.lat_2
SectorProjection.lat_ts
SectorProjection.lon_0
SectorProjection.model_config
SectorProjection.proj
SectorProjection.t_epoch
SectorProjection.t_final
SectorProjection.units
SectorProjection.x_0
SectorProjection.y_0
SectorResolution
SectorShape
StaticMetadata
StitchedMetadata
TCMetadata
TCMetadata.aid_type
TCMetadata.center_lat
TCMetadata.center_lon
TCMetadata.deck_line
TCMetadata.final_storm_name
TCMetadata.model_config
TCMetadata.pressure
TCMetadata.source_file
TCMetadata.storm_basin
TCMetadata.storm_name
TCMetadata.storm_num
TCMetadata.storm_year
TCMetadata.synoptic_time
TCMetadata.velocity_max
VolcanoMetadata
XYCoordinate
lat_lon_coordinate()
- geoips.pydantic.workflows module
- Module contents
- geoips.sector_utils package
- Submodules
- geoips.sector_utils.estimate_area_extent module
- geoips.sector_utils.overpass_predictor module
- geoips.sector_utils.projections module
- geoips.sector_utils.tc_tracks module
- geoips.sector_utils.tc_tracks_database module
- geoips.sector_utils.utils module
check_center_coverage()
copy_sector_info()
create_areadefinition_from_yaml()
filter_area_defs_actual_time()
get_lat_center()
get_lon_center()
get_max_lat()
get_max_lon()
get_min_lat()
get_min_lon()
get_sectors_from_yamls()
get_static_area_defs_for_xarray()
get_tc_area_defs_for_xarray()
get_trackfile_area_defs()
is_dynamic_sector()
is_requested_aid_type()
is_sector_type()
remove_duplicate_storm_positions()
set_tc_coverage_check_area_def()
set_text_area_def()
storm_locations_match()
- geoips.sector_utils.yaml_utils module
- Module contents
- geoips.utils package
- geoips.xarray_utils package
Submodules#
geoips.cli module#
GeoIPS
The Geolocated Information Processing System (GeoIPS) is a generalized processing system, providing a collection of algorithm and product implementations facilitating consistent and reliable application of specific products across a variety of sensors and data types.
GeoIPS acts as a toolbox for internal GeoIPS-based product development - all modules are expected to have simple inputs and outputs (Python numpy or dask arrays or xarrays, dictionaries, strings, lists), to enable portability and simplified interfacing between modules.
- class geoips.cli.RawDescriptionArgumentDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]#
Bases:
ArgumentDefaultsHelpFormatter
,RawDescriptionHelpFormatter
Compound formatter class for user-readable help.
preserves the raw description formatting
adds defaults to helps.
- geoips.cli.add_list_interface_parser(subparsers, name, aliases=None)[source]#
Add list interface parser.
- geoips.cli.formclass#
geoips.create_plugin_registries module#
Generates all available plugins from all installed GeoIPS packages.
After all plugins have been generated, they are written to a registered_plugins.json file which contains a dictionary of all the registered GeoIPS plugins across all plugin repositories.
Call ‘python create_plugin_registry.py’ to produce registered_plugins.json for EVERY currently installed plugin package. A separate registered_plugins.json is created at the top level package directory for each plugin package.
- geoips.create_plugin_registries.add_module_plugin(package, relpath, plugins)[source]#
Add the module plugin associated with the filepaths and package to plugins.
- Parameters:
package (str) – The current GeoIPS package being parsed
relpath (str) – The relpath path to the module plugin
plugins (dict) – A dictionary object of all installed GeoIPS package plugins
- Returns:
error_message – String containing informative error messages from any plugins that were improperly formatted. An exception will be raised at the very end if error_message is not the empty string - this allows collecting ALL errors throughout the plugin registry process and reporting them all at once, to facilitate rapidly identifying and resolving errors.
- Return type:
str
- geoips.create_plugin_registries.add_text_plugin(package, relpath, plugins)[source]#
Add all txt plugins into plugin registries.
- Parameters:
package (str) – The current GeoIPS package being parsed
relpath (str) – The relpath path to the module plugin
plugins (dict) – A dictionary object of all installed GeoIPS package plugins
- Returns:
error_message – String containing informative error messages from any plugins that were improperly formatted. An exception will be raised at the very end if error_message is not the empty string - this allows collecting ALL errors throughout the plugin registry process and reporting them all at once, to facilitate rapidly identifying and resolving errors.
- Return type:
str
- geoips.create_plugin_registries.add_yaml_plugin(filepath, relpath, package, plugins, namespace)[source]#
Add the yaml plugin associated with the filepaths and package to plugins.
- Parameters:
filepath (str) – The path of the plugin derived from resouces.files(package) / plugin
relpath (str) – The relative path to the filepath provided
package (str) – The current GeoIPS package being parsed
plugins (dict) – A dictionary object of all installed GeoIPS package plugins
namespace (str) – Namespace that your plugin packages fall under. The argument parser defaults this value to ‘geoips.plugin_packages’, but a user can create separate namespaces if developing interfaces outside of the main GeoIPS package.
- Returns:
error_message – String containing informative error messages from any plugins that were improperly formatted. An exception will be raised at the very end if error_message is not the empty string - this allows collecting ALL errors throughout the plugin registry process and reporting them all at once, to facilitate rapidly identifying and resolving errors.
- Return type:
str
- geoips.create_plugin_registries.check_plugin_exists(package, plugins, interface_name, plugin_name, relpath)[source]#
Check if plugin already exists. If it does raise a PluginRegistryError.
Note this only checks for duplicate plugins within a single plugin package. The registry_sanity_check function is used after all plugins have been loaded to identify duplicate plugins across different plugin packages.
- Parameters:
package (str) – The GeoIPS package being tested against
plugins (dict) – A dictionary object of all installed GeoIPS plugins in the current plugin package.
interface_name (str) – A string representing the GeoIPS interface being checked against
plugin_name (str) – A string representing the name of the plugin within the GeoIPS interface
- Returns:
error_message – Empty string if no error, appropriate informative error message if duplicate plugin found in current plugin package.
- Return type:
str
- geoips.create_plugin_registries.create_plugin_registries(plugin_packages, save_type, namespace)[source]#
Generate all plugin paths associated with every installed GeoIPS packages.
These paths include schema plugins, module_based plugins and normal YAML plugins. After these paths are generated, they are sent to parse_plugin_paths, which generates and adds the actual plugins to the plugins dictionary.
- Parameters:
plugin_packages (list EntryPoints) – A list of EntryPoints pointing to each installed GeoIPS package –> ie. [EntryPoint(name=’geoips’, value=’geoips’, group=’geoips.plugin_packages’), …]
save_type (str) – The file format to save to [json, yaml]
namespace (str) – Namespace that your plugin packages fall under. The argument parser defaults this value to ‘geoips.plugin_packages’, but a user can create separate namespaces if developing interfaces outside of the main GeoIPS package.
- geoips.create_plugin_registries.format_docstring(docstring, use_regex=True)[source]#
Format the provided docstring placement in the plugin registry.
Found when using the CLI and inspecting the registry, some docstrings are formatted in a hard to read manner and look pretty bad. This function will format these docstrings to be easily readable, whether obtained via the CLI or manually inspected in the plugin registry.
- Parameters:
docstring (str) –
The docstring which we are going to format.
use_regex (bool, optional (default=False)) –
Whether or not we want to apply regex formatting to the docstring. Usually recommended as it will replace ‘newline’ chars but not purposeful ‘.newline’ strings.
- geoips.create_plugin_registries.parse_plugin_paths(plugin_paths, package, package_dir, plugins, namespace)[source]#
Parse the plugin_paths provided from the current installed GeoIPS package.
Then, add them to the plugins dictionary based on the path of the plugin. The path contains information as to whether the plugin is a schema, module_based, or a normal yaml plugin.
- Parameters:
plugin_paths (dict) – A dictionary of filepaths, with keys referring to the type of plugin
package (str) – The current GeoIPS package being parsed
package_dir (str) – The path to the current GeoIPS package (for determining relative paths)
plugins (dict) – A dictionary object of all installed GeoIPS package plugins
namespace (str) – Namespace that your plugin packages fall under. The argument parser defaults this value to ‘geoips.plugin_packages’, but a user can create separate namespaces if developing interfaces outside of the main GeoIPS package.
- Returns:
error_message – String containing informative error messages from any plugins that were improperly formatted. An exception will be raised at the very end if error_message is not the empty string - this allows collecting ALL errors throughout the plugin registry process and reporting them all at once, to facilitate rapidly identifying and resolving errors.
- Return type:
str
- geoips.create_plugin_registries.registry_sanity_check(plugin_packages, save_type)[source]#
Check that each plugin package registry has no duplicate lowest depth entries.
If it does, raise a PluginRegistryError for that specific package, then remove all plugin registries from each package so the user must fix the error before continuing. While this doesn’t cause a normal error, duplicate plugins will be overwritten by same-named plugin found in the last package-entrypoint.
- Parameters:
plugin_packages (list EntryPoints) – A list of EntryPoints pointing to each installed GeoIPS package –> ie. [EntryPoint(name=’geoips’, value=’geoips’, group=’geoips.plugin_packages’)]
save_type (str) – The file format to save to [json, yaml]
- Returns:
No returns
Exceptions
———-
PluginRegistryError – If error_message has contents, then raise PluginRegistryError(error_message). The error_message string will collect and report on all errors within this function prior to raising the PluginRegistryError to facilitate rapidly identifying and resolving errors throughout all plugin packages.
- geoips.create_plugin_registries.remove_registries(plugin_packages)[source]#
Remove all plugin registries if a PluginRegistryError is raised.
- Parameters:
plugin_packages (list EntryPoints) – A list of EntryPoints pointing to each installed GeoIPS package –> ie. [EntryPoint(name=’geoips’, value=’geoips’, group=’geoips.plugin_packages’), …]
- Return type:
None
- geoips.create_plugin_registries.write_registered_plugins(pkg_dir, plugins, save_type)[source]#
Write dictionary of all plugins available from installed GeoIPS packages.
- Parameters:
pkg_dir (str) – Path in which to write registered_plugins
plugins (dict) – A dictionary object of all installed GeoIPS package plugins
save_type (str) – The file format to save to [json, yaml]
- Return type:
No returns, file written to pkg_dir
geoips.errors module#
GeoIPS error module.
- exception geoips.errors.CliError[source]#
Bases:
Exception
Raise exception on command line interface error.
- exception geoips.errors.CoverageError[source]#
Bases:
Exception
Raise exception on data coverage error.
- exception geoips.errors.MissingRequiredXarrayMetadata[source]#
Bases:
Exception
Exception to be raised when required metadata missing from a geoips xarray.
Can be used from reader plugins if required metadata is missing, or from the procflows to validate the xarray output of plugins. At every stage, all GeoIPS xarrays should contain the required metadata.
- exception geoips.errors.NoValidFilesError[source]#
Bases:
Exception
Exception to be raised when there are no valid files found.
Can be used from reader plugins if no valid files were passed to the reader.
- exception geoips.errors.OutputFormatterDatelineError[source]#
Bases:
Exception
Exception to be raised when there is a dateline error in an output formatter.
- exception geoips.errors.OutputFormatterInvalidProjectionError[source]#
Bases:
Exception
Exception to be raised when there is a projection error in an OutputFormatter.
- exception geoips.errors.PluginError[source]#
Bases:
Exception
Exception to be raised when there is an error in a GeoIPS plugin.
geoips.geoips_utils module#
General high level utilities for geoips processing.
- geoips.geoips_utils.copy_standard_metadata(orig_xarray, dest_xarray, extra_attrs=None, force=True)[source]#
Copy standard metadata from orig_xarray to dest_xarray.
- Parameters:
orig_xarray (xarray.Dataset) – Original xarray to copy attributes from
dest_xarray (xarray.Dataset) – Destination xarray to copy attributes to
extra_attrs (list of str, optional) – Additional attributes to copy, beyond the standard metadata, by default None
force (bool, optional) – If force is True, overwrite existing attributes, by default True
- Returns:
dest_xarray with standard metadata copied in place from orig_xarray.
- Return type:
xarray.Dataset
- geoips.geoips_utils.expose_geoips_commands(pkg_name=None, _test_log=None)[source]#
Expose a list of commands that operate in the GeoIPS environment.
Where, these commands are defined under ‘pyproject.toml:[tool.poetry.scripts]’, or ‘pyproject.toml:[project.entry-points.console_scripts]’
- Parameters:
pkg_name (str (default = None)) –
The name of the GeoIPS Plugin Package whose command’s will be exposed.
If None, assume this was called via the commandline and retrieve package_name via that manner. Otherwise use the supplied package_name.
_test_log (logging.Logger (default = None)) –
If provided, use this logger instead. This is added as an optional argument so we can check the output of this command for our Unit Tests.
- geoips.geoips_utils.find_all_txt_plugins(subdir='')[source]#
Find all txt plugins in registered plugin packages.
Search the
plugins
directory of each registered plugin package for files ending in.txt
. Return list of files
- geoips.geoips_utils.find_ascii_palette(name)[source]#
Find ASCII palette named “name”.
Search the plugins/txt/ascii_palettes directory for ASCII palettes to use as colormaps.
- geoips.geoips_utils.get_interface_module(namespace)[source]#
Retrieve the interface module from a given namespace.
Since this function uses the first portion of a namespace, I.e. (geoips.plugin_packages –> geoips), only interfaces implemented in that exact package will be recognized in that namespace. This means that if developers or users implement new interfaces in the ‘geoips.plugin_packages’ namespace, they still won’t be recognized or available for use in GeoIPS.
To get new interfaces to work, you must implement them in a separate namespace that is named the same as the plugin package that implemented them. I.e. (splunk.plugin_packages –> splunk). Any other package that falls under that namespace can make use of these interfaces, as well as GeoIPS’ interfaces.
- Parameters:
namespace (str) –
The namespace containg the requested interface module. I.e. ‘geoips.plugin_packages’.
- geoips.geoips_utils.get_numpy_seeded_random_generator()[source]#
Get a NumPy random generator seeded with a fixed value.
- Returns:
A NumPy random generator initialized with a fixed seed value of 42.
- Return type:
numpy.random.Generator
Notes
This function returns a seeded random generator using NumPy’s default_rng function with a fixed seed of 42. Using a fixed seed ensures that the random numbers generated by this generator will be reproducible across different runs. 42 was chosen because it is the answer to the universe and all things; that is to say: it’s selection is inconsequential and any other number could have been chosen.
Examples
>>> predictable_random = get_numpy_seeded_random_generator() >>> predictable_random.integers(0, 10, size=5) array([6, 3, 7, 4, 6]) # Example output, will be the same every time
- geoips.geoips_utils.is_editable(package_name)[source]#
Return whether or not ‘package_name’ has been installed in editable mode.
Where editable mode is a local package installed via ‘pip install -e <path_to_pkg> and non-editable mode is a local package installed via ‘pip install <pact_to_pkg>.
If the package under package_name doesn’t exist, raise a ValueError reporting that.
- Parameters:
package_name (str) –
The name of the pip installed local package. (ie. “geoips”, “recenter_tc”, ..)
- Returns:
editable –
The truth value as to whether or not the package was installed in editable mode.
- Return type:
bool
- geoips.geoips_utils.load_all_yaml_plugins()[source]#
Find all YAML plugins in registered plugin packages.
Search the
plugins
directory of each registered plugin package for files ending in.yaml
. Read each plugin file
- geoips.geoips_utils.merge_nested_dicts(dest, src, in_place=True, replace=False)[source]#
Perform an in-place merge of src into dest.
Performs an in-place merge of src into dest while preserving any values that already exist in dest.
- geoips.geoips_utils.order_paths_from_least_to_most_specific(paths)[source]#
Orders a list of filesystem paths from least to most specific.
This function takes a list of filesystem paths and returns a new list of paths ordered from the least specific (higher-level directories) to the most specific (subdirectories and files). It expands environmental variables in paths.
- Parameters:
paths (list of str or pathlib.Path) – A list of filesystem paths to be ordered.
- Returns:
A list of filesystem paths ordered from least to most specific.
- Return type:
list of pathlib.Path
Examples
>>> paths = [ ... '/home/user/docs/', ... '/home/user/images/', ... '/home/user/', ... '/home/user/images/photo.jpg' ... '/home/user/docs/report.txt', ... ] >>> order_paths_from_least_to_most_specific(paths) [PosixPath('/home/user/'), PosixPath('/home/user/docs/'), PosixPath('/home/user/images/'), PosixPath('/home/user/docs/report.txt'), PosixPath('/home/user/images/photo.jpg')]
- geoips.geoips_utils.output_process_times(process_datetimes, num_jobs=None, job_str='GeoIPS 2')[source]#
Calculate and print the process times from the process_datetimes dictionary.
- Parameters:
process_datetimes (dict) –
dictionary formatted as follows:
process_datetimes['overall_start']
- overall start datetime of the entire scriptprocess_datetimes['overall_end']
- overall end datetime of the entire scriptprocess_datetimes[process_name]['start']
- start time of an individual processprocess_datetimes[process_name]['end']
- end time of an individual process
- geoips.geoips_utils.remove_unsupported_kwargs(module, requested_kwargs)[source]#
Remove unsupported keyword arguments.
- geoips.geoips_utils.replace_geoips_paths(path, replace_paths=None, base_paths=None, curly_braces=False)[source]#
Replace specified sub-paths in path with related environment variable names.
This function replaces paths in the provided path with their corresponding environment variable names. This is useful for generating output paths or metadata that are independent of specific installation directories.
For example, it can replace:
'/home/user/geoproc/geoips_packages'
with'$GEOIPS_PACKAGES_DIR'
'/home/user/geoproc/geoips_outdirs'
with'$GEOIPS_OUTDIRS'
'/home/user/geoproc'
with'$GEOIPS_BASEDIR'
- Parameters:
path (str or pathlib.Path) – The path in which to replace base paths.
replace_paths (list of str, optional) –
A list of environment variable names whose corresponding paths should be replaced in path. If None, defaults to:
['$GEOIPS_OUTDIRS', '$GEOIPS_PACKAGES_DIR', '$GEOIPS_TESTDATA_DIR', '$GEOIPS_DEPENDENCIES_DIR', '$GEOIPS_BASEDIR']
base_paths (dict, optional) – A dictionary mapping environment variable names to their corresponding base paths. If None, defaults to geoips.filenames.base_paths.PATH.
curly_braces (bool, default=False) – If True, includes curly braces in the environment variables (e.g.,
'${GEOIPS_BASEDIR}'
), otherwise excludes them (e.g.,'$GEOIPS_BASEDIR'
).
- Returns:
The path with specified base paths replaced with environment variable names.
- Return type:
str
Notes
The function iterates over the provided replace_paths in reverse order (from most specific to least specific) and replaces the first matching base path in the given path with the corresponding environment variable name.
Examples
>>> path = '/home/user/geoproc/geoips_packages/module/file.py' >>> base_paths = { ... 'GEOIPS_PACKAGES_DIR': '/home/user/geoproc/geoips_packages', ... 'GEOIPS_BASEDIR': '/home/user/geoproc' ... } >>> replace_geoips_paths(path, base_paths=base_paths) '$GEOIPS_PACKAGES_DIR/module/file.py'
- geoips.geoips_utils.replace_geoips_paths_in_dict(replace_dict, replace_paths=None, base_paths=None, curly_braces=False)[source]#
Replace geoips paths in every path-based element within a dictionary.
- geoips.geoips_utils.replace_geoips_paths_in_list(replace_list, replace_paths=None, base_paths=None, curly_braces=False)[source]#
Replace GeoIPS paths with geoips settings in elements of a list.
This function iterates over each element in the provided replace_list, attempting to replace GeoIPS paths within each element using the replace_geoips_paths function. If an element raises a TypeError when cast to a pathlib path, it is skipped.
- Parameters:
replace_list (list) – A list of elements to process. Elements can be of any type, but only those that are Path-like will be processed.
replace_paths (dict, optional) – Passed to replace_geoips_paths
base_paths (dict, optional) – Passed to replace_geoips_paths
curly_braces (bool, optional) – Passed to replace_geoips_paths
- Returns:
A new list containing the elements with GeoIPS paths replaced where possible. Elements that could not be processed are included unchanged.
- Return type:
list
Examples
>>> replace_geoips_paths_in_list(['/home/geoips/data/project', ... 'no_replacement_here']) ['$GEOIPS_DATA_DIR/project', 'no_replacement_here']
See also
replace_geoips_paths
Function used to replace GeoIPS paths in individual elements.
geoips.plugin_registry module#
PluginRegistry class to interface with the JSON plugin registries.
The “geoips config create-registries” utility generates a JSON file at the top level of every geoips plugin package with a complete list of all plugins with the associated metadata (everything except the actual contents of the plugin itself).
Once all of the registered_plugins.json files have been generated via geoips config create-registries, this class uses those registries to quickly identify and open plugins as required. Previously the individual interface classes would open all plugins every time one was required, so moving this process into a single PluginRegistry object allows us to more effectively cache plugins across all interfaces, and avoid reading in all plugins multiple times.
- class geoips.plugin_registry.PluginRegistry(namespace, _test_registry_files=[])[source]#
Bases:
object
Plugin Registry class definition.
Represents all of the plugins found in all of the available GeoIPS packages. This class will load a plugin when requested, rather than loading all plugins when GeoIPS is instantiated.
- create_registries(packages=None, save_type='json') None [source]#
Create one or more plugin registry files.
By default, this command will create all plugin registry files for all installed geoips packages (geoips.plugin_packages entrypoint). If packages is provided via the argument above, create registry files associated with each of those packages.
- Parameters:
packages (list[str], default=None) –
A list of names corresponding to geoips.plugin_packges whose registries we want to create.
save_type (str, default="json") –
Format to write registries to. This will also be the file extension. Valid options are either ‘json’ or ‘yaml’.
- Raises:
ValueError: –
Raised if ‘save_type’ is provided but is not one of [‘json’, ‘yaml’]
TypeError: –
Raised if packages is provided and is not a list of strings.
PluginRegistryError: –
Raised if one or more of the packages provided is not a valid geoips.plugin_package, or if the associated namespace provided is not a valid namespace.
- delete_registries(packages=None) None [source]#
Delete one or more plugin registry files.
By default, this command will delete all plugin registry files found in all installed geoips packages (geoips.plugin_packages entrypoint). If packages is provided via the argument above, delete the registry file(s) associated with each of those packages.
- Parameters:
packages (list[str], default=None) –
A list of names corresponding to geoips.plugin_packges whose registries we want to delete.
- Raises:
TypeError: –
Raised if packages is provided and is not a list of strings.
FileNotFoundError: –
Raised if a registry file could not be found in one or more geoips.plugin_packages.
PluginRegistryError: –
Raised if one or more of the packages provided is not a valid geoips.plugin_package, or if the associated namespace provided is not a valid namespace.
- get_module_plugin(interface_obj, name, rebuild_registries=None)[source]#
Retrieve a plugin from this interface by name.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting this module plugin.
name (str) –
The name the desired plugin.
rebuild_registries (bool (default=None)) –
Whether or not to rebuild the registries if get_plugin fails. If set to None, default to what we have set in geoips.filenames.base_paths, which defaults to True. If specified, use the input value of rebuild_registries, which should be a boolean value. If rebuild registries is true and get_plugin fails, rebuild the plugin registry, call then call get_plugin once more with rebuild_registries toggled off, so it only gets rebuilt once.
- Returns:
An object of type
<interface>Plugin
where<interface>
is the name ofthis interface.
- Raises:
PluginError – If the specified plugin isn’t found within the interface.
- get_module_plugins(interface_obj)[source]#
Retrieve all module plugins for this interface.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting all plugins.
- get_plugin_metadata(interface_obj, plugin_name)[source]#
Retrieve a plugin’s metadata.
Where the metadata of the plugin matches the plugin’s corresponding entry in the plugin registry.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting plugin metadata.
plugin_name (str or tuple(str)) –
The name of the plugin whose metadata we want.
- Returns:
metadata –
A dictionary of metadata for the requested plugin.
- Return type:
dict
- get_yaml_plugin(interface_obj, name, rebuild_registries=None)[source]#
Get a YAML plugin by its name.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting this yaml plugin.
name (str or tuple(str)) –
The name of the yaml-based plugin. Either a single string or a tuple of strings for product plugins.
rebuild_registries (bool (default=None)) –
Whether or not to rebuild the registries if get_plugin fails. If set to None, default to what we have set in geoips.filenames.base_paths, which defaults to True. If specified, use the input value of rebuild_registries, which should be a boolean value. If rebuild registries is true and get_plugin fails, rebuild the plugin registry, call then call get_plugin once more with rebuild_registries toggled off, so it only gets rebuilt once.
- get_yaml_plugins(interface_obj)[source]#
Retrieve all yaml plugin objects for this interface.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting all plugins.
- property interface_mapping#
Dictionary of interface types and interfaces of that type.
GeoIPS has three types of interfaces, though only two are commonly used (yaml_based, module_based). This dictionary has top level keys of all interface types, with their values being the list of unique interfaces that inherit that type.
- property registered_module_based_plugins#
A dictionary of registered module-based plugins.
- property registered_plugins#
Dictionary of every plugin’s metadata found within self.namespace.
self.namespace usually should correspond to ‘geoips.plugin_packages’ unless you’re creating registries for plugins that exist outside this namespace.
- property registered_yaml_based_plugins#
A dictionary of registered YAML-based plugins.
- retry_get_plugin(interface_obj, name, rebuild_registries, err_str, err_type=<class 'geoips.errors.PluginError'>)[source]#
Rerun self.get_plugin, but call ‘geoips config create-registries’ beforehand.
By running ‘geoips config create-registries’, we automate the registration of plugins in GeoIPS. If the plugin persists not to be found, then we’ll raise an appropriate PluginError as denoted by ‘err_str’.
- Parameters:
interface_obj (GeoIPS Interface Object) –
The object representing the interface class requesting this plugin.
name (str or tuple(str)) –
The name of the yaml plugin. Either a single string or a tuple of strings for product plugins.
rebuild_registries (bool) –
Whether or not to rebuild the registries if get_plugin fails. If set to true and get_plugin fails, rebuild the plugin registry, call then call get_plugin once more with rebuild_registries toggled off, so it only gets rebuilt once.
err_str (string) –
The error to be reported.
err_type (Exception-based Class) –
The class of exception to be raised.
Module contents#
The Geolocated Information Processing System (GeoIPS).
GeoIPS ® Base Package#
The GeoIPS Base Package provides a Python 3 based architecture supporting a wide variety of satellite and weather data processing. The modular nature of the GeoIPS base infrastructure also allows plug-and-play capability for user-specified custom functionality.
Homepage: NRLMMD-GEOIPS/geoips