From f7903f4feaef585dd47d91d8e4f7b4a5c20ad1de Mon Sep 17 00:00:00 2001
From: Arthur Lu <learthurgo@gmail.com>
Date: Fri, 28 Feb 2025 19:17:44 +0000
Subject: [PATCH] add individual config files for each strategy, config file
 path can be specified as the second argument

---
 app/config.py                             | 3 ++-
 app/config_baseline.yaml                  | 4 ++++
 app/{config.yaml => config_prefetch.yaml} | 0
 app/config_seive.yaml                     | 4 ++++
 app/config_tiered.yaml                    | 4 ++++
 app/main.py                               | 4 ++++
 6 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 app/config_baseline.yaml
 rename app/{config.yaml => config_prefetch.yaml} (100%)
 create mode 100644 app/config_seive.yaml
 create mode 100644 app/config_tiered.yaml

diff --git a/app/config.py b/app/config.py
index c4b3b9a..987ae67 100644
--- a/app/config.py
+++ b/app/config.py
@@ -1,7 +1,8 @@
 import os
 import yaml
+import sys
 
-CONFIG_FILE = "config.yaml"
+CONFIG_FILE = sys.argv[1]
 
 def load_config():
     with open(CONFIG_FILE, "r") as f:
diff --git a/app/config_baseline.yaml b/app/config_baseline.yaml
new file mode 100644
index 0000000..c8eb188
--- /dev/null
+++ b/app/config_baseline.yaml
@@ -0,0 +1,4 @@
+cache_strategy: "Baseline"  # Change this to "Prefetch" or "Tiered" or "Seive"
+cache_limit: 10
+l2_cache_limit: 100
+db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder
\ No newline at end of file
diff --git a/app/config.yaml b/app/config_prefetch.yaml
similarity index 100%
rename from app/config.yaml
rename to app/config_prefetch.yaml
diff --git a/app/config_seive.yaml b/app/config_seive.yaml
new file mode 100644
index 0000000..884cba0
--- /dev/null
+++ b/app/config_seive.yaml
@@ -0,0 +1,4 @@
+cache_strategy: "Seive"  # Change this to "Prefetch" or "Tiered" or "Seive"
+cache_limit: 10
+l2_cache_limit: 100
+db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder
\ No newline at end of file
diff --git a/app/config_tiered.yaml b/app/config_tiered.yaml
new file mode 100644
index 0000000..99494e9
--- /dev/null
+++ b/app/config_tiered.yaml
@@ -0,0 +1,4 @@
+cache_strategy: "Tiered"  # Change this to "Prefetch" or "Tiered" or "Seive"
+cache_limit: 10
+l2_cache_limit: 100
+db_file: "llmData_sns.json" # Change this to the name of any json file within the "database/datastore" folder
\ No newline at end of file
diff --git a/app/main.py b/app/main.py
index fcfca9f..8fef2e2 100644
--- a/app/main.py
+++ b/app/main.py
@@ -11,12 +11,16 @@ app = FastAPI()
 
 # Initialize cache based on strategy from config.yaml or environment variable
 if CACHE_STRATEGY == "Baseline":
+    print("Using baseline cache strategy")
     cache = BaselineCache(limit=CACHE_LIMIT)
 elif CACHE_STRATEGY == "Prefetch":
+    print("Using prefetch cache strategy")
     cache = PrefetchCache(limit=CACHE_LIMIT)
 elif CACHE_STRATEGY == "Tiered":
+    print("Using tiered cache strategy")
     cache = TieredCache(limit=CACHE_LIMIT, l2_limit=L2_CACHE_LIMIT)
 elif CACHE_STRATEGY == "Seive":
+    print("Using seive cache strategy")
     cache = SeiveCache(limit=CACHE_LIMIT)
 else:
     raise ValueError(f"Invalid CACHE_STRATEGY: {CACHE_STRATEGY}")