Types
zenml.types
Custom ZenML types.
Attributes
HookSpecification = Union[str, Source, FunctionType, Callable[..., None]]
module-attribute
Classes
CSVString
Bases: str
Special string class to indicate a CSV string.
HTMLString
Bases: str
Special string class to indicate an HTML string.
JSONString
Bases: str
Special string class to indicate a JSON string.
MarkdownString
Bases: str
Special string class to indicate a Markdown string.
Source
Bases: BaseModel
Source specification.
A source specifies a module name as well as an optional attribute of that module. These values can be used to import the module and get the value of the attribute inside the module.
Example
The source Source(module="zenml.config.source", attribute="Source")
references the class that this docstring is describing. This class is
defined in the zenml.config.source
module and the name of the
attribute is the class name Source
.
Attributes:
Name | Type | Description |
---|---|---|
module |
str
|
The module name. |
attribute |
Optional[str]
|
Optional name of the attribute inside the module. |
type |
SourceType
|
The type of the source. |
Attributes
import_path: str
property
The import path of the source.
Returns:
Type | Description |
---|---|
str
|
The import path of the source. |
is_internal: bool
property
If the source is internal (=from the zenml package).
Returns:
Type | Description |
---|---|
bool
|
True if the source is internal, False otherwise |
is_module_source: bool
property
If the source is a module source.
Returns:
Type | Description |
---|---|
bool
|
If the source is a module source. |
Functions
from_import_path(import_path: str, is_module_path: bool = False) -> Source
classmethod
Creates a source from an import path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
import_path
|
str
|
The import path. |
required |
is_module_path
|
bool
|
If the import path points to a module or not. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If the import path is empty. |
Returns:
Type | Description |
---|---|
Source
|
The source. |
Source code in src/zenml/config/source.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
model_dump(**kwargs: Any) -> Dict[str, Any]
Dump the source as a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The source as a dictionary. |
Source code in src/zenml/config/source.py
143 144 145 146 147 148 149 150 151 152 |
|
model_dump_json(**kwargs: Any) -> str
Dump the source as a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
str
|
The source as a JSON string. |
Source code in src/zenml/config/source.py
154 155 156 157 158 159 160 161 162 163 |
|