-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read registry & config from env variables
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |