Feature Store
# Get the latest lib from Rapidcanvas
# !pip install --extra-index-url=https://us-central1-python.pkg.dev/rapidcanvas-361003/pypi/simple utils==0.12dev0
from utils.rc.client.requests import Requests
from utils.rc.client.auth import AuthClient
from utils.rc.dtos.project import Project
from utils.rc.dtos.dataset import Dataset
from utils.rc.dtos.recipe import Recipe
from utils.rc.dtos.transform import Transform
from utils.rc.dtos.artifact import Artifact
from utils.rc.dtos.dataSource import DataSource
from utils.rc.dtos.dataSource import DataSourceType
from utils.rc.dtos.dataSource import RedisStorageConfig
from utils.rc.dtos.template_v2 import TemplateV2, TemplateTransformV2
import pandas as pd
import logging
from utils.utils.log_util import LogUtil
LogUtil.set_basic_config(format='%(levelname)s:%(message)s', level=logging.INFO)
online_data_store = DataSource.createDataSource(
"online-redis",
DataSourceType.REDIS_STORAGE,
{RedisStorageConfig.HOST: "127.0.0.1", RedisStorageConfig.PORT: "6379"}
)
project = Project.create(
name="Example Feature Store",
description="Testing feature store",
createEmpty=True
)
project.id
titanic = project.addDataset(
dataset_name="titanic",
dataset_description="titanic golden",
dataset_file_path="data/titanic.csv"
)
titanic.getData(5)
recipe = project.addRecipe([titanic], name="feature_store_sync")
template = TemplateV2(
name="FeatureStoreSync", description="FeatureStoreSync", project_id=project.id, source="CUSTOM", status="ACTIVE", tags=["Number", "datatype-long"]
)
template_transform = TemplateTransformV2(type = "python", params=dict(notebookName="FeatureStoreSync.ipynb"))
template.base_transforms = [template_transform]
template.publish("transforms/FeatureStoreSync.ipynb")
transform = Transform()
transform.templateId = template.id
transform.name = "transform_1"
transform.variables = {
"datasetName": titanic.name,
"columns": "Name,Sex,Age",
"featureEntityName": "Passenger",
"featureEntityColumn": "PassengerId",
"dataSourceName": online_data_store.name
}
recipe.prepareForLocal(transform, "feature_store")
recipe.add_transform(transform)
recipe.run()