Skip to content

etils.etils

EasyDeLGradientCheckPointers dataclass

The code snippet is defining a data class called EasyDeLGradientCheckPointers using the @dataclass decorator. A data class is a class that is primarily used to store data, and it automatically generates special methods such as __init__, __repr__, and __eq__ based on the class attributes.

Source code in src/python/easydel/etils/etils.py
34
35
36
37
38
39
40
41
42
43
44
45
46
@dataclass
class EasyDeLGradientCheckPointers:
    """
    The code snippet is defining a data class called `EasyDeLGradientCheckPointers` using the `@dataclass`
    decorator. A data class is a class that is primarily used to store data, and it automatically
    generates special methods such as `__init__`, `__repr__`, and `__eq__` based on the class
    attributes.
    """
    EVERYTHING_SAVEABLE: Literal["everything_saveable"] = "everything_saveable"  # Fix Pycharm Debugging Issue
    NOTHING_SAVEABLE: Literal["nothing_saveable"] = "nothing_saveable"  # Fix Pycharm Debugging Issue
    CHECKPOINT_DOTS: Literal["checkpoint_dots"] = "checkpoint_dots"  # Fix Pycharm Debugging Issue
    CHECKPOINT_DOTS_WITH_NO_BATCH_DMIS: Literal["checkpoint_dots_with_no_batch_dims"] = \
        "checkpoint_dots_with_no_batch_dims"  # Fix Pycharm Debugging Issue

EasyDeLOptimizers dataclass

The code snippet is defining a data class called EasyDeLOptimizers using the @dataclass decorator. A data class is a class that is primarily used to store data, and it automatically generates special methods such as __init__, __repr__, and __eq__ based on the class attributes.

Source code in src/python/easydel/etils/etils.py
 6
 7
 8
 9
10
11
12
13
14
15
16
@dataclass
class EasyDeLOptimizers:
    """
    The code snippet is defining a data class called `EasyDeLOptimizers` using the `@dataclass`
    decorator. A data class is a class that is primarily used to store data, and it automatically
    generates special methods such as `__init__`, `__repr__`, and `__eq__` based on the class
    attributes.
    """
    ADAFACTOR: Literal["adafactor"] = "adafactor"  # Fix Pycharm Debugging Issue
    LION: Literal["lion"] = "lion"  # Fix Pycharm Debugging Issue
    ADAMW: Literal["adamw"] = 'adamw'  # Fix Pycharm Debugging Issue

EasyDeLSchedulers dataclass

The code snippet is defining a data class called EasyDeLSchedulers using the @dataclass decorator. A data class is a class that is primarily used to store data, and it automatically generates special methods such as __init__, __repr__, and __eq__ based on the class attributes.

Source code in src/python/easydel/etils/etils.py
19
20
21
22
23
24
25
26
27
28
29
30
31
@dataclass
class EasyDeLSchedulers:
    """
    The code snippet is defining a data class called `EasyDeLSchedulers` using the `@dataclass`
    decorator. A data class is a class that is primarily used to store data, and it automatically
    generates special methods such as `__init__`, `__repr__`, and `__eq__` based on the class
    attributes.
    """
    LINEAR: Literal["linear"] = "linear"  # Fix Pycharm Debugging Issue
    COSINE: Literal["cosine"] = "cosine"  # Fix Pycharm Debugging Issue
    NONE: Literal["none"] = "none"  # Fix Pycharm Debugging Issue
    WARM_UP_COSINE: Literal["warm_up_cosine"] = "warm_up_cosine"  # Fix Pycharm Debugging Issue
    WARM_UP_LINEAR: Literal["warm_up_linear"] = "warm_up_linear"  # Fix Pycharm Debugging Issue

get_logger(name, level=logging.INFO)

Function to create and configure a logger.

Parameters:

Name Type Description Default
name

str: The name of the logger.

required
level int

int: The logging level. Defaults to logging.INFO.

INFO

Returns:

Type Description
Logger

The configured logger instance.

Source code in src/python/easydel/etils/etils.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def get_logger(name, level: int = logging.INFO) -> logging.Logger:
    """
    Function to create and configure a logger.
    :param name: str: The name of the logger.
    :param level: int: The logging level. Defaults to logging.INFO.
    :return logging.Logger: The configured logger instance.
    """
    logger = logging.getLogger(name)
    logger.propagate = False

    # Set the logging level
    logger.setLevel(level)

    # Create a console handler
    console_handler = logging.StreamHandler()
    console_handler.setLevel(level)

    formatter = logging.Formatter("%(asctime)s %(levelname)-8s [%(name)s] %(message)s")
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)
    return logger

set_loggers_level(level=logging.WARNING)

Function to set the logging level of all loggers to the specified level.

Parameters:

Name Type Description Default
level int

int: The logging level to set. Defaults to logging.WARNING.

WARNING
Source code in src/python/easydel/etils/etils.py
 94
 95
 96
 97
 98
 99
100
101
def set_loggers_level(level: int = logging.WARNING):
    """
    Function to set the logging level of all loggers to the specified level.
    :param level: int: The logging level to set. Defaults to logging.WARNING.
    """
    logging.root.setLevel(level)
    for handler in logging.root.handlers:
        handler.setLevel(level)