climate_ref.provider_registry
#
Registry of the currently active providers in the REF
This module provides a registry for the currently active providers. Often, we can't directly import a provider and it's diagnostics as each provider maintains its own virtual environment to avoid dependency conflicts.
For remote providers, a proxy is used to access the metadata associated with the diagnostics. These diagnostics cannot be run locally, but can be executed using other executors.
ProviderRegistry
#
Registry for the currently active providers
In some cases we can't directly import a provider and it's diagnostics, in this case we need to proxy the diagnostics.
Source code in packages/climate-ref/src/climate_ref/provider_registry.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
build_from_config(config, db)
staticmethod
#
Create a ProviderRegistry instance using information from the database
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Configuration object |
required |
db
|
Database
|
Database instance |
required |
Returns:
| Type | Description |
|---|---|
ProviderRegistry
|
A new ProviderRegistry instance |
Source code in packages/climate-ref/src/climate_ref/provider_registry.py
get(slug)
#
Retrieve a provider by name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slug
|
str
|
Slug of the provider of interest |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
A provider with the matching slug has not been registered |
Returns:
| Type | Description |
|---|---|
The requested provider
|
|
Source code in packages/climate-ref/src/climate_ref/provider_registry.py
get_metric(provider_slug, diagnostic_slug)
#
Retrieve a diagnostic by name
This is a convenience method to retrieve a diagnostic from a provider
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_slug
|
str
|
Slug of the provider of interest |
required |
diagnostic_slug
|
str
|
Slug of the diagnostic of interest |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the provider/diagnostic with the given slugs is not found. |
Returns:
| Type | Description |
|---|---|
The requested diagnostic.
|
|