geoips.interfaces package#

Subpackages#

Submodules#

geoips.interfaces.base module#

Base classes for interfaces, plugins, and plugin validation machinery.

class geoips.interfaces.base.BaseClassInterface[source]#

Bases: BaseClassInterface

Base class for class-based interfaces.

This class should not be instantiated directly. Instead, a package should implement custom interfaces that inherit from the children of this class. Those custom interfaces would then be accessed by importing them from geoips.interfaces. For example: ` from geoips.interfaces import algorithms ` will retrieve an instance of AlgorithmsInterface which will provide access to the geoips algorithm plugins.

apiVersion = 'geoips/v1'#
class geoips.interfaces.base.BaseYamlInterface[source]#

Bases: BaseYamlInterface

Base class for GeoIPS yaml-based plugin interfaces.

This class should not be instantiated directly. Instead, interfaces should be accessed by importing them from geoips.interfaces. For example: ` from geoips.interfaces import products ` will retrieve an instance of ProductsInterface which will provide access to the GeoIPS products plugins.

apiVersion = 'geoips/v1'#
validator = <geoips.interfaces.base.YamlPluginValidator object>#
class geoips.interfaces.base.YamlPluginValidator[source]#

Bases: object

PluginValidator class.

property schemas#

Return a list of jsonschema schemas for GeoIPS.

This performs a lazy-load for the schema to avoid loading them if not needed. This reduces the import time for geoips.interfaces.

validate(plugin, validator_id=None)[source]#

Validate a YAML plugin against the relevant schema.

The relevant schema is determined based on the interface and family of the plugin.

validate_list(plugin)[source]#

Validate a list of YAML plugins.

Some interfaces allow a ‘list’ family. These list plugins will contain a property that is the same as the interface’s name. Under that is a list of individual plugins.

This function will add the interface property to each plugin in the list, then validate each plugin.

property validators#

Return schema validators.

This performs a lazy-load for the validators to avoid loading them if not needed. This reduces the import time for geoips.interfaces.

geoips.interfaces.base.get_schemas(path, validator)[source]#

Collect all of the interface schema.

geoips.interfaces.base.get_validators(schema_dict, validator_class)[source]#

Create validators for each schema in schema_dict.

Parameters:

schema_dict (dict) – A dictionary whose keys are schema $id and whose values are the full schema.

Returns:

A dictionary whose keys are schema $id and whose values are jsonschema validator instances.

Return type:

dict

geoips.interfaces.base.plugin_repr(obj)[source]#

Repr plugin string.

geoips.interfaces.class_based_plugin module#

Implements a base class for class-based plugins.

The base class implemented here would expose the call signature of the child plugin class as __call__() while also providing hooks for pre- and post-processing.

The hooks are available as _pre_call() and _post_call(). They should be used to implement common functionality that all plugins of this type should posess but which we don’t want developers to need to implement. They are intended to be overridden by the child plugin-type class (e.g. BaseReaderPlugin). They should define what kwargs they accept when defined on the plugin-type class but should accept their arguments from **kwargs from __call__().

The call() method should be overridden on the actual plugin class. It should provide the data processing for the plugin. __call__()’s signature will be identical to that of call() except that call() should not accept **kwargs. That should be consumed by the hooks.

__call__() should not be overridden anywhere.

I removed this for now, but maybe consider again later: I still need to do more research to understand the effects of ParamSpec, TypeVar, and Generic, but they are supposed to help make this class and its children interact with IDE, static analysis tools, and other type checkers correctly.

class geoips.interfaces.class_based_plugin.BaseClassPlugin(module=None)[source]#

Bases: ABC

The base class for GeoIPS class-based plugins.

All plugins are required to carry the following class attributes:

  • interface: The interface type the plugin belongs to (e.g. ‘readers’, ‘products’). This is typically provided by the interface-level plugin class and not the individual plugin class.

  • family: The family name of the plugin. This should be defined by the plugin class.

  • name: The specific name of the plugin. This should be defined by the plugin class.

Subclasses of this base class must also implement the following methods:

  • call(): The main method that performs the plugin’s functionality. This method should be implemented by the plugin class.

  • _pre_call(): A hook method that can be overridden to preprocess data before calling the main call() method. This method should accept the same arguments as call() via *args and **kwargs and should, typically, be implemented by the interface-level plugin class.

  • _post_call(): A hook method that can be overridden to post-process data after calling the main call() method. This method should accept the same arguments as call() via *args and **kwargs and should, typically, be implemented by the interface-level plugin class.

The purpose of _pre_call() and _post_call() is to allow for common functionality that all plugins of a certain type should possess, without requiring developers to implement this functionality in every plugin class. Initially, this will be used to convert inputs from DataTree to other formats and back to DataTree after processing, but it could be used for other common tasks as well.

abstract call(*args, **kwargs)[source]#

Callable method to be implemented by the plugin class.

data_tree = False#
required_attributes = ['interface', 'family', 'name']#
geoips.interfaces.class_based_plugin.valid_str_attr(cls, attr_name: str)[source]#

Check that the given attribute is a non-empty string.

Module contents#

GeoIPS interface module.