Skip to content

Commit

Permalink
Read registry & config from env variables
Browse files Browse the repository at this point in the history
Signed-off-by: Tsotne Tabidze <[email protected]>
  • Loading branch information
Tsotne Tabidze committed Sep 16, 2021
1 parent b3d58f6 commit 8fac0c8
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions sdk/python/feast/infra/feature_servers/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import base64
import os
import tempfile
from pathlib import Path

import yaml
from mangum import Mangum

import feast
from feast import FeatureStore
from feast.feature_server import get_app

# TODO: replace this with an actual feature repo config deserialized from the env variables
config = feast.RepoConfig()
# Load RepoConfig
config_base64 = os.environ["FEAST_CONFIG_BASE64"]
config_bytes = base64.b64decode(config_base64)

store = feast.FeatureStore(config=config)
# Override the registry path
config_yaml = yaml.safe_load(config_bytes)
config_yaml["registry"] = "registry.db"
config_bytes = yaml.safe_dump(config_yaml).encode()

app = get_app(store)
# Load Registry
registry_base64 = os.environ["FEAST_REGISTRY_BASE64"]
registry_bytes = base64.b64decode(registry_base64)

# Create a new unique directory for writing feature_store.yaml and registry.db files
repo_path = Path(tempfile.mkdtemp())

with open(repo_path / "feature_store.yaml", "wb") as f:
f.write(config_bytes)

with open(repo_path / "registry.db", "wb") as f:
f.write(registry_bytes)

# Initialize the feature store
store = FeatureStore(repo_path=str(repo_path.resolve()))

# Create the FastAPI app and AWS Lambda handler
app = get_app(store)
handler = Mangum(app)

0 comments on commit 8fac0c8

Please sign in to comment.