Exemple #1
0
    def __init__(self,
                 name='',
                 entity='',
                 granularity=Granularity.NONE,
                 owner='',
                 value_type=ValueType.DOUBLE,
                 description='',
                 uri='',
                 warehouse_store=None,
                 serving_store=None,
                 group='',
                 tags=[],
                 options={}):
        """Create feast feature instance.
        
        Args:
            name (str): name of feature, in lower snake case
            entity (str): entity the feature belongs to, in lower case
            granularity (feast.sdk.resources.feature.Granularity):
                granularity of the feature
            owner (str): owner of the feature
            value_type (feast.sdk.resources.feature.ValueType): defaults to
                ValueType.DOUBLE. value type of the feature
            description (str): defaults to "". description of the feature
            uri (str): defaults to "". uri pointing to the source code or 
                origin of this feature
            warehouse_store (feast.sdk.resources.feature.Datastore):
                warehouse store id and options
            serving_store (feast.sdk.resources.feature.Datastore): serving
                store id and options
            group (str, optional): feature group to inherit from
            tags (list[str], optional): tags assigned to the feature
            options (dic, optional): additional options for the feature
        """
        id = '.'.join(
            [entity,
             Granularity_pb2.Enum.Name(granularity.value), name]).lower()

        warehouse_store_spec = None
        serving_store_spec = None
        if (serving_store is not None):
            serving_store_spec = serving_store.spec
        if (warehouse_store is not None):
            warehouse_store_spec = warehouse_store.spec
        data_stores = DataStores(serving=serving_store_spec,
                                 warehouse=warehouse_store_spec)
        self.__spec = FeatureSpec(id=id,
                                  granularity=granularity.value,
                                  name=name,
                                  entity=entity,
                                  owner=owner,
                                  dataStores=data_stores,
                                  description=description,
                                  uri=uri,
                                  valueType=value_type.value,
                                  group=group,
                                  tags=tags,
                                  options=options)
Exemple #2
0
    def from_yaml(cls, path):
        """Create an instance of feature from a yaml spec file
        
        Args:
            path (str): path to yaml spec file
        """

        with open(path, 'r') as file:
            content = yaml.safe_load(file.read())
            feature = cls()
            feature.__spec = Parse(json.dumps(content),
                                   FeatureSpec(),
                                   ignore_unknown_fields=False)
            return feature
Exemple #3
0
 def __init__(self,
              name='',
              entity='',
              owner='',
              value_type=ValueType.DOUBLE,
              description='',
              uri='',
              group='',
              tags=[],
              options={}):
     """Create feast feature instance.
     
     Args:
         name (str): name of feature, in lower snake case
         entity (str): entity the feature belongs to, in lower case
         owner (str): owner of the feature
         value_type (feast.sdk.resources.feature.ValueType): defaults to
             ValueType.DOUBLE. value type of the feature
         description (str): defaults to "". description of the feature
         uri (str): defaults to "". uri pointing to the source code or 
             origin of this feature
         group (str, optional): feature group to inherit from
         tags (list[str], optional): tags assigned to the feature
         options (dic, optional): additional options for the feature
     """
     id = '{}.{}'.format(entity, name).lower()
     self.__spec = FeatureSpec(id=id,
                               name=name,
                               entity=entity,
                               owner=owner,
                               description=description,
                               uri=uri,
                               valueType=value_type.value,
                               group=group,
                               tags=tags,
                               options=options)
Exemple #4
0
 def _create_feature_spec(self, feature_id, wh_id):
     wh_store = DataStore(id=wh_id)
     datastores = DataStores(warehouse=wh_store)
     return FeatureSpec(id=feature_id, dataStores=datastores)
Exemple #5
0
 def _create_feature_spec(self, feature_id, wh_id):
     return FeatureSpec(id=feature_id)