alfraser commited on
Commit
7a2c982
·
1 Parent(s): 2f0e8e7

Fixed bugs in the dataload process with referencing the new json folder and then looking up the available databases.

Browse files
data/sqlite/products_dataset.db CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:904bf5e44391fc113ca57481c6518e427699862bb6939fbdf778fbd3efd18131
3
- size 36864
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5ece96e2b662df011c9896e4c276053296e6ea28a8d207bdf19c5219734585d
3
+ size 17260544
src/data_synthesis/generate_data.py CHANGED
@@ -109,12 +109,12 @@ def generate_products(category: str, features: List[str], k: int = 20):
109
 
110
  def category_product_file(category: str) -> str:
111
  output_file_name = f"products_{category.lower().replace(' ', '_')}.json"
112
- return os.path.join(data_dir, output_file_name)
113
 
114
 
115
  def category_review_file(category: str) -> str:
116
  output_file_name = f"reviews_{category.lower().replace(' ', '_')}.json"
117
- return os.path.join(data_dir, output_file_name)
118
 
119
 
120
  def products_for_category(category: str) -> List[Product]:
 
109
 
110
  def category_product_file(category: str) -> str:
111
  output_file_name = f"products_{category.lower().replace(' ', '_')}.json"
112
+ return os.path.join(data_dir, 'json', output_file_name)
113
 
114
 
115
  def category_review_file(category: str) -> str:
116
  output_file_name = f"reviews_{category.lower().replace(' ', '_')}.json"
117
+ return os.path.join(data_dir, 'json', output_file_name)
118
 
119
 
120
  def products_for_category(category: str) -> List[Product]:
src/datatypes.py CHANGED
@@ -6,7 +6,8 @@ from src.common import *
6
 
7
  class DataLoader:
8
  active_db = "all_products"
9
- db_file = os.path.join(data_dir, 'sqlite', f"{active_db}.db")
 
10
  loaded = False
11
 
12
  @classmethod
@@ -14,17 +15,17 @@ class DataLoader:
14
  if name != cls.active_db:
15
  new_file = os.path.join(data_dir, 'sqlite', f"{name}.db")
16
  print(f"Switching database file from {cls.db_file} to {new_file}")
17
- cls.db_file = os.path.join(data_dir, f"{name}.db")
18
  DataLoader.load_data(reload=True)
19
  cls.active_db = name
20
 
21
  @staticmethod
22
  def current_db() -> str:
23
- return [f[:-3] for f in os.listdir(data_dir) if f.startswith('products') and f.endswith('.db')]
24
 
25
  @staticmethod
26
  def available_dbs() -> List[str]:
27
- return [f[:-3] for f in os.listdir(data_dir) if f.startswith('products') and f.endswith('.db')]
28
 
29
  @staticmethod
30
  def load_data(reload=False):
 
6
 
7
  class DataLoader:
8
  active_db = "all_products"
9
+ db_dir = os.path.join(data_dir, 'sqlite')
10
+ db_file = os.path.join(db_dir, f"{active_db}.db")
11
  loaded = False
12
 
13
  @classmethod
 
15
  if name != cls.active_db:
16
  new_file = os.path.join(data_dir, 'sqlite', f"{name}.db")
17
  print(f"Switching database file from {cls.db_file} to {new_file}")
18
+ cls.db_file = os.path.join(DataLoader.db_dir, f"{name}.db")
19
  DataLoader.load_data(reload=True)
20
  cls.active_db = name
21
 
22
  @staticmethod
23
  def current_db() -> str:
24
+ return DataLoader.active_db[:-3]
25
 
26
  @staticmethod
27
  def available_dbs() -> List[str]:
28
+ return [f[:-3] for f in os.listdir(DataLoader.db_dir) if ('products' in f) and f.endswith('.db')]
29
 
30
  @staticmethod
31
  def load_data(reload=False):