Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
ES Subset Generator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ChEMBL
C
ChEMBL
Main Web Interface
ES Subset Generator
Commits
1913f2cd
Commit
1913f2cd
authored
Aug 12, 2020
by
David Mendez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoint to check status of subindex generation task
parent
a96a6934
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
5 deletions
+84
-5
app/__init__.py
app/__init__.py
+2
-0
app/blueprints/subset_generator_blueprint/controllers/marshmallow_schemas.py
...et_generator_blueprint/controllers/marshmallow_schemas.py
+8
-1
app/blueprints/subset_generator_blueprint/controllers/subset_generator_controller.py
...ator_blueprint/controllers/subset_generator_controller.py
+23
-2
app/blueprints/subset_generator_blueprint/services/subset_generator_service.py
..._generator_blueprint/services/subset_generator_service.py
+20
-2
app/swagger/swagger.yaml
app/swagger/swagger.yaml
+31
-0
No files found.
app/__init__.py
View file @
1913f2cd
...
...
@@ -8,6 +8,7 @@ from flask_cors import CORS
from
app.config
import
RUN_CONFIG
# from app.cache import CACHE
from
app.blueprints.swagger_description.swagger_description_blueprint
import
SWAGGER_BLUEPRINT
from
app.blueprints.subset_generator_blueprint.controllers.subset_generator_controller
import
SUBSET_GENERATOR_BLUEPRINT
def
create_app
():
...
...
@@ -37,6 +38,7 @@ def create_app():
# CACHE.cache._client.behaviors['retry_timeout'] = 600
flask_app
.
register_blueprint
(
SWAGGER_BLUEPRINT
,
url_prefix
=
f'
{
base_path
}
/swagger'
)
flask_app
.
register_blueprint
(
SUBSET_GENERATOR_BLUEPRINT
,
url_prefix
=
f'
{
base_path
}
/es_subsets'
)
return
flask_app
...
...
app/blueprints/subset_generator_blueprint/controllers/marshmallow_schemas.py
View file @
1913f2cd
...
...
@@ -9,5 +9,12 @@ class SubmitSubsetGenerationRequest(Schema):
Class with the schema for submitting the generation of a subset
"""
origin_index
=
fields
.
String
(
required
=
True
)
items_ids
=
fields
.
Nested
(
required
=
True
)
items_ids
=
fields
.
String
(
required
=
True
,
many
=
True
)
class
SubsetGenerationStatusRequest
(
Schema
):
"""
Class with the schema for requesting the status of a subset generation task
"""
task_id
=
fields
.
String
(
required
=
True
)
app/blueprints/subset_generator_blueprint/controllers/subset_generator_controller.py
View file @
1913f2cd
...
...
@@ -8,7 +8,6 @@ from app.blueprints.subset_generator_blueprint.services import subset_generator_
from
app.request_validation.decorators
import
validate_form_with
,
validate_url_params_with
from
app
import
app_logging
SUBSET_GENERATOR_BLUEPRINT
=
Blueprint
(
'es_subsets'
,
__name__
)
...
...
@@ -28,8 +27,30 @@ def submit_subset_creation_from_ids():
try
:
return
jsonify
({
'msg'
:
'hola'
})
submission_response
=
subset_generator_service
.
submit_subset_generation_from_ids
(
origin_index
,
items_ids
)
return
jsonify
(
submission_response
)
except
subset_generator_service
.
SubsetGeneratorServiceError
as
error
:
abort
(
500
,
msg
=
f'Internal server error:
{
str
(
error
)
}
'
)
@
SUBSET_GENERATOR_BLUEPRINT
.
route
(
'/get_task_status/<task_id>'
,
methods
=
[
'GET'
])
@
validate_url_params_with
(
marshmallow_schemas
.
SubsetGenerationStatusRequest
)
def
get_task_status
(
task_id
):
"""
:param task_id: id of the task to check
:return: json response with status of the task
"""
try
:
status_response
=
subset_generator_service
.
get_task_status
(
task_id
)
return
jsonify
(
status_response
)
except
subset_generator_service
.
SubsetGeneratorServiceError
as
error
:
abort
(
500
,
msg
=
f'Internal server error:
{
str
(
error
)
}
'
)
except
subset_generator_service
.
SubsetGenerationTaskNotFoundError
as
error
:
abort
(
404
,
repr
(
error
))
\ No newline at end of file
app/blueprints/subset_generator_blueprint/services/subset_generator_service.py
View file @
1913f2cd
...
...
@@ -4,7 +4,11 @@ Subset generator service
class
SubsetGeneratorServiceError
(
Exception
):
"""Base class for exceptions in the properties configuration service."""
"""Base class for exceptions in the subset generation service."""
class
SubsetGenerationTaskNotFoundError
(
Exception
):
"""Base class for exceptions in the subset generation service."""
def
submit_subset_generation_from_ids
(
origin_index
,
items_ids
):
...
...
@@ -12,9 +16,23 @@ def submit_subset_generation_from_ids(origin_index, items_ids):
Starts the process of the generation of the subset based on the ids passed as parameter
:param origin_index: source index for the subset
:param items_ids: ids of the items to include
:return: a
n
id of the task to check it's progress
:return: a
dict with the
id of the task to check it's progress
"""
return
{
'task_id'
:
'some_id'
}
def
get_task_status
(
task_id
):
"""
:param task_id: the task id to check
:return: a dict describing the status of the task
"""
return
{
'task_status'
:
'RUNNING'
,
'progress'
:
50
,
'num_items_in_subset'
:
'20000'
,
'subset_index_name'
:
'subset_index'
}
app/swagger/swagger.yaml
View file @
1913f2cd
...
...
@@ -48,9 +48,40 @@ paths:
description
:
"
successful
operation"
schema
:
$ref
:
'
#/definitions/SubsetOperationResponse'
/es_subsets/get_task_status/{task_id}
:
get
:
tags
:
-
'
ES
subsets'
summary
:
'
Returns
the
status
of
the
subset
creation
task'
description
:
'
After
submitting
a
task
to
create
a
subset,
it
returns
the
status
of
the
subset
creation
task'
operationId
:
'
get_subset_index_creation_status'
produces
:
-
'
application/json'
parameters
:
-
name
:
'
task_id'
in
:
'
path'
description
:
'
Id
of
the
task
to
check'
required
:
true
type
:
'
string'
responses
:
'
200'
:
description
:
"
successful
operation"
schema
:
$ref
:
'
#/definitions/SubsetCreationStatusResponse'
definitions
:
SubsetOperationResponse
:
type
:
'
object'
properties
:
task_id
:
type
:
'
string'
SubsetCreationStatusResponse
:
type
:
'
object'
properties
:
task_status
:
type
:
'
string'
progress
:
type
:
'
integer'
num_items_in_subset
:
type
:
'
integer'
subset_index_name
:
type
:
'
string'
\ No newline at end of file
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