simet.parser.provider¶
simet.parser.provider ¶
ProviderParser ¶
Factory wrapper that builds concrete providers from a config dict.
Parses a ProviderSchema from a plain mapping (e.g., YAML/JSON) and
delegates construction to :meth:ProviderType.get_provider.
parse_provider
staticmethod
¶
parse_provider(provider_data)
Parse provider config and return a concrete Provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_data
|
dict
|
Mapping that must match |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Provider |
Provider
|
An instance of the requested provider. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the |
Example
cfg = {"type": "LocalProviderWithoutClass", "path": "data/unlabeled"} p = ProviderParser.parse_provider(cfg) p.class.name 'LocalProviderWithoutClass'
Source code in simet/parser/provider.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
ProviderType ¶
Bases: StrEnum
Enum of supported providers (string-valued).
get_provider
staticmethod
¶
get_provider(provider_schema)
Construct a Provider from a validated ProviderSchema.
Converts the path to a Path and instantiates the provider indicated
by provider_schema.type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_schema
|
ProviderSchema
|
Validated schema with |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Provider |
Provider
|
Concrete provider instance:
- |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
- Local providers expect
pathto exist on disk; validation occurs when theirget_data(...)is called. CIFARProviderwill download the dataset intopathif missing.
Source code in simet/parser/provider.py
56 57 58 59 60 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 | |