Discovery
timenet_connectors.discovery ¶source
Discover connectors lazily by convention.
Each connector lives in its own folder at datasets/<org>/<name>/, or datasets/<name>/ for a
flat id. The package's __init__.py exposes a CONNECTOR class. A dataset.yaml card sits
beside it. A dataset id maps to that package by convention, so there is no central registry. Discovery
imports only the requested connector. Each connector declares its own id through metadata().
connector_dir ¶source
Return the directory of a dataset id's connector package.
Deliberately import-free. This runs before the connector's environment
exists, so importing the connector module (which is what :func:resolve
does) would fail on the very dependencies its requirements.txt
declares. find_spec imports the parent packages only, never the leaf.
A connector directory holds a dataset.yaml card. An org namespace package
(physionet) also has submodule_search_locations but no card, so it is
not a connector and is rejected like any unknown id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
A flat ( |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The connector package's directory. |
Raises:
| Type | Description |
|---|---|
LookupError
|
If no connector with a |
has_connector ¶source
Report whether a connector package exists for an id, without importing it.
Ask this instead of catching :func:connector_dir's LookupError: a miss is an ordinary
answer here, not an exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
A flat ( |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether a connector package exists for the id. |
requirements_for ¶source
Return the connector's requirements.txt, or None if it declares none.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
A flat ( |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The path to the connector's |
Raises:
| Type | Description |
|---|---|
LookupError
|
If no module exists for the id. |
resolve ¶source
resolve(dataset_id: str) -> type[BaseConnector]
Return the connector class for a dataset id and import only its module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
A flat ( |
required |
Returns:
| Type | Description |
|---|---|
type[BaseConnector]
|
The connector class. |
Raises:
| Type | Description |
|---|---|
LookupError
|
If no module exists for the id, or it exposes no |
ModuleNotFoundError
|
If a connector module for the id exists but fails to import one of its own dependencies. This surfaces the real error instead of masking it as an unknown id. |