Types
zenml.types
Custom ZenML types.
Attributes
HookSpecification = Union[str, Source, FunctionType, Callable[..., None]]
module-attribute
InitHookSpecification = Union[str, Source, FunctionType, Callable[..., Any]]
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
convert_source(source: Any) -> Any
classmethod
Converts an old source string to a source object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
Source string or object. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The converted source. |
Source code in src/zenml/config/source.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
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
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 107 108 | |
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
145 146 147 148 149 150 151 152 153 154 | |
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
156 157 158 159 160 161 162 163 164 165 | |