Skip to content

Enums

ResourceStatus

Bases: str, Enum

ResourceStatus is an enumeration representing the possible states that a resource may occupy within an application.

Each status is represented as a string, which provides a human-readable representation for each of the stages in the lifecycle of a resource.

Attributes:

Name Type Description
NO_STATUS str

The state of a resource that cannot have another status.

CREATED str

The state after a resource has been successfully created.

PENDING str

The state indicating that the resource is in the process of being prepared, but is not yet ready.

READY str

The state indicating that the resource has been successfully prepared and is now ready for use.

FAILED str

The state indicating that an error occurred during the creation or preparation of the resource.

Source code in src/featureform/enums.py
class ResourceStatus(str, Enum):
    """
    ResourceStatus is an enumeration representing the possible states that a
    resource may occupy within an application.

    Each status is represented as a string, which provides a human-readable
    representation for each of the stages in the lifecycle of a resource.

    Attributes:
        NO_STATUS (str): The state of a resource that cannot have another status.
        CREATED (str): The state after a resource has been successfully created.
        PENDING (str): The state indicating that the resource is in the process of being prepared, but is not yet ready.
        READY (str): The state indicating that the resource has been successfully prepared and is now ready for use.
        FAILED (str): The state indicating that an error occurred during the creation or preparation of the resource.
    """

    NO_STATUS = "NO_STATUS"
    CREATED = "CREATED"
    PENDING = "PENDING"
    READY = "READY"
    FAILED = "FAILED"

    @staticmethod
    def from_proto(proto):
        return proto.Status._enum_type.values[proto.status].name

ScalarType

Bases: Enum

ScalarType is an enum of all the scalar types supported by Featureform.

Attributes:

Name Type Description
NIL

An empty string representing no specified type.

INT

A string representing an integer type.

INT32

A string representing a 32-bit integer type.

INT64

A string representing a 64-bit integer type.

FLOAT32

A string representing a 32-bit float type.

FLOAT64

A string representing a 64-bit float type.

STRING

A string representing a string type.

BOOL

A string representing a boolean type.

DATETIME

A string representing a datetime type.

Source code in src/featureform/enums.py
class ScalarType(Enum):
    """
    ScalarType is an enum of all the scalar types supported by Featureform.

    Attributes:
        NIL: An empty string representing no specified type.
        INT: A string representing an integer type.
        INT32: A string representing a 32-bit integer type.
        INT64: A string representing a 64-bit integer type.
        FLOAT32: A string representing a 32-bit float type.
        FLOAT64: A string representing a 64-bit float type.
        STRING: A string representing a string type.
        BOOL: A string representing a boolean type.
        DATETIME: A string representing a datetime type.
    """

    NIL = ""
    INT = "int"
    INT32 = "int32"
    INT64 = "int64"
    FLOAT32 = "float32"
    FLOAT64 = "float64"
    STRING = "string"
    BOOL = "bool"
    DATETIME = "datetime"

    @classmethod
    def has_value(cls, value):
        try:
            cls(value)
            return True
        except ValueError:
            return False

    @classmethod
    def get_values(cls):
        return [e.value for e in cls]

    def to_proto(self):
        proto_enum = self.to_proto_enum()
        return pb.ValueType(scalar=proto_enum)

    def to_proto_enum(self):
        mapping = {
            ScalarType.NIL: pb.ScalarType.NULL,
            ScalarType.INT: pb.ScalarType.INT,
            ScalarType.INT32: pb.ScalarType.INT32,
            ScalarType.INT64: pb.ScalarType.INT64,
            ScalarType.FLOAT32: pb.ScalarType.FLOAT32,
            ScalarType.FLOAT64: pb.ScalarType.FLOAT64,
            ScalarType.STRING: pb.ScalarType.STRING,
            ScalarType.BOOL: pb.ScalarType.BOOL,
            ScalarType.DATETIME: pb.ScalarType.DATETIME,
        }
        return mapping[self]

    @classmethod
    def from_proto(cls, proto_val):
        mapping = {
            pb.ScalarType.NULL: ScalarType.NIL,
            pb.ScalarType.INT: ScalarType.INT,
            pb.ScalarType.INT32: ScalarType.INT32,
            pb.ScalarType.INT64: ScalarType.INT64,
            pb.ScalarType.FLOAT32: ScalarType.FLOAT32,
            pb.ScalarType.FLOAT64: ScalarType.FLOAT64,
            pb.ScalarType.STRING: ScalarType.STRING,
            pb.ScalarType.BOOL: ScalarType.BOOL,
            pb.ScalarType.DATETIME: ScalarType.DATETIME,
        }
        return mapping[proto_val]