Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
632699b8
Commit
632699b8
authored
4 years ago
by
Lorenz Boguhn
Browse files
Options
Downloads
Patches
Plain Diff
Fixed old python scripts
parent
d1bef630
No related branches found
No related tags found
4 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!96
Handle shutdown
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
slope-evaluator/api.py
+25
-11
25 additions, 11 deletions
slope-evaluator/api.py
slope-evaluator/trend_slope_computer.py
+2
-1
2 additions, 1 deletion
slope-evaluator/trend_slope_computer.py
with
27 additions
and
12 deletions
slope-evaluator/api.py
+
25
−
11
View file @
632699b8
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
,
Request
import
trend_slope_computer
as
trend_slope_computer
import
trend_slope_computer
as
trend_slope_computer
import
logging
import
logging
import
os
import
os
import
pandas
as
pd
import
pandas
as
pd
import
json
import
numpy
as
np
from
fastapi.encoders
import
jsonable_encoder
app
=
FastAPI
()
app
=
FastAPI
()
def
execute
(
results
,
threshold
):
@app.get
(
"
/evaluate-slope
"
)
d
=
[]
def
evaluate_slope
(
total_lag
):
for
result
in
results
:
print
(
"
request received
"
)
#print(results)
print
(
total_lag
)
group
=
result
[
'
metric
'
][
'
group
'
]
execute
(
total_lag
,
1000
)
for
value
in
result
[
'
values
'
]:
return
{
"
suitable
"
:
"
false
"
}
# print(value)
d
.
append
({
'
group
'
:
group
,
'
timestamp
'
:
int
(
value
[
0
]),
'
value
'
:
int
(
value
[
1
])
if
value
[
1
]
!=
'
NaN
'
else
0
})
df
=
pd
.
DataFrame
(
d
)
def
execute
(
total_lag
,
threshold
):
print
(
df
)
df
=
pd
.
DataFrame
(
total_lag
)
try
:
try
:
trend_slope
=
trend_slope_computer
.
compute
(
df
,
6
0
)
trend_slope
=
trend_slope_computer
.
compute
(
df
,
0
)
except
Exception
as
e
:
except
Exception
as
e
:
err_msg
=
'
Computing trend slope failed
'
err_msg
=
'
Computing trend slope failed
'
print
(
err_msg
)
print
(
err_msg
)
...
@@ -30,3 +35,12 @@ def execute(total_lag, threshold):
...
@@ -30,3 +35,12 @@ def execute(total_lag, threshold):
print
(
f
"
Trend Slope:
{
trend_slope
}
"
)
print
(
f
"
Trend Slope:
{
trend_slope
}
"
)
return
trend_slope
<
threshold
return
trend_slope
<
threshold
@app.post
(
"
/evaluate-slope
"
,
response_model
=
bool
)
async
def
evaluate_slope
(
request
:
Request
):
print
(
"
request received
"
)
x
=
json
.
loads
(
await
request
.
body
())
#x = np.array(x['total_lag'])
y
=
execute
(
x
[
'
total_lag
'
],
1000
)
print
(
print
(
y
))
return
y
This diff is collapsed.
Click to expand it.
slope-evaluator/trend_slope_computer.py
+
2
−
1
View file @
632699b8
...
@@ -2,7 +2,8 @@ from sklearn.linear_model import LinearRegression
...
@@ -2,7 +2,8 @@ from sklearn.linear_model import LinearRegression
import
pandas
as
pd
import
pandas
as
pd
import
os
import
os
def
compute
(
input
,
warmup_sec
):
def
compute
(
x
,
warmup_sec
):
input
=
x
input
[
'
sec_start
'
]
=
input
.
loc
[
0
:,
'
timestamp
'
]
-
input
.
iloc
[
0
][
'
timestamp
'
]
input
[
'
sec_start
'
]
=
input
.
loc
[
0
:,
'
timestamp
'
]
-
input
.
iloc
[
0
][
'
timestamp
'
]
regress
=
input
.
loc
[
input
[
'
sec_start
'
]
>=
warmup_sec
]
# Warm-Up
regress
=
input
.
loc
[
input
[
'
sec_start
'
]
>=
warmup_sec
]
# Warm-Up
...
...
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