Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
batch-analytics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aakash.bedi
batch-analytics
Commits
4399ec5c
Commit
4399ec5c
authored
Jan 24, 2023
by
aakash.bedi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configure postgres
parent
07cb2e46
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
35 deletions
+26
-35
conf/application.conf
conf/application.conf
+2
-2
config.env
config.env
+1
-1
data/t_batch_information_master.xlsx
data/t_batch_information_master.xlsx
+0
-0
data/t_batch_kpi_master.xlsx
data/t_batch_kpi_master.xlsx
+0
-0
data/t_batch_master.xlsx
data/t_batch_master.xlsx
+0
-0
data/t_batch_material_master.xlsx
data/t_batch_material_master.xlsx
+0
-0
scripts/constants/app_configuration.py
scripts/constants/app_configuration.py
+3
-9
scripts/core/join_tables/join_required_tables.py
scripts/core/join_tables/join_required_tables.py
+9
-9
scripts/core/master_tables/batch_kpi_table.py
scripts/core/master_tables/batch_kpi_table.py
+2
-3
scripts/core/master_tables/batch_master_table.py
scripts/core/master_tables/batch_master_table.py
+7
-8
scripts/core/master_tables/batch_material_table.py
scripts/core/master_tables/batch_material_table.py
+2
-3
No files found.
conf/application.conf
View file @
4399ec5c
...
@@ -14,8 +14,8 @@ required_tz=$REQUIRED_TZ
...
@@ -14,8 +14,8 @@ required_tz=$REQUIRED_TZ
start_relative
=$
START_RELATIVE
start_relative
=$
START_RELATIVE
end_relative
=$
END_RELATIVE
end_relative
=$
END_RELATIVE
[
FORECAST_DATA
]
[
POSTGRES_CRED
]
days_of_degradation_prediction
=$
DAYS_OF_DEGRADATION_PREDICTION
postgres_uri
=$
POSTGRES_URI
config.env
View file @
4399ec5c
...
@@ -6,4 +6,4 @@ DEFAULT_TZ="UTC"
...
@@ -6,4 +6,4 @@ DEFAULT_TZ="UTC"
REQUIRED_TZ="Asia/Kolkata"
REQUIRED_TZ="Asia/Kolkata"
START_RELATIVE=90
START_RELATIVE=90
END_RELATIVE=0
END_RELATIVE=0
DAYS_OF_DEGRADATION_PREDICTION=7
POSTGRES_URI=postgresql://ilens:iLens$456@192.168.0.207:5455/ilens_ai
data/t_batch_information_master.xlsx
View file @
4399ec5c
No preview for this file type
data/t_batch_kpi_master.xlsx
View file @
4399ec5c
No preview for this file type
data/t_batch_master.xlsx
View file @
4399ec5c
No preview for this file type
data/t_batch_material_master.xlsx
View file @
4399ec5c
No preview for this file type
scripts/constants/app_configuration.py
View file @
4399ec5c
...
@@ -9,7 +9,6 @@ from loguru import logger
...
@@ -9,7 +9,6 @@ from loguru import logger
_application_conf
=
f
"./conf/application.conf"
_application_conf
=
f
"./conf/application.conf"
_default_conf
=
f
"./config.env"
_default_conf
=
f
"./config.env"
data_conf
=
f
"./conf/data.yml"
data_conf
=
f
"./conf/data.yml"
training_data
=
f
"./data/training.csv"
load_dotenv
(
dotenv_path
=
_default_conf
)
load_dotenv
(
dotenv_path
=
_default_conf
)
...
@@ -51,21 +50,16 @@ class Kafka:
...
@@ -51,21 +50,16 @@ class Kafka:
kafka_topic
=
config
[
"KAFKA"
][
"kafka_topic"
]
kafka_topic
=
config
[
"KAFKA"
][
"kafka_topic"
]
class
HistoricalData
:
class
PostgresCred
:
start_relative
=
config
[
'HISTORICAL_DATA'
][
'start_relative'
]
postgres_uri
=
config
[
'POSTGRES_CRED'
][
'postgres_uri'
]
end_relative
=
config
[
'HISTORICAL_DATA'
][
'end_relative'
]
class
ForecastData
:
days_of_degradation_prediction
=
config
[
'FORECAST_DATA'
][
'days_of_degradation_prediction'
]
class
TimeZone
:
class
TimeZone
:
default_tz
=
config
[
"TIMEZONE"
][
"default_tz"
]
default_tz
=
config
[
"TIMEZONE"
][
"default_tz"
]
required_tz
=
config
[
"TIMEZONE"
][
"required_tz"
]
required_tz
=
config
[
"TIMEZONE"
][
"required_tz"
]
# Read the configuration file
# Read the configuration file
yml_file_path
=
"conf/"
yml_file_path
=
"conf/"
try
:
try
:
with
open
(
os
.
path
.
join
(
yml_file_path
,
'data.yml'
),
'r'
)
as
engine_yml_file
:
with
open
(
os
.
path
.
join
(
yml_file_path
,
'data.yml'
),
'r'
)
as
engine_yml_file
:
...
...
scripts/core/join_tables/join_required_tables.py
View file @
4399ec5c
from
loguru
import
logger
from
loguru
import
logger
import
pandas
as
pd
import
pandas
as
pd
from
scripts.co
re.master_tables.dataframe_read
import
ReadData
from
scripts.co
nstants.app_configuration
import
PostgresCred
class
JoinTables
:
class
JoinTables
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
base_path
=
f
'data'
self
.
base_path
=
f
'data'
self
.
golden_batch
=
"Golden Batch"
def
join_master
(
self
,
df_batch_master
,
df_batch_kpi_master
,
df_batch_material_master
):
def
join_master
(
self
,
df_batch_master
,
df_batch_kpi_master
,
df_batch_material_master
):
try
:
try
:
...
@@ -19,22 +20,21 @@ class JoinTables:
...
@@ -19,22 +20,21 @@ class JoinTables:
min_bct_4
=
df
.
loc
[
df
[
'process_stage_id'
]
==
'P2E-STAGE-004'
,
'batch_cycle_time_minutes'
]
.
min
()
min_bct_4
=
df
.
loc
[
df
[
'process_stage_id'
]
==
'P2E-STAGE-004'
,
'batch_cycle_time_minutes'
]
.
min
()
min_bct_5
=
df
.
loc
[
df
[
'process_stage_id'
]
==
'P2E-STAGE-005'
,
'batch_cycle_time_minutes'
]
.
min
()
min_bct_5
=
df
.
loc
[
df
[
'process_stage_id'
]
==
'P2E-STAGE-005'
,
'batch_cycle_time_minutes'
]
.
min
()
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-001'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_1
),
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-001'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_1
),
'golden_batch'
]
=
'Golden Batch'
'golden_batch'
]
=
self
.
golden_batch
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-002'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_2
),
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-002'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_2
),
'golden_batch'
]
=
'Golden Batch'
'golden_batch'
]
=
self
.
golden_batch
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-003'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_3
),
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-003'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_3
),
'golden_batch'
]
=
'Golden Batch'
'golden_batch'
]
=
self
.
golden_batch
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-004'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_4
),
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-004'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_4
),
'golden_batch'
]
=
'Golden Batch'
'golden_batch'
]
=
self
.
golden_batch
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-005'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_5
),
df
.
loc
[(
df
[
'process_stage_id'
]
==
'P2E-STAGE-005'
)
&
(
df
[
'batch_cycle_time_minutes'
]
==
min_bct_5
),
'golden_batch'
]
=
'Golden Batch'
'golden_batch'
]
=
self
.
golden_batch
df
.
reset_index
(
drop
=
True
,
inplace
=
True
)
df
.
reset_index
(
drop
=
True
,
inplace
=
True
)
df
=
df
.
round
(
2
)
df
=
df
.
round
(
2
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_information_master.xlsx"
,
index
=
False
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_information_master.xlsx"
,
index
=
False
)
logger
.
info
(
f
'Pushing master_join to postgres'
)
logger
.
info
(
f
'Pushing master_join to postgres'
)
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_information_master"
,
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_information_master"
,
PostgresCred
.
postgres_uri
,
"postgresql://ilens:iLens$456@192.168.0.207:5455/ilens_ai"
,
if_exists
=
'replace'
)
if_exists
=
'replace'
)
logger
.
debug
(
f
'Pushed master_join to postgres'
)
logger
.
debug
(
f
'Pushed master_join to postgres'
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
f
"Exception - {e}"
)
logger
.
exception
(
f
"Exception - {e}"
)
\ No newline at end of file
scripts/core/master_tables/batch_kpi_table.py
View file @
4399ec5c
from
loguru
import
logger
from
loguru
import
logger
import
pandas
as
pd
import
pandas
as
pd
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.constants.app_configuration
import
PostgresCred
class
BatchKpi
:
class
BatchKpi
:
...
@@ -66,9 +67,7 @@ class BatchKpi:
...
@@ -66,9 +67,7 @@ class BatchKpi:
df
=
df
.
round
(
2
)
df
=
df
.
round
(
2
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_kpi_master.xlsx"
,
index
=
False
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_kpi_master.xlsx"
,
index
=
False
)
logger
.
info
(
f
'Pushing batch_kpi_master to postgres'
)
logger
.
info
(
f
'Pushing batch_kpi_master to postgres'
)
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_kpi_master"
,
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_kpi_master"
,
PostgresCred
.
postgres_uri
,
if_exists
=
"replace"
)
"postgresql://ilens:iLens$456@192.168.0.207:5455/ilens_ai"
,
if_exists
=
"replace"
)
logger
.
debug
(
f
'Pushed batch_kpi_master to postgres'
)
logger
.
debug
(
f
'Pushed batch_kpi_master to postgres'
)
return
df
return
df
except
Exception
as
e
:
except
Exception
as
e
:
...
...
scripts/core/master_tables/batch_master_table.py
View file @
4399ec5c
from
loguru
import
logger
from
loguru
import
logger
import
pandas
as
pd
import
pandas
as
pd
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.constants.app_configuration
import
PostgresCred
class
BatchMaster
:
class
BatchMaster
:
...
@@ -51,23 +52,23 @@ class BatchMaster:
...
@@ -51,23 +52,23 @@ class BatchMaster:
df_stage_1
,
df_stage_2
,
df_stage_3
,
df_stage_4
,
df_stage_5
=
ReadData
()
.
read_df
()
df_stage_1
,
df_stage_2
,
df_stage_3
,
df_stage_4
,
df_stage_5
=
ReadData
()
.
read_df
()
df_stage_1
=
self
.
batch_master
(
df_stage_1
,
process_stage_name
=
"Stage-01"
,
df_stage_1
=
self
.
batch_master
(
df_stage_1
,
process_stage_name
=
"Stage-01"
,
process_stage_id
=
"P2E-STAGE-001"
,
process_stage_id
=
"P2E-STAGE-001"
,
batch_product
=
"P2E-Stage-01"
,
ideal_batch_cycle_time_hr
=
720
,
batch_product
=
"P2E-Stage-01"
,
ideal_batch_cycle_time_hr
=
12
,
batch_setup_time_hr
=
1
)
batch_setup_time_hr
=
1
)
df_stage_2
=
self
.
batch_master
(
df_stage_2
,
process_stage_name
=
"Stage-02"
,
df_stage_2
=
self
.
batch_master
(
df_stage_2
,
process_stage_name
=
"Stage-02"
,
process_stage_id
=
"P2E-STAGE-002"
,
process_stage_id
=
"P2E-STAGE-002"
,
batch_product
=
"P2E-Stage-02"
,
ideal_batch_cycle_time_hr
=
1440
,
batch_product
=
"P2E-Stage-02"
,
ideal_batch_cycle_time_hr
=
24
,
batch_setup_time_hr
=
1
)
batch_setup_time_hr
=
1
)
df_stage_3
=
self
.
batch_master
(
df_stage_3
,
process_stage_name
=
"Stage-03"
,
df_stage_3
=
self
.
batch_master
(
df_stage_3
,
process_stage_name
=
"Stage-03"
,
process_stage_id
=
"P2E-STAGE-003"
,
process_stage_id
=
"P2E-STAGE-003"
,
batch_product
=
"P2E-Stage-03"
,
ideal_batch_cycle_time_hr
=
2880
,
batch_product
=
"P2E-Stage-03"
,
ideal_batch_cycle_time_hr
=
48
,
batch_setup_time_hr
=
1
)
batch_setup_time_hr
=
1
)
df_stage_4
=
self
.
batch_master
(
df_stage_4
,
process_stage_name
=
"Stage-04"
,
df_stage_4
=
self
.
batch_master
(
df_stage_4
,
process_stage_name
=
"Stage-04"
,
process_stage_id
=
"P2E-STAGE-004"
,
process_stage_id
=
"P2E-STAGE-004"
,
batch_product
=
"P2E-Stage-04"
,
ideal_batch_cycle_time_hr
=
7440
,
batch_product
=
"P2E-Stage-04"
,
ideal_batch_cycle_time_hr
=
124
,
batch_setup_time_hr
=
1
)
batch_setup_time_hr
=
1
)
df_stage_5
=
self
.
batch_master
(
df_stage_5
,
process_stage_name
=
"Stage-05"
,
df_stage_5
=
self
.
batch_master
(
df_stage_5
,
process_stage_name
=
"Stage-05"
,
process_stage_id
=
"P2E-STAGE-005"
,
process_stage_id
=
"P2E-STAGE-005"
,
batch_product
=
"P2E-Stage-05"
,
ideal_batch_cycle_time_hr
=
657
0
,
batch_product
=
"P2E-Stage-05"
,
ideal_batch_cycle_time_hr
=
11
0
,
batch_setup_time_hr
=
1
)
batch_setup_time_hr
=
1
)
df
=
pd
.
concat
([
df_stage_1
,
df_stage_2
,
df_stage_3
,
df_stage_4
,
df_stage_5
],
axis
=
0
)
df
=
pd
.
concat
([
df_stage_1
,
df_stage_2
,
df_stage_3
,
df_stage_4
,
df_stage_5
],
axis
=
0
)
...
@@ -77,9 +78,7 @@ class BatchMaster:
...
@@ -77,9 +78,7 @@ class BatchMaster:
df
=
df
.
round
(
2
)
df
=
df
.
round
(
2
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_master.xlsx"
,
index
=
False
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_master.xlsx"
,
index
=
False
)
logger
.
info
(
f
'Pushing batch_master to postgres'
)
logger
.
info
(
f
'Pushing batch_master to postgres'
)
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_master"
,
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_master"
,
PostgresCred
.
postgres_uri
,
if_exists
=
"replace"
)
"postgresql://ilens:iLens$456@192.168.0.207:5455/ilens_ai"
,
if_exists
=
"replace"
)
logger
.
debug
(
f
'Pushed batch_master to postgres'
)
logger
.
debug
(
f
'Pushed batch_master to postgres'
)
return
df
return
df
...
...
scripts/core/master_tables/batch_material_table.py
View file @
4399ec5c
from
loguru
import
logger
from
loguru
import
logger
import
pandas
as
pd
import
pandas
as
pd
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.core.master_tables.dataframe_read
import
ReadData
from
scripts.constants.app_configuration
import
PostgresCred
class
BatchMaterial
:
class
BatchMaterial
:
...
@@ -71,9 +72,7 @@ class BatchMaterial:
...
@@ -71,9 +72,7 @@ class BatchMaterial:
df
=
df
.
round
(
2
)
df
=
df
.
round
(
2
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_material_master.xlsx"
,
index
=
False
)
df
.
to_excel
(
f
"{self.base_path}/t_batch_material_master.xlsx"
,
index
=
False
)
logger
.
info
(
f
'Pushing batch_master to postgres'
)
logger
.
info
(
f
'Pushing batch_master to postgres'
)
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_material_master"
,
df
.
set_index
(
'batch_no'
)
.
to_sql
(
"t_batch_material_master"
,
PostgresCred
.
postgres_uri
,
if_exists
=
"replace"
)
"postgresql://ilens:iLens$456@192.168.0.207:5455/ilens_ai"
,
if_exists
=
"replace"
)
logger
.
debug
(
f
'Pushed batch_master to postgres'
)
logger
.
debug
(
f
'Pushed batch_master to postgres'
)
return
df
return
df
except
Exception
as
e
:
except
Exception
as
e
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment