haileyhalimj@gmail.com commited on
Commit
e26abe9
·
1 Parent(s): dc6b17a

deleting the variables in the config to prevent infinite loop

Browse files
src/config/optimization_config.py CHANGED
@@ -581,20 +581,25 @@ def get_payment_mode_config():
581
  # This section is at the end to ensure all functions are defined first
582
  # ============================================================================
583
 
 
 
 
 
 
584
  # Initialize with default values (will use fallback data when no Streamlit session)
585
- PER_PRODUCT_SPEED = get_per_product_speed()
586
- LINE_LIST = get_line_list()
587
- EMPLOYEE_TYPE_LIST = get_employee_type_list()
588
- SHIFT_LIST = get_active_shift_list()
589
- LINE_CNT_PER_TYPE = get_line_cnt_per_type()
590
- COST_LIST_PER_EMP_SHIFT = get_cost_list_per_emp_shift()
591
- MAX_EMPLOYEE_PER_TYPE_ON_DAY = get_max_employee_per_type_on_day()
592
- MAX_HOUR_PER_SHIFT_PER_PERSON = get_max_hour_per_shift_per_person()
593
- MAX_PARALLEL_WORKERS = get_max_parallel_workers()
594
- FIXED_MIN_UNICEF_PER_DAY = get_fixed_min_unicef_per_day()
595
- PAYMENT_MODE_CONFIG = get_payment_mode_config()
596
-
597
- print("✅ Module-level configuration variables initialized")
598
 
599
  # Note: These variables are initialized once at import time with default/fallback values.
600
  # To get fresh values after changing Streamlit configuration, either:
 
581
  # This section is at the end to ensure all functions are defined first
582
  # ============================================================================
583
 
584
+ # DISABLED: Module-level initialization was causing infinite loops in Hugging Face deployment
585
+ # The functions are called dynamically when needed instead of at import time
586
+ # This prevents the infinite loop where importing this module triggers Streamlit session access
587
+ # which causes the app to reload, which imports this module again, etc.
588
+
589
  # Initialize with default values (will use fallback data when no Streamlit session)
590
+ # PER_PRODUCT_SPEED = get_per_product_speed()
591
+ # LINE_LIST = get_line_list()
592
+ # EMPLOYEE_TYPE_LIST = get_employee_type_list()
593
+ # SHIFT_LIST = get_active_shift_list()
594
+ # LINE_CNT_PER_TYPE = get_line_cnt_per_type()
595
+ # COST_LIST_PER_EMP_SHIFT = get_cost_list_per_emp_shift()
596
+ # MAX_EMPLOYEE_PER_TYPE_ON_DAY = get_max_employee_per_type_on_day()
597
+ # MAX_HOUR_PER_SHIFT_PER_PERSON = get_max_hour_per_shift_per_person()
598
+ # MAX_PARALLEL_WORKERS = get_max_parallel_workers()
599
+ # FIXED_MIN_UNICEF_PER_DAY = get_fixed_min_unicef_per_day()
600
+ # PAYMENT_MODE_CONFIG = get_payment_mode_config()
601
+
602
+ print("✅ Module-level configuration functions defined (variables initialized dynamically)")
603
 
604
  # Note: These variables are initialized once at import time with default/fallback values.
605
  # To get fresh values after changing Streamlit configuration, either:
src/demand_filtering.py CHANGED
@@ -216,7 +216,7 @@ class DemandFilter:
216
  speed_data = None
217
  try:
218
  from src.config import optimization_config
219
- speed_data = optimization_config.PER_PRODUCT_SPEED
220
  except Exception as e:
221
  print(f"Warning: Could not load speed data for validation: {e}")
222
 
@@ -252,7 +252,7 @@ class DemandFilter:
252
  speed_data = None
253
  try:
254
  from src.config import optimization_config
255
- speed_data = optimization_config.PER_PRODUCT_SPEED
256
  except Exception as e:
257
  print(f"Warning: Could not load speed data for analysis: {e}")
258
 
 
216
  speed_data = None
217
  try:
218
  from src.config import optimization_config
219
+ speed_data = optimization_config.get_per_product_speed()
220
  except Exception as e:
221
  print(f"Warning: Could not load speed data for validation: {e}")
222
 
 
252
  speed_data = None
253
  try:
254
  from src.config import optimization_config
255
+ speed_data = optimization_config.get_per_product_speed()
256
  except Exception as e:
257
  print(f"Warning: Could not load speed data for analysis: {e}")
258
 
src/demand_validation_viz.py CHANGED
@@ -30,7 +30,7 @@ class DemandValidationViz:
30
  try:
31
  # Load speed data for visualization
32
  from src.config import optimization_config
33
- self.speed_data = optimization_config.PER_PRODUCT_SPEED
34
 
35
  # Load data in the filter instance
36
  return self.filter_instance.load_data()
 
30
  try:
31
  # Load speed data for visualization
32
  from src.config import optimization_config
33
+ self.speed_data = optimization_config.get_per_product_speed()
34
 
35
  # Load data in the filter instance
36
  return self.filter_instance.load_data()
src/models/optimizer_real.py CHANGED
@@ -65,10 +65,12 @@ def build_lines():
65
  line_tuples.append((lt, i))
66
  return line_tuples
67
 
68
- line_tuples=build_lines()
69
- print("line_tuples",line_tuples)
70
- PER_PRODUCT_SPEED = get_per_product_speed() # Dynamic call
71
- print("PER_PRODUCT_SPEED",PER_PRODUCT_SPEED)
 
 
72
 
73
  def sort_products_by_hierarchy(product_list):
74
  """
@@ -202,6 +204,10 @@ def run_optimization_for_week():
202
 
203
  line_tuples = build_lines()
204
  print("Lines",line_tuples)
 
 
 
 
205
 
206
  # --- Short aliases for parameters ---
207
  Hmax_s = dict(get_max_hour_per_shift_per_person()) # Dynamic call - per-shift hours
 
65
  line_tuples.append((lt, i))
66
  return line_tuples
67
 
68
+ # DISABLED: Module-level initialization was causing infinite loops
69
+ # These variables are now created dynamically when needed
70
+ # line_tuples=build_lines()
71
+ # print("line_tuples",line_tuples)
72
+ # PER_PRODUCT_SPEED = get_per_product_speed() # Dynamic call
73
+ # print("PER_PRODUCT_SPEED",PER_PRODUCT_SPEED)
74
 
75
  def sort_products_by_hierarchy(product_list):
76
  """
 
204
 
205
  line_tuples = build_lines()
206
  print("Lines",line_tuples)
207
+
208
+ # Load product speed data dynamically
209
+ PER_PRODUCT_SPEED = get_per_product_speed()
210
+ print("PER_PRODUCT_SPEED",PER_PRODUCT_SPEED)
211
 
212
  # --- Short aliases for parameters ---
213
  Hmax_s = dict(get_max_hour_per_shift_per_person()) # Dynamic call - per-shift hours