Registry#

class Registry[source]#

Bases: object

A registry for resources that are built-in or contributed by plugins.

__init__()[source]#

Methods

__init__()

add_config(type_hint, config, plugin[, upgrader])

Add a Config.

add_file_system(file_system)

Add a FileSystem.

add_plugin_command(cmd)

Add a click command contributed by a plugin.

add_runner(runner_name, runner)

Add a Runner.

add_rv_config_schema(config_section, ...)

Add section of schema used by RVConfig.

discover_plugins()

Discover all raster vision plugins.

get_config(type_hint)

Get a Config class associated with a type_hint.

get_file_system(uri[, mode])

Get a FileSystem used to handle the file type of a URI.

get_plugin(type_hint)

Get module path of plugin when Config class with type_hint is defined.

get_plugin_commands()

Get the click commands contributed by plugins.

get_plugin_from_alias(alias)

get_plugin_version(plugin)

Get latest version of plugin.

get_runner(runner_name)

Return a Runner class based on its name.

get_rv_config_schema()

Return RVConfig schema.

get_type_hint_lineage(type_hint)

Get the lineage for a type hint.

get_upgrader(type_hint)

Get function that upgrades config dicts for type_hint.

load_builtins()

Add all builtin resources.

load_plugins([plugin_names])

Load plugins and register their resources.

register_renamed_type_hints(type_hint_old, ...)

Register renamed type_hints.

set_plugin_aliases(plugin, aliases)

set_plugin_version(plugin, version)

Set the latest version of a plugin.

update_config_info()

__init__()[source]#
add_config(type_hint: str, config: type['Config'], plugin: str, upgrader=None)[source]#

Add a Config.

Parameters:
  • type_hint (str) – the type hint used for deserialization of dict to an instance of config

  • config (type['Config']) – Config class

  • plugin (str) –

add_file_system(file_system: FileSystem)[source]#

Add a FileSystem.

Parameters:

file_system (FileSystem) – the FileSystem class to add

add_plugin_command(cmd: Command)[source]#

Add a click command contributed by a plugin.

Parameters:

cmd (Command) –

add_runner(runner_name: str, runner: type['Runner'])[source]#

Add a Runner.

Parameters:
  • runner_name (str) – the name of the runner that is passed to the CLI

  • runner (type['Runner']) – the Runner class

add_rv_config_schema(config_section: str, config_fields: list[str])[source]#

Add section of schema used by RVConfig.

Parameters:
  • config_section (str) – name of section

  • config_fields (list[str]) – list of field names within section

discover_plugins()[source]#

Discover all raster vision plugins.

get_config(type_hint: str) type['Config'][source]#

Get a Config class associated with a type_hint.

Parameters:

type_hint (str) –

Return type:

type[‘Config’]

get_file_system(uri: str, mode: str = 'r') type['FileSystem'][source]#

Get a FileSystem used to handle the file type of a URI.

Parameters:
  • uri (str) – a URI to be opened by a registered FileSystem

  • mode (str) – mode for opening file (eg. r or w)

Returns:

the first FileSystem class which can handle opening the uri

Return type:

type[‘FileSystem’]

get_plugin(type_hint: str) str[source]#

Get module path of plugin when Config class with type_hint is defined.

Parameters:

type_hint (str) –

Return type:

str

get_plugin_commands() list[click.core.Command][source]#

Get the click commands contributed by plugins.

Return type:

list[click.core.Command]

get_plugin_from_alias(alias: str) str | None[source]#
Parameters:

alias (str) –

Return type:

str | None

get_plugin_version(plugin: str) int[source]#

Get latest version of plugin.

Parameters:

plugin (str) – the module path of the plugin

Return type:

int

get_runner(runner_name: str) type['Runner'][source]#

Return a Runner class based on its name.

Parameters:

runner_name (str) –

Return type:

type[‘Runner’]

get_rv_config_schema()[source]#

Return RVConfig schema.

get_type_hint_lineage(type_hint: str) list[str][source]#

Get the lineage for a type hint.

Returns:

List of type hints of all Config classes in the subclass is-a “lineage” from Config to the class with type hint type_hint.

Parameters:

type_hint (str) –

Return type:

list[str]

get_upgrader(type_hint: str) collections.abc.Callable[[dict, int], dict] | None[source]#

Get function that upgrades config dicts for type_hint.

Parameters:

type_hint (str) –

Return type:

collections.abc.Callable[[dict, int], dict] | None

load_builtins()[source]#

Add all builtin resources.

load_plugins(plugin_names: Optional[Iterable[str]] = None) None[source]#

Load plugins and register their resources.

Import each Python module within the rastervision namespace package and call the register_plugin function at its root (if it exists).

Parameters:

plugin_names (Optional[Iterable[str]]) –

Return type:

None

register_renamed_type_hints(type_hint_old: str, type_hint_new: str)[source]#

Register renamed type_hints.

Parameters:
  • type_hint_old (str) – Old type hint.

  • type_hint_new (str) – New type hint.

set_plugin_aliases(plugin: str, aliases: list[str])[source]#
Parameters:
set_plugin_version(plugin: str, version: int)[source]#

Set the latest version of a plugin.

Parameters:
  • plugin (str) – module path of plugin (eg. rastervision.core)

  • version (int) – a non-negative integer version number that should be incremented each time a config schema changes

update_config_info()[source]#