Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dsa2-gunasinha
CSCT
Commits
e4e2ba5a
Commit
e4e2ba5a
authored
2 years ago
by
amilashanaka
Browse files
Options
Downloads
Patches
Plain Diff
add new endpoints
parent
c4e873e0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/run.py
+72
-2
72 additions, 2 deletions
api/run.py
with
72 additions
and
2 deletions
api/run.py
+
72
−
2
View file @
e4e2ba5a
...
@@ -9,6 +9,7 @@ from app import app
...
@@ -9,6 +9,7 @@ from app import app
import
pandas
as
pd
import
pandas
as
pd
import
datetime
as
dt
import
datetime
as
dt
import
numpy
as
np
import
numpy
as
np
import
json
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
create_engine
...
@@ -23,6 +24,9 @@ from flask import flash, request
...
@@ -23,6 +24,9 @@ from flask import flash, request
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
matplotlib.dates
as
mdates
import
seaborn
as
sns
sns
.
set_theme
(
style
=
"
darkgrid
"
)
#=================================================
#=================================================
...
@@ -199,6 +203,72 @@ setup()
...
@@ -199,6 +203,72 @@ setup()
# end points declaration
# end points declaration
@app.route
(
"
/plot_order-demands
"
,
methods
=
[
'
GET
'
])
def
plot_order_demands_total
():
global
raw_data_set
sns
.
lineplot
(
x
=
'
Date
'
,
y
=
'
Order_Demand
'
,
hue
=
'
Warehouse
'
,
data
=
raw_data_set
)
plt
.
figure
(
figsize
=
(
20
,
7
))
plt
.
xticks
(
rotation
=
15
)
plt
.
gcf
().
autofmt_xdate
()
plt
.
legend
()
plt
.
show
()
return
"
Order demand
"
@app.route
(
"
/plot_order_demand_total
"
,
methods
=
[
'
GET
'
])
def
plot_order_demands
():
global
data_set
import
matplotlib.pyplot
as
plt
from
matplotlib.ticker
import
(
MultipleLocator
,
FormatStrFormatter
,
AutoMinorLocator
)
import
matplotlib.dates
as
mdates
dtFmt
=
mdates
.
DateFormatter
(
'
%Y-%b
'
)
# define the formatting
sns
.
lineplot
(
x
=
'
Date
'
,
y
=
'
Order_Demand
'
,
data
=
data_set
)
plt
.
figure
(
figsize
=
(
20
,
7
))
plt
.
gca
().
xaxis
.
set_major_formatter
(
dtFmt
)
# show every 12th tick on x axes
plt
.
gca
().
xaxis
.
set_major_locator
(
mdates
.
MonthLocator
(
interval
=
1
))
plt
.
xticks
(
rotation
=
90
,
fontweight
=
'
light
'
,
fontsize
=
'
x-small
'
,)
plt
.
legend
()
plt
.
show
()
return
"
Order demand
"
@app.route
(
"
/products
"
,
methods
=
[
'
GET
'
])
def
products
():
global
raw_data_set
result_array
=
raw_data_set
[
'
Product_code
'
].
unique
()
return
result_array
.
tolist
()
@app.route
(
"
/date_range
"
,
methods
=
[
'
GET
'
])
def
date_range
():
result_array
=
data_set
[
'
Date
'
].
unique
()
return
result_array
.
tolist
()
@app.route
(
"
/warehouse
"
,
methods
=
[
'
GET
'
])
def
warehouse
():
global
raw_data_set
warehouse_array
=
raw_data_set
[
'
Warehouse
'
].
unique
()
return
warehouse_array
.
tolist
()
@app.route
(
"
/row_data
"
,
methods
=
[
'
GET
'
])
def
row_data
():
global
raw_data_set
return
raw_data_set
.
to_json
(
orient
=
'
records
'
)
@app.route
(
"
/validation
"
,
methods
=
[
'
GET
'
])
@app.route
(
"
/validation
"
,
methods
=
[
'
GET
'
])
def
validation
():
def
validation
():
...
@@ -207,7 +277,7 @@ def validation():
...
@@ -207,7 +277,7 @@ def validation():
return
result
.
to_json
(
orient
=
'
records
'
)
return
result
.
to_json
(
orient
=
'
records
'
)
@app.route
(
"
/forecast_to_date
"
,
methods
=
[
"
POST
"
])
@app.route
(
"
/forecast_to_date
"
,
methods
=
[
"
POST
"
])
def
forecast
():
def
forecast
_to_date
():
global
data_set
global
data_set
global
scaler
global
scaler
global
index_data_set
global
index_data_set
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment