serenarolloh commited on
Commit
504d366
·
verified ·
1 Parent(s): 0b1a8c8

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +39 -13
config.py CHANGED
@@ -1,4 +1,9 @@
1
  from pydantic import BaseSettings, Field
 
 
 
 
 
2
 
3
  class Settings(BaseSettings):
4
  # Default values for the processor and model
@@ -25,15 +30,23 @@ class Settings(BaseSettings):
25
 
26
  # Function to dynamically select model and processor based on shipper_id
27
  def set_model(self):
 
 
28
  shipper_model_map = {
29
- "61": {"model": "senga-ml/donut-16", "processor": "senga-ml/donut-v16"},
30
- "81": {"model": "senga-ml/donut-16", "processor": "senga-ml/donut-v16"},
31
- "139": {"model": "senga-ml/donut-16", "processor": "senga-ml/donut-v16"},
32
- "165": {"model": "senga-ml/donut-17", "processor": "senga-ml/donut-v17"},
33
- "127": {"model": "senga-ml/donut-17", "processor": "senga-ml/donut-v17"},
34
- "145": {"model": "senga-ml/donut-17", "processor": "senga-ml/donut-v17"},
 
 
 
35
  }
36
 
 
 
 
37
  config = shipper_model_map.get(
38
  self.shipper_id,
39
  {"model": self.base_model, "processor": self.base_processor}
@@ -42,15 +55,28 @@ class Settings(BaseSettings):
42
  self.model = config["model"]
43
  self.processor = config["processor"]
44
 
45
- # For debugging
46
- print(f"Selected model for shipper {self.shipper_id}: {self.model}")
47
- print(f"Selected processor for shipper {self.shipper_id}: {self.processor}")
 
 
 
48
 
49
- # Create a singleton instance
50
  settings = Settings()
 
51
 
52
- # Example of how to update shipper_id and trigger model change
53
  def update_shipper(new_shipper_id):
 
 
 
 
 
 
 
 
 
 
54
  settings.shipper_id = new_shipper_id
55
- settings.set_model()
56
- return settings.model, settings.processor
 
1
  from pydantic import BaseSettings, Field
2
+ import logging
3
+
4
+ # Set up logging
5
+ logging.basicConfig(level=logging.INFO)
6
+ logger = logging.getLogger(__name__)
7
 
8
  class Settings(BaseSettings):
9
  # Default values for the processor and model
 
30
 
31
  # Function to dynamically select model and processor based on shipper_id
32
  def set_model(self):
33
+ # IMPORTANT: Make sure model names are consistent!
34
+ # You had "donut-16" in some places and "donut-v16" in others
35
  shipper_model_map = {
36
+ # Group 1 models - using donut-v16
37
+ "61": {"model": "senga-ml/donut-v16", "processor": "senga-ml/donut-v16"},
38
+ "81": {"model": "senga-ml/donut-v16", "processor": "senga-ml/donut-v16"},
39
+ "139": {"model": "senga-ml/donut-v16", "processor": "senga-ml/donut-v16"},
40
+
41
+ # Group 2 models - using donut-v17
42
+ "165": {"model": "senga-ml/donut-v17", "processor": "senga-ml/donut-v17"},
43
+ "127": {"model": "senga-ml/donut-v17", "processor": "senga-ml/donut-v17"},
44
+ "145": {"model": "senga-ml/donut-v17", "processor": "senga-ml/donut-v17"},
45
  }
46
 
47
+ previous_model = self.model
48
+ previous_processor = self.processor
49
+
50
  config = shipper_model_map.get(
51
  self.shipper_id,
52
  {"model": self.base_model, "processor": self.base_processor}
 
55
  self.model = config["model"]
56
  self.processor = config["processor"]
57
 
58
+ # Log changes for debugging
59
+ logger.info(f"Shipper ID set to: {self.shipper_id}")
60
+ logger.info(f"Changed model from {previous_model} to {self.model}")
61
+ logger.info(f"Changed processor from {previous_processor} to {self.processor}")
62
+
63
+ return self.model, self.processor
64
 
65
+ # Create a single instance
66
  settings = Settings()
67
+ logger.info(f"Initial model setup: {settings.model}")
68
 
69
+ # Function to update shipper and trigger model change
70
  def update_shipper(new_shipper_id):
71
+ """
72
+ Update the shipper ID and change the model accordingly
73
+
74
+ Args:
75
+ new_shipper_id: The new shipper ID to use
76
+
77
+ Returns:
78
+ tuple: (model, processor) that were selected
79
+ """
80
+ logger.info(f"Updating shipper ID to {new_shipper_id}")
81
  settings.shipper_id = new_shipper_id
82
+ return settings.set_model()