Unique IDs¶
Models for handling unique identifiers.
UniqueID ¶
UniqueID(*args, **kwargs)
Bases: str, PydanticStrMixin
An augmented str class intended to represent a unique ID type
Validate that the string is a valid UUID4.
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the string is not a valid UUID4. |
Source code in src/aibs_informatics_core/models/unique_ids.py
20 21 22 23 24 25 26 27 28 29 30 | |
as_uuid ¶
as_uuid()
Return the underlying UUID object.
Source code in src/aibs_informatics_core/models/unique_ids.py
44 45 46 | |
create
classmethod
¶
create(seed=None)
Create a new UniqueID, optionally seeded for deterministic generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int | str | None
|
Optional seed value. If provided, generates a deterministic UUID. |
None
|
Returns:
| Type | Description |
|---|---|
UNIQUE_ID_TYPE
|
A new UniqueID instance. |
Source code in src/aibs_informatics_core/models/unique_ids.py
32 33 34 35 36 37 38 39 40 41 42 | |
from_env
classmethod
¶
from_env()
Load a UniqueID from environment variables.
Checks the environment variables listed in ENV_VARS.
Returns:
| Type | Description |
|---|---|
UNIQUE_ID_TYPE
|
A UniqueID loaded from the environment. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no matching environment variable is found. |
Source code in src/aibs_informatics_core/models/unique_ids.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |