Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
a79a9bea
Commit
a79a9bea
authored
4 years ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Create the webservice's MyMDC client in a non-blocking thread executor
parent
51adb1de
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webservice/webservice.py
+20
-14
20 additions, 14 deletions
webservice/webservice.py
with
20 additions
and
14 deletions
webservice/webservice.py
+
20
−
14
View file @
a79a9bea
...
@@ -49,25 +49,31 @@ async def init_job_db(config):
...
@@ -49,25 +49,31 @@ async def init_job_db(config):
return
conn
return
conn
async
def
init_md_client
(
config
)
:
async
def
init_md_client
(
config
:
Dict
[
str
,
Dict
[
str
,
str
]])
->
MetadataClient
:
"""
Initialize an MDC client connection
"""
Initialize an MDC client connection
.
:param config: the configuration parsed from the webservice YAML config
:param config: the configuration parsed from the webservice YAML config
:return: an MDC client connection
:return: an MDC client connection
"""
"""
# FIXME: this blocks the even loop, should use asyncio.Task
# FIXME: calls to this coro should be shielded
# TODO: could the client be a global? This would recuce passing it around
# TODO: could the client be a global? This would recuce passing it around
mdconf
=
config
[
'
metadata-client
'
]
client_conn
=
MetadataClient
(
client_id
=
mdconf
[
'
user-id
'
],
# During MetadataClient initialisation, this object requests authentication from MyMDC
client_secret
=
mdconf
[
'
user-secret
'
],
# As such, it is needed to run the initialisation in a thread.
user_email
=
mdconf
[
'
user-email
'
],
def
_init_client
():
token_url
=
mdconf
[
'
token-url
'
],
mdconf
=
config
[
'
metadata-client
'
]
refresh_url
=
mdconf
[
'
refresh-url
'
],
client_conn
=
MetadataClient
(
client_id
=
mdconf
[
'
user-id
'
],
auth_url
=
mdconf
[
'
auth-url
'
],
client_secret
=
mdconf
[
'
user-secret
'
],
scope
=
mdconf
[
'
scope
'
],
user_email
=
mdconf
[
'
user-email
'
],
base_api_url
=
mdconf
[
'
base-api-url
'
])
token_url
=
mdconf
[
'
token-url
'
],
return
client_conn
refresh_url
=
mdconf
[
'
refresh-url
'
],
auth_url
=
mdconf
[
'
auth-url
'
],
scope
=
mdconf
[
'
scope
'
],
base_api_url
=
mdconf
[
'
base-api-url
'
])
return
client_conn
loop
=
get_event_loop
()
client
=
await
shield
(
loop
.
run_in_executor
(
None
,
_init_client
))
return
client
def
init_config_repo
(
config
):
def
init_config_repo
(
config
):
...
...
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