Dataset Class API
This module defines the Dataset abstract base class, which serves as a blueprint for creating
specific types of datasets. It enforces the structure and methods that must be implemented by
derived classes.
Classes:
| Name | Description |
|---|---|
Dataset |
Represents an abstract base class for managing datasets, providing functionality to
initialize dataset names, manage optional namespaces, and enforce the |
Attributes (of Dataset):
_dataset_name (str | UUID): Stores the dataset name, derived from the class name or uuid.
_namespace (Optional[str]): An optional namespace to uniquely identify the dataset.
_name (str | UUID): Combined namespace and dataset name, or just the dataset name if no namespace is specified.
Functions:
| Name | Description |
|---|---|
__init__ |
Optional[str] = None): Initializes the dataset with an optional namespace. |
derive |
"Lair") -> None: An abstract method to be implemented by subclasses to define custom functionality. |
Dependencies
- abc (Abstract Base Classes): Used to enforce the
derivemethod. - typing: For type hints.
- UUID: A utility for handling dataset identifiers.
Dataset
Bases: ABC
Represents an abstract base class for a dataset.
This class defines the structure and required functionality for
derived classes that represent datasets. It initializes and manages
the naming and optional namespace for the dataset. Derived classes
must implement the derive method to specify their own behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
_dataset_name |
str | UUID
|
Stores the dataset name, which is either
derived from the |
_namespace |
Optional[str]
|
Optional namespace for the dataset, used to create a unique dataset name when provided. |
_name |
str | UUID
|
Fully formed name for the dataset, combining the namespace and dataset name when a namespace is provided. |
__init__
__init__(namespace: Optional[str] = None)
Initializes a class instance. This method sets up internal attributes for the dataset name and namespace. It ensures proper naming of the instance by either using the 'uuid' attribute or the class name. If a namespace is provided, it prefixes the dataset name with the namespace joined by a hyphen. This initialization ensures that duplicate instances are not created by checking for specific pre-existing attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Optional[str]
|
The namespace to be prefixed to the dataset name. If no namespace is provided, the dataset name remains unprefixed. |
None
|
derive
abstractmethod
derive(lair: Lair) -> None
Defines an abstract method for deriving behavior specific to a particular implementation of the class. This method must be overridden by subclasses to provide concrete functionality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lair
|
Lair
|
Input parameter of type "Lair" that provides the necessary context or data required for the derivation process. |
required |