kedro.utils¶
kedro.utils ¶
This module provides a set of helper functions being used across different components of kedro package.
| Name | Type | Description |
|---|---|---|
find_kedro_project |
Function | Given a path, find a Kedro project associated with it. |
is_kedro_project |
Function | Evaluate if a given path is a root directory of a Kedro project or not. |
load_obj |
Function | Extract an object from a given path. |
experimental |
Decorator | Decorator to mark a function or class as experimental. |
KedroExperimentalWarning |
UserWarning | Warning raised when using an experimental Kedro feature. |
kedro.utils.find_kedro_project ¶
find_kedro_project(current_dir)
Given a path, find a Kedro project associated with it.
Can be
- Itself, if a path is a root directory of a Kedro project.
- One of its parents, if self is not a Kedro project but one of the parent path is.
- None, if neither self nor any parent path is a Kedro project.
Returns:
-
Any–Kedro project associated with a given path,
-
Any–or None if no relevant Kedro project is found.
Source code in kedro/utils.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
kedro.utils.is_kedro_project ¶
is_kedro_project(project_path)
Evaluate if a given path is a root directory of a Kedro project or not.
Parameters:
-
project_path(str | Path) –Path to be tested for being a root of a Kedro project.
Returns:
-
bool–True if a given path is a root directory of a Kedro project, otherwise False.
Source code in kedro/utils.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
kedro.utils.load_obj ¶
load_obj(obj_path, default_obj_path='')
Extract an object from a given path.
Parameters:
-
obj_path(str) –Path to an object to be extracted, including the object name.
-
default_obj_path(str, default:'') –Default object path.
Returns:
-
Any–Extracted object.
Raises:
-
AttributeError–When the object does not have the given named attribute.
Source code in kedro/utils.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
kedro.utils.KedroExperimentalWarning ¶
Bases: UserWarning
Warning raised when using an experimental Kedro feature.
kedro.utils.experimental ¶
experimental(obj)
Mark a function or class as experimental.
Emits a KedroExperimentalWarning when invoked (for functions) or
instantiated (for classes). The original API remains fully usable.
Parameters:
-
obj(Callable | type) –The function or class to wrap.
Returns:
-
Callable | type–A wrapped version of the object that emits warnings on use.
Example:
@experimental
def sample_func(a, b):
return a + b
@experimental
class SampleClass:
def __init__(self, x):
self.x = x
Source code in kedro/utils.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |