kcelia commited on
Commit
45b7f9a
·
unverified ·
1 Parent(s): 997b879

chore: update paths

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. utils.py +7 -1
app.py CHANGED
@@ -56,10 +56,10 @@ ALL_DIRECTORIES = [
56
  # Load test dataset
57
 
58
  print("Load data ...")
59
- UNIQUE_FOUNDERS = load_pickle_from_zip("unique_founders.pkl")
60
- OTHER_TEST_FOUNDERS = load_pickle_from_zip("hf_test_founders.pkl")
61
- OTHER_TRAIN_FOUNDERS = load_pickle_from_zip("hf_train_founders.pkl")
62
- UNIQUE_MIXED_FOUNDERS = load_pickle_from_zip("unique_mixed_founders.pkl")
63
 
64
  DESCENDANT_PATH = Path("./data/Child.pkl")
65
  PREDICTION_IMG_PATH = Path("output.npg")
 
56
  # Load test dataset
57
 
58
  print("Load data ...")
59
+ UNIQUE_FOUNDERS = load_pickle_from_zip("data/unique_founders.pkl")
60
+ OTHER_TEST_FOUNDERS = load_pickle_from_zip("data/hf_test_founders.pkl")
61
+ OTHER_TRAIN_FOUNDERS = load_pickle_from_zip("data/hf_train_founders.pkl")
62
+ UNIQUE_MIXED_FOUNDERS = load_pickle_from_zip("data/unique_mixed_founders.pkl")
63
 
64
  DESCENDANT_PATH = Path("./data/Child.pkl")
65
  PREDICTION_IMG_PATH = Path("output.npg")
utils.py CHANGED
@@ -39,15 +39,21 @@ META = {"A": 5, "C": 1059079, "M": 10589, "NW": 100, "CT": 1059, "CTR": 0.1, "WS
39
 
40
  BUILD_GENS = [1, 2, 4, 6, 8, 12, 16, 24, 32, 48]
41
 
 
42
 
43
  def load_pickle_from_zip(file_name, zip_path="data.zip"):
44
  """
45
  Load a pickle file from within a zip archive.
46
  """
 
 
 
47
  with zipfile.ZipFile(zip_path, 'r') as z:
 
 
 
48
  with z.open(file_name) as f:
49
  return pickle.load(f)
50
-
51
 
52
  def generate_weighted_percentages():
53
  dominant_percentage = random.randint(50, 70)
 
39
 
40
  BUILD_GENS = [1, 2, 4, 6, 8, 12, 16, 24, 32, 48]
41
 
42
+ import os
43
 
44
  def load_pickle_from_zip(file_name, zip_path="data.zip"):
45
  """
46
  Load a pickle file from within a zip archive.
47
  """
48
+ if not os.path.exists(zip_path):
49
+ raise FileNotFoundError(f"The zip file '{zip_path}' does not exist.")
50
+
51
  with zipfile.ZipFile(zip_path, 'r') as z:
52
+ if file_name not in z.namelist():
53
+ print("-----", file_name, z.namelist())
54
+ raise KeyError(f"The file '{file_name}' does not exist in the zip archive '{zip_path}'.")
55
  with z.open(file_name) as f:
56
  return pickle.load(f)
 
57
 
58
  def generate_weighted_percentages():
59
  dominant_percentage = random.randint(50, 70)