| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 07f473a commit be6fa17
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,137 @@ | |||
| 1 | + from pydantic import BaseModel | ||
| 2 | + from typing import Dict, Optional, List, Union | ||
| 3 | + import json | ||
| 4 | + from enum import Enum | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + class ValueType(Enum): | ||
| 8 | + """ | ||
| 9 | + Type of the feature. | ||
| 10 | + """ | ||
| 11 | + INT = "int" | ||
| 12 | + LONG = "long" | ||
| 13 | + FLOAT = "float" | ||
| 14 | + DOUBLE = "double" | ||
| 15 | + STRING = "string" | ||
| 16 | + BOOLEAN = "boolean" | ||
| 17 | + BYTES = "bytes" | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + class DimensionType(Enum): | ||
| 21 | + """ | ||
| 22 | + Supported dimension types for tensors in Feathr. | ||
| 23 | + """ | ||
| 24 | + INT = "int" | ||
| 25 | + LONG = "long" | ||
| 26 | + STRING = "string" | ||
| 27 | + BOOLEAN = "boolean" | ||
| 28 | + BYTES = "bytes" | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + class TensorCategory(Enum): | ||
| 32 | + """ | ||
| 33 | + Supported Tensor categories in Feathr. | ||
| 34 | + """ | ||
| 35 | + DENSE = "dense" # Dense tensors store values in a contiguous sequential block of memory where all values are represented. | ||
| 36 | + SPARSE = "sparse" # Sparse tensor represents a dataset in which most of the entries are zero. | ||
| 37 | + RAGGED = "ragged" # Ragged tensors (also known as nested tensors) are similar to dense tensors but have variable-length dimensions. | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + class FeatureValueType(Enum): | ||
| 41 | + """ | ||
| 42 | + The high level types associated with a feature. | ||
| 43 | + This represents the high level semantic types supported by early versions of Frame. | ||
| 44 | + """ | ||
| 45 | + BOOLEAN = "boolean" # Boolean valued feature | ||
| 46 | + NUMERIC = "numeric" # Numerically valued feature | ||
| 47 | + CATEGORICAL = "categorical" # Represent a feature that consists of a single category | ||
| 48 | + CATEGORICAL_SET = "categorical_set" # Represent a feature that consists of multiple categories | ||
| 49 | + DENSE_VECTOR = "dense_vector" # Represent a feature in vector format where the majority of the elements are non-zero | ||
| 50 | + TERM_VECTOR = "term_vector" # Represent features that has string terms and numeric value | ||
| 51 | + TENSOR = "tensor" # Represent tensor based features. | ||
| 52 | + UNSPECIFIED = "unspecified" # Placeholder for when no types are specified | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + class Dimension(BaseModel): | ||
| 56 | + """ | ||
| 57 | + Tensor is used to represent feature data. A tensor is a generalization of vectors and matrices to potentially higher dimensions. | ||
| 58 | + """ | ||
| 59 | + type: DimensionType # Type of the dimension in the tensor. Each dimension can have a different type. | ||
| 60 | + shape: Optional[int] # Size of the dimension in the tensor. If unset, it means the size is unknown and actual size will be determined at runtime. | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + class TensorFeatureFormat(BaseModel): | ||
| 64 | + """ | ||
| 65 | + Defines the format of feature data. Feature data is produced by applying transformation on source, in a Feature. | ||
| 66 | + Tensor is used to represent feature data. A tensor is a generalization of vectors and matrices to potentially | ||
| 67 | + higher dimensions. | ||
| 68 | + """ | ||
| 69 | + tensorCategory: TensorCategory # Type of the tensor. | ||
| 70 | + valueType: ValueType # Type of the value column. | ||
| 71 | + dimensions: List[Dimension] # A feature data can have zero or more dimensions (columns that represent keys). | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + class FeatureType(BaseModel): | ||
| 75 | + """ | ||
| 76 | + Information about a featureName. It defines the type, format and default value. | ||
| 77 | + Tensor is the next generation representation of the features, so using | ||
| 78 | + Tensor type w TensorFeatureFormat would be preferable FeatureType. | ||
| 79 | + """ | ||
| 80 | + type: FeatureValueType # Defines the high level semantic type of feature. | ||
| 81 | + format: Optional[TensorFeatureFormat] # Defines the format of feature data. | ||
| 82 | + defaultValue: Union[bool, int, float, str, bytes] | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + class Clazz(BaseModel): | ||
| 86 | + """ | ||
| 87 | + Reference to a class by fully-qualified name | ||
| 88 | + """ | ||
| 89 | + fullyQualifiedName: str # A fully-qualified class name including paths. | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + class Function(BaseModel): | ||
| 93 | + """ | ||
| 94 | + Base model for all functions | ||
| 95 | + """ | ||
| 96 | + expression: str # Expression in str format | ||
| 97 | + functionType: str # Type of function in str format, will be used in UI | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + class MvelExpression(Function): | ||
| 101 | + """ | ||
| 102 | + An expression in MVEL language. | ||
| 103 | + """ | ||
| 104 | + mvel: str # The MVEL expression | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + class UserDefinedFunction(Function): | ||
| 108 | + """ | ||
| 109 | + User defined function that can be used in feature extraction or derivation. | ||
| 110 | + """ | ||
| 111 | + clazz: Clazz # Reference to the class that implements the user defined function. | ||
| 112 | + parameters: Dict[str, json] = {} # This field defines the custom parameters of the user defined function | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + class SparkSqlExpression(Function): | ||
| 116 | + """ | ||
| 117 | + An expression in Spark SQL. | ||
| 118 | + """ | ||
| 119 | + sql: str # Spark SQl expression | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + class SemanticVersion(BaseModel): | ||
| 123 | + """ | ||
| 124 | + A representation of a semantic version (see https://semver.org/) | ||
| 125 | + """ | ||
| 126 | + majorVersion: int # The major version of this version. This is the x in x.y.z. | ||
| 127 | + minorVersion: int # The minor version of this version. This is the y in x.y.z | ||
| 128 | + patchVersion: int # The patch version of this version. This is the z in x.y.z | ||
| 129 | + metadata: Optional[str] # Optional build metadata attached to this version. | ||
| 130 | + | ||
| 131 | + | ||
| 132 | + class FeathrModel(BaseModel): | ||
| 133 | + """ | ||
| 134 | + Base model for feathr entity which will be displayed in Feathr UI | ||
| 135 | + """ | ||
| 136 | + displayName: str # name of the entity showed on UI | ||
| 137 | + typeName: str # type of entity in str format, will be displayed in UI | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,37 +6,194 @@ This file defines abstract backend data models diagram for feature registry. | |||
| 6 | 6 | ||
| 7 | 7 | ```mermaid | |
| 8 | 8 | classDiagram | |
| 9 | - Project "1" --> "n" FeatureName : contains | ||
| 10 | - Project "1" --> "n" Anchor : contains | ||
| 11 | - FeatureName "1" --> "n" Feature : contains | ||
| 12 | - Anchor "1" --> "n" Feature : contains | ||
| 13 | - Feature <|-- AnchorFeature : extends | ||
| 9 | + Project "1" --> "n" FeatureName: contains | ||
| 10 | + Project "1" --> "n" Anchor: contains | ||
| 11 | + FeatureName "1" --> "n" Feature: contains | ||
| 12 | + FeatureName --> "Optional" SemanticVersion: contains | ||
| 13 | + FeatureName --> "Optional" FeatureType: contains | ||
| 14 | + Anchor "1" --> "n" AnchorFeature: contains | ||
| 15 | + Anchor --> DataSource: contains | ||
| 16 | + Feature <|-- AnchorFeature: extends | ||
| 14 | 17 | Feature <|-- DerivedFeature: extends | |
| 15 | - Feature --> Transformation | ||
| 16 | - Feature --> Transformation : contains | ||
| 18 | + Feature --> Transformation: contains | ||
| 19 | + Feature --> Source: contains | ||
| 20 | + Transformation --> Function: contains | ||
| 17 | 21 | Source <|-- DataSource: extends | |
| 22 | + DataSource --> "Optional" Clazz: contains | ||
| 23 | + DataSource --> "Optional" Function: contains | ||
| 18 | 24 | Source <|-- MultiFeatureSource: extends | |
| 19 | 25 | MultiFeatureSource "1" --> "1..n" FeatureSource: contains | |
| 20 | - AnchorFeature --> DataSource : contains | ||
| 26 | + AnchorFeature --> DataSource: contains | ||
| 21 | 27 | DerivedFeature --> MultiFeatureSource: contains | |
| 22 | - | ||
| 28 | + FeathrModel <|-- Project: extends | ||
| 29 | + FeathrModel <|-- FeatureName: extends | ||
| 30 | + FeathrModel <|-- Anchor: extends | ||
| 31 | + FeathrModel <|-- Feature: extends | ||
| 32 | + FeathrModel <|-- Source: extends | ||
| 33 | + Dimension --> DimensionType: contains | ||
| 34 | + TensorFeatureFormat --> TensorCategory: contains | ||
| 35 | + TensorFeatureFormat --> ValueType: contains | ||
| 36 | + TensorFeatureFormat "1" --> "1..n" Dimension: contains | ||
| 37 | + FeatureType --> FeatureValueType: contains | ||
| 38 | + FeatureType --> "Optional" TensorFeatureFormat: contains | ||
| 39 | + Window --> WindowTimeUnit: contains | ||
| 40 | + Function <|-- MvelExpression: extends | ||
| 41 | + Function <|-- UserDefinedFunction: extends | ||
| 42 | + Function <|-- SparkSqlExpression: extends | ||
| 43 | + SlidingWindowAggregation --> SparkSqlExpression: contains | ||
| 44 | + SlidingWindowAggregation --> SlidingWindowAggregationType: contains | ||
| 45 | + SlidingWindowAggregation --> Window: contains | ||
| 46 | + SlidingWindowEmbeddingAggregation --> SparkSqlExpression: contains | ||
| 47 | + SlidingWindowEmbeddingAggregation --> SlidingWindowEmbeddingAggregationType: contains | ||
| 48 | + SlidingWindowEmbeddingAggregation --> Window: contains | ||
| 49 | + SlidingWindowLatestAvailable --> SparkSqlExpression: contains | ||
| 50 | + SlidingWindowLatestAvailable --> Window: contains | ||
| 51 | + Function <|-- SlidingWindowAggregation: extends | ||
| 52 | + Function <|-- SlidingWindowEmbeddingAggregation: extends | ||
| 53 | + Function <|-- SlidingWindowLatestAvailable: extends | ||
| 54 | + | ||
| 55 | + class ValueType{ | ||
| 56 | + <<enumeration>> | ||
| 57 | + INT | ||
| 58 | + LONG | ||
| 59 | + FLOAT | ||
| 60 | + DOUBLE | ||
| 61 | + STRING | ||
| 62 | + BOOLEAN | ||
| 63 | + BYTES | ||
| 64 | + } | ||
| 65 | + class DimensionType{ | ||
| 66 | + <<enumeration>> | ||
| 67 | + INT | ||
| 68 | + LONG | ||
| 69 | + STRING | ||
| 70 | + BOOLEAN | ||
| 71 | + BYTES | ||
| 72 | + } | ||
| 73 | + class TensorCategory{ | ||
| 74 | + <<enumeration>> | ||
| 75 | + DENSE | ||
| 76 | + SPARSE | ||
| 77 | + RAGGED | ||
| 78 | + } | ||
| 79 | + class FeatureValueType{ | ||
| 80 | + <<enumeration>> | ||
| 81 | + BOOLEAN | ||
| 82 | + NUMERIC | ||
| 83 | + CATEGORICAL | ||
| 84 | + CATEGORICAL_SET | ||
| 85 | + DENSE_VECTOR | ||
| 86 | + TERM_VECTOR | ||
| 87 | + TENSOR | ||
| 88 | + UNSPECIFIED | ||
| 89 | + } | ||
| 90 | + class Dimension{ | ||
| 91 | + +DimensionType type | ||
| 92 | + +Optional[str] shape | ||
| 93 | + } | ||
| 94 | + class TensorFeatureFormat{ | ||
| 95 | + +TensorCategory tensorCategory | ||
| 96 | + +ValueType valueType | ||
| 97 | + +List[Dimension] dimensions | ||
| 98 | + } | ||
| 99 | + class FeatureType{ | ||
| 100 | + +FeatureValueType type | ||
| 101 | + +Optional[TensorFeatureFormat] format | ||
| 102 | + +Union[bool, int, float, str, types] defaultValue | ||
| 103 | + } | ||
| 104 | + class Clazz{ | ||
| 105 | + +str fullyQualifiedName | ||
| 106 | + } | ||
| 107 | + class Function{ | ||
| 108 | + +str expression | ||
| 109 | + } | ||
| 110 | + class MvelExpression{ | ||
| 111 | + +str mvel | ||
| 112 | + } | ||
| 113 | + class UserDefinedFunction{ | ||
| 114 | + +str sql | ||
| 115 | + } | ||
| 116 | + class SemanticVersion{ | ||
| 117 | + +int majorVersion | ||
| 118 | + +int minorVersion | ||
| 119 | + +int patchVersion | ||
| 120 | + +Optional[str] metadata | ||
| 121 | + } | ||
| 122 | + class FeathrModel{ | ||
| 123 | + +str displayName | ||
| 124 | + +str typeName | ||
| 125 | + } | ||
| 126 | + class SlidingWindowAggregationType{ | ||
| 127 | + <<enumeration>> | ||
| 128 | + SUM | ||
| 129 | + COUNT | ||
| 130 | + MAX | ||
| 131 | + MIN | ||
| 132 | + AVG | ||
| 133 | + } | ||
| 134 | + class SlidingWindowEmbeddingAggregationType{ | ||
| 135 | + <<enumeration>> | ||
| 136 | + MAX_POOLING | ||
| 137 | + MIN_POOLING | ||
| 138 | + AVG_POOLING | ||
| 139 | + } | ||
| 140 | + class WindowTimeUnit{ | ||
| 141 | + <<enumeration>> | ||
| 142 | + DAY | ||
| 143 | + HOUR | ||
| 144 | + MINUTE | ||
| 145 | + SECOND | ||
| 146 | + } | ||
| 147 | + class Window{ | ||
| 148 | + +int size | ||
| 149 | + +WindowTimeUnit unit | ||
| 150 | + } | ||
| 151 | + class SlidingWindowAggregation{ | ||
| 152 | + +SlidingWindowAggregationType aggregationType | ||
| 153 | + +Window window | ||
| 154 | + +SparkSqlExpression targetColumn | ||
| 155 | + +Optional[SparkSqlExpression] filter | ||
| 156 | + +Optional[SparkSqlExpression] groupBy | ||
| 157 | + +Optional[int] limit | ||
| 158 | + } | ||
| 159 | + class SlidingWindowEmbeddingAggregation{ | ||
| 160 | + +SlidingWindowEmbeddingAggregationType aggregationType | ||
| 161 | + +Window window | ||
| 162 | + +SparkSqlExpression targetColumn | ||
| 163 | + +Optional[SparkSqlExpression] filter | ||
| 164 | + +Optional[SparkSqlExpression] groupBy | ||
| 165 | + } | ||
| 166 | + class SlidingWindowLatestAvailable{ | ||
| 167 | + +Optional[Window] window | ||
| 168 | + +SparkSqlExpression targetColumn | ||
| 169 | + +Optional[SparkSqlExpression] filter | ||
| 170 | + +Optional[SparkSqlExpression] groupBy | ||
| 171 | + +Optional[int] limit | ||
| 172 | + } | ||
| 23 | 173 | class Source{ | |
| 24 | 174 | } | |
| 25 | 175 | class DataSource{ | |
| 176 | + +Optional[Clazz] clazz | ||
| 177 | + +Optional[Function] keyFunction | ||
| 26 | 178 | } | |
| 27 | 179 | class FeatureSource{ | |
| 28 | - +FeatureNameId feature_name_id | ||
| 180 | + +FeatureNameId input_feature_name_id | ||
| 181 | + +Optional[str] alias | ||
| 29 | 182 | } | |
| 30 | 183 | class MultiFeatureSource{ | |
| 31 | 184 | +List[FeatureSource] sources | |
| 32 | 185 | } | |
| 186 | + class Transformation{ | ||
| 187 | + +Function transformationFunction | ||
| 188 | + } | ||
| 33 | 189 | class Feature{ | |
| 34 | 190 | +FeatureId id | |
| 35 | 191 | +FeatureNameId feature_namme_id | |
| 36 | 192 | +Source source | |
| 37 | 193 | +Transformation transformation | |
| 38 | 194 | } | |
| 39 | 195 | class AnchorFeature{ | |
| 196 | + +AnchorId anchor_id | ||
| 40 | 197 | +DataSource source | |
| 41 | 198 | } | |
| 42 | 199 | class DerivedFeature{ | |
@@ -46,6 +203,8 @@ classDiagram | |||
| 46 | 203 | +FeatureNameId id | |
| 47 | 204 | +ProjectId project_id | |
| 48 | 205 | +List[FeatureId] feature_ids | |
| 206 | + +Optional[SemanticVersion] semanticVersion | ||
| 207 | + +Optional[FeatureType] featureType | ||
| 49 | 208 | } | |
| 50 | 209 | class Project{ | |
| 51 | 210 | +ProjectId id | |
| Back | FazBrowse Home | New Git URL |
0 commit comments