cmipcite.tracking_id#
Handling of tracking IDs
Classes:
| Name | Description |
|---|---|
MultiDatasetHandlingStrategy |
Strategy for handling the case when a tracking ID appears in multiple datasets |
MultipleDatasetMemberError |
Raised to indicate that a tracking ID is associated with multiple datasets i.e. PIDs |
Functions:
| Name | Description |
|---|---|
get_dataset_pid |
Get dataset PID to which a given tracking ID belongs |
get_dataset_pids |
Get the PID(s) of the dataset(s) with which a tracking ID is associated |
MultiDatasetHandlingStrategy #
Bases: StrEnum
Strategy for handling the case when a tracking ID appears in multiple datasets
In other words, is associated with more than one dataset PID
Attributes:
| Name | Type | Description |
|---|---|---|
FIRST |
Get the PID for the first dataset |
|
LATEST |
Get the PID for the latest dataset |
Source code in src/cmipcite/tracking_id.py
MultipleDatasetMemberError #
Bases: KeyError
Raised to indicate that a tracking ID is associated with multiple datasets i.e. PIDs
Usually only raised if no strategy for handling such a clash is given.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialise the error |
Source code in src/cmipcite/tracking_id.py
__init__ #
Initialise the error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracking_id
|
str
|
Tracking ID |
required |
version_pids
|
dict[str, str]
|
Version strings and associated PIDs with which |
required |
Source code in src/cmipcite/tracking_id.py
get_dataset_pid #
get_dataset_pid(
tracking_id: str,
multi_dataset_handling: MultiDatasetHandlingStrategy
| None = None,
client: RESTHandleClient | None = None,
) -> str
Get dataset PID to which a given tracking ID belongs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracking_id
|
str
|
Tracking ID |
required |
multi_dataset_handling
|
MultiDatasetHandlingStrategy | None
|
What to do in the case that the tracking ID belongs to multiple datasets i.e. is associated with more than one PID. If not supplied, an error is raised if |
None
|
client
|
RESTHandleClient | None
|
Client to use for interacting with pyhandle's REST API If not supplied, a new client with a default handle server URL is instantiated. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
|
Raises:
| Type | Description |
|---|---|
MultipleDatasetMemberError
|
|
Source code in src/cmipcite/tracking_id.py
get_dataset_pids #
Get the PID(s) of the dataset(s) with which a tracking ID is associated
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracking_id
|
str
|
Tracking ID for which to get associated PIDs |
required |
client
|
RESTHandleClient | None
|
Client to use for interacting with pyhandle's REST API If not supplied, a new client with a default handle server URL is instantiated. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
PID(s) of the dataset(s) with which |