HaLim
commited on
Commit
·
51181a6
1
Parent(s):
75e8648
Adding etl process and change fixed numbers into variables
Browse files- src/config/optimization_config.py +79 -12
- src/etl/extract.py +10 -2
src/config/optimization_config.py
CHANGED
|
@@ -45,24 +45,91 @@ def get_shift_list():
|
|
| 45 |
return streamlit_shift_list
|
| 46 |
except Exception as e:
|
| 47 |
print(f"using default value for shift list")
|
| 48 |
-
shift_list = extract.
|
| 49 |
-
shift_list = shift_list["
|
| 50 |
return shift_list
|
| 51 |
SHIFT_LIST = get_shift_list()
|
| 52 |
print(SHIFT_LIST)
|
| 53 |
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
LINE_LIST_PER_TYPE = {
|
| 58 |
-
"long": 2,
|
| 59 |
-
"short": 3,
|
| 60 |
-
} # Work_centre_capacity but not enough on the number of line and exact number of capacity
|
| 61 |
-
DEMAND_LIST = {"a": 1000, "b": 6000, "c": 4000} # COOIS_Planned_and_Released.csv
|
| 62 |
-
COST_LIST_PER_EMP_SHIFT = { # WH_Workforce_Hourly_Pay_Scale
|
| 63 |
-
"Fixed": {1: 0, 2: 22, 3: 18},
|
| 64 |
-
"Humanizer": {1: 10, 2: 10, 3: 10},
|
| 65 |
-
}
|
| 66 |
PRODUCTIVITY_LIST_PER_EMP_PRODUCT = { # Kits_Calculation
|
| 67 |
"Fixed": {
|
| 68 |
1: {"a": 1000, "b": 1000, "c": 1000},
|
|
|
|
| 45 |
return streamlit_shift_list
|
| 46 |
except Exception as e:
|
| 47 |
print(f"using default value for shift list")
|
| 48 |
+
shift_list = extract.read_shift_cost_data()
|
| 49 |
+
shift_list = shift_list["id"].unique()
|
| 50 |
return shift_list
|
| 51 |
SHIFT_LIST = get_shift_list()
|
| 52 |
print(SHIFT_LIST)
|
| 53 |
|
| 54 |
|
| 55 |
+
def get_line_list():
|
| 56 |
+
try:
|
| 57 |
+
streamlit_line_list = dashboard.line_list
|
| 58 |
+
return streamlit_line_list
|
| 59 |
+
except Exception as e:
|
| 60 |
+
print(f"using default value for line list")
|
| 61 |
+
line_df = extract.read_packaging_line_data()
|
| 62 |
+
line_list = line_df["id"].unique().tolist()
|
| 63 |
+
return line_list
|
| 64 |
+
|
| 65 |
+
LINE_LIST = get_line_list()
|
| 66 |
+
print(LINE_LIST)
|
| 67 |
+
|
| 68 |
+
def get_line_cnt_per_type():
|
| 69 |
+
try:
|
| 70 |
+
streamlit_line_cnt_per_type = dashboard.line_cnt_per_type
|
| 71 |
+
return streamlit_line_cnt_per_type
|
| 72 |
+
except Exception as e:
|
| 73 |
+
print(f"using default value for line cnt per type")
|
| 74 |
+
line_df = extract.read_packaging_line_data()
|
| 75 |
+
line_cnt_per_type = line_df.set_index("id")["line_count"].to_dict()
|
| 76 |
+
print(line_cnt_per_type)
|
| 77 |
+
return line_cnt_per_type
|
| 78 |
+
|
| 79 |
+
LINE_CNT_PER_TYPE = get_line_cnt_per_type()
|
| 80 |
+
print(LINE_CNT_PER_TYPE)
|
| 81 |
+
|
| 82 |
+
def get_demand_dictionary():
|
| 83 |
+
try:
|
| 84 |
+
streamlit_demand_dictionary = dashboard.demand_dictionary
|
| 85 |
+
return streamlit_demand_dictionary
|
| 86 |
+
except Exception as e:
|
| 87 |
+
print(f"using default value for demand dictionary")
|
| 88 |
+
demand_df = extract.read_demand_data()
|
| 89 |
+
print(demand_df)
|
| 90 |
+
demand_dictionary = demand_df.groupby('Material Number')["Order quantity (GMEIN)"].sum().to_dict()
|
| 91 |
+
return demand_dictionary
|
| 92 |
+
|
| 93 |
+
DEMAND_DICTIONARY = get_demand_dictionary()
|
| 94 |
+
print(DEMAND_DICTIONARY)
|
| 95 |
+
|
| 96 |
+
def get_cost_list_per_emp_shift():
|
| 97 |
+
try:
|
| 98 |
+
streamlit_cost_list_per_emp_shift = dashboard.cost_list_per_emp_shift
|
| 99 |
+
return streamlit_cost_list_per_emp_shift
|
| 100 |
+
except Exception as e:
|
| 101 |
+
print(f"using default value for cost list per emp shift")
|
| 102 |
+
shift_cost_df = extract.read_shift_cost_data()
|
| 103 |
+
#question - Important : there is multiple type of employment type in terms of the cost
|
| 104 |
+
#1 -. unicef 2 - humanizer
|
| 105 |
+
return {1:{1:43,2:43,6:64},2:{1:27,2:27,6:41}}
|
| 106 |
+
|
| 107 |
+
COST_LIST_PER_EMP_SHIFT = get_cost_list_per_emp_shift()
|
| 108 |
+
print(COST_LIST_PER_EMP_SHIFT)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
# COST_LIST_PER_EMP_SHIFT = { # WH_Workforce_Hourly_Pay_Scale
|
| 113 |
+
# "Fixed": {1: 0, 2: 22, 3: 18},
|
| 114 |
+
# "Humanizer": {1: 10, 2: 10, 3: 10},
|
| 115 |
+
# }
|
| 116 |
+
|
| 117 |
+
def get_productivity_list_per_emp_product():
|
| 118 |
+
try:
|
| 119 |
+
streamlit_productivity_list_per_emp_product = dashboard.productivity_list_per_emp_product
|
| 120 |
+
return streamlit_productivity_list_per_emp_product
|
| 121 |
+
except Exception as e:
|
| 122 |
+
print(f"using default value for productivity list per emp product")
|
| 123 |
+
emp_product_df = extract.read_employee_productivity_data()
|
| 124 |
+
print(emp_product_df)
|
| 125 |
+
productivity_list_per_emp_product = emp_product_df.groupby("employment_type_id")["productivity"].sum().to_dict()
|
| 126 |
+
print(productivity_list_per_emp_product)
|
| 127 |
+
return
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
PRODUCTIVITY_LIST_PER_EMP_PRODUCT = get_productivity_list_per_emp_product()
|
| 131 |
+
print(PRODUCTIVITY_LIST_PER_EMP_PRODUCT)
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
PRODUCTIVITY_LIST_PER_EMP_PRODUCT = { # Kits_Calculation
|
| 134 |
"Fixed": {
|
| 135 |
1: {"a": 1000, "b": 1000, "c": 1000},
|
src/etl/extract.py
CHANGED
|
@@ -29,8 +29,8 @@ def read_employee_data(
|
|
| 29 |
return pd.read_csv(path)
|
| 30 |
|
| 31 |
|
| 32 |
-
def
|
| 33 |
-
path="data/real_data_excel/converted_csv/
|
| 34 |
) -> pd.DataFrame:
|
| 35 |
return pd.read_csv(path)
|
| 36 |
|
|
@@ -52,6 +52,14 @@ def read_material_master(
|
|
| 52 |
) -> pd.DataFrame:
|
| 53 |
return pd.read_csv(path)
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
def read_released_orders_data(
|
| 57 |
path="data/real_data_excel/converted_csv/COOIS_Released_Prod_Orders.csv",
|
|
|
|
| 29 |
return pd.read_csv(path)
|
| 30 |
|
| 31 |
|
| 32 |
+
def read_shift_cost_data(
|
| 33 |
+
path="data/real_data_excel/converted_csv/work_shift.csv",
|
| 34 |
) -> pd.DataFrame:
|
| 35 |
return pd.read_csv(path)
|
| 36 |
|
|
|
|
| 52 |
) -> pd.DataFrame:
|
| 53 |
return pd.read_csv(path)
|
| 54 |
|
| 55 |
+
def read_packaging_line_data(
|
| 56 |
+
path="data/real_data_excel/converted_csv/Work_Centre_Capacity_processed.csv",
|
| 57 |
+
) -> pd.DataFrame:
|
| 58 |
+
df = pd.read_csv(path)
|
| 59 |
+
# Filter for packaging lines only
|
| 60 |
+
df = df[df["line_for_packaging"] == True]
|
| 61 |
+
return df
|
| 62 |
+
|
| 63 |
|
| 64 |
def read_released_orders_data(
|
| 65 |
path="data/real_data_excel/converted_csv/COOIS_Released_Prod_Orders.csv",
|