Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
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
Container Registry
Model registry
Operate
Environments
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
AURA
engine
Commits
3b25fff8
Commit
3b25fff8
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refactor: add default timeout to requests
parent
4f0b1c67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!35
ORM-less scheduling
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/aura_engine/base/api.py
+8
-6
8 additions, 6 deletions
src/aura_engine/base/api.py
src/aura_engine/plugins/monitor.py
+2
-1
2 additions, 1 deletion
src/aura_engine/plugins/monitor.py
with
10 additions
and
7 deletions
src/aura_engine/base/api.py
+
8
−
6
View file @
3b25fff8
...
...
@@ -204,7 +204,7 @@ class SimpleRestApi:
return
json_data
@exception_handler
def
get
(
self
,
url
:
str
,
headers
:
dict
=
None
)
->
requests
.
Response
:
def
get
(
self
,
url
:
str
,
headers
:
dict
=
None
,
timeout
:
int
=
5
)
->
requests
.
Response
:
"""
GET from an URL.
...
...
@@ -222,13 +222,13 @@ class SimpleRestApi:
json_data
=
None
if
not
headers
:
headers
=
SimpleRestApi
.
default_headers
response
=
requests
.
get
(
url
,
headers
=
headers
)
response
=
requests
.
get
(
url
,
headers
=
headers
,
timeout
=
timeout
)
if
headers
.
get
(
"
content-type
"
)
==
SimpleRestApi
.
CONTENT_JSON
:
json_data
=
self
.
deserialize_json
(
response
)
return
DotDict
({
"
response
"
:
response
,
"
json
"
:
json_data
})
@exception_handler
def
post
(
self
,
url
:
str
,
data
:
dict
,
headers
:
dict
=
None
):
def
post
(
self
,
url
:
str
,
data
:
dict
,
headers
:
dict
=
None
,
timeout
:
int
=
5
):
"""
POST to an URL.
...
...
@@ -248,10 +248,12 @@ class SimpleRestApi:
if
not
headers
:
headers
=
SimpleRestApi
.
default_headers
body
:
str
=
self
.
serialize_json
(
data
)
return
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
return
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
,
timeout
=
timeout
)
@exception_handler
def
put
(
self
,
url
:
str
,
data
:
dict
,
headers
:
dict
=
None
)
->
requests
.
Response
:
def
put
(
self
,
url
:
str
,
data
:
dict
,
headers
:
dict
=
None
,
timeout
:
int
=
5
)
->
requests
.
Response
:
"""
PUT to an URL.
...
...
@@ -271,7 +273,7 @@ class SimpleRestApi:
if
not
headers
:
headers
=
SimpleRestApi
.
default_headers
body
:
str
=
self
.
serialize_json
(
data
)
return
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
return
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
,
timeout
=
timeout
)
class
SimpleCachedRestApi
:
...
...
This diff is collapsed.
Click to expand it.
src/aura_engine/plugins/monitor.py
+
2
−
1
View file @
3b25fff8
...
...
@@ -197,6 +197,7 @@ class AuraMonitor:
body
[
"
isHealthy
"
]
=
is_healthy
body
[
"
details
"
]
=
json
.
dumps
(
data
,
default
=
str
)
json_data
=
json
.
dumps
(
body
,
default
=
str
)
timeout
=
5
url
=
self
.
config
.
get
(
"
api_engine_store_health
"
)
url
=
url
.
replace
(
"
${ENGINE_NUMBER}
"
,
str
(
self
.
config
.
get
(
"
api_engine_number
"
)))
headers
=
{
"
content-type
"
:
"
application/json
"
}
...
...
@@ -204,7 +205,7 @@ class AuraMonitor:
response
.
status_code
=
404
try
:
response
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
)
response
=
requests
.
post
(
url
,
data
=
json_data
,
headers
=
headers
,
timeout
=
timeout
)
if
response
.
status_code
==
204
:
self
.
logger
.
info
(
"
Successfully posted healthy=%s state to Engine API!
"
%
is_healthy
...
...
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