flytekit.core.utils
| Class |
Description |
AutoDeletingTempDir |
Creates a posix safe tempdir which is auto deleted once out of scope. |
ClassDecorator |
Abstract class for class decorators. |
Directory |
|
timeit |
A context manager and a decorator that measures the execution time of the wrapped code block or functions. |
| Property |
Type |
Description |
TYPE_CHECKING |
bool |
|
def has_return_statement(
func: typing.Callable,
) -> bool
| Parameter |
Type |
Description |
func |
typing.Callable |
|
def load_proto_from_file(
pb2_type,
path,
)
| Parameter |
Type |
Description |
pb2_type |
|
|
path |
|
|
def str2bool(
value: typing.Optional[str],
) -> bool
Convert a string to a boolean. This is useful for parsing environment variables.
| Parameter |
Type |
Description |
value |
typing.Optional[str] |
The string to convert to a boolean |
Returns: the boolean value
def write_proto_to_file(
proto,
path,
)
| Parameter |
Type |
Description |
proto |
|
|
path |
|
|
Creates a posix safe tempdir which is auto deleted once out of scope
class AutoDeletingTempDir(
working_dir_prefix = None,
tmp_dir = None,
cleanup = True,
)
| Parameter |
Type |
Description |
working_dir_prefix |
|
|
tmp_dir |
|
|
cleanup |
|
|
| Property |
Type |
Description |
name |
None |
|
def get_named_tempfile(
name,
)
| Parameter |
Type |
Description |
name |
|
|
The list of absolute filepaths for all immediate sub-paths
Returns: list[Text]
Abstract class for class decorators.
We can attach config on the decorator class and use it in the upper level.
class ClassDecorator(
task_function = None,
**kwargs,
)
If the decorator is called with arguments, func will be None.
If the decorator is called without arguments, func will be function to be decorated.
| Parameter |
Type |
Description |
task_function |
|
|
**kwargs |
|
|
| Method |
Description |
execute() |
This method will be called when the decorated function is called. |
get_extra_config() |
Get the config of the decorator. |
def execute(
*args,
**kwargs,
)
This method will be called when the decorated function is called.
| Parameter |
Type |
Description |
*args |
|
|
**kwargs |
|
|
Get the config of the decorator.
| Parameter |
Type |
Description |
path |
|
|
| Property |
Type |
Description |
name |
None |
|
| Method |
Description |
list_dir() |
The list of absolute filepaths for all immediate sub-paths. |
The list of absolute filepaths for all immediate sub-paths
Returns: list[Text]
A context manager and a decorator that measures the execution time of the wrapped code block or functions.
It will append a timing information to TimeLineDeck. For instance:
@timeit(“Function description”)
def function()
with timeit(“Wrapped code block description”):
# your code
class timeit(
name: str = '',
)
| Parameter |
Type |
Description |
name |
str |
A string that describes the wrapped code block or function being executed. |