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
d204bffe
Commit
d204bffe
authored
Aug 18, 2020
by
David Mendez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement parsing of a single property in source for mapping
parent
d9dd45c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
app/es_subset_generator/mappings.py
app/es_subset_generator/mappings.py
+8
-6
app/es_subset_generator/test/test_mappings_handling.py
app/es_subset_generator/test/test_mappings_handling.py
+12
-2
No files found.
app/es_subset_generator/mappings.py
View file @
d204bffe
...
...
@@ -24,13 +24,18 @@ def parse_mapping_from_es_response(index_mapping, required_source):
"""
Reads the response of the mapping from ES and produces the mapping to use for the subset index
:param index_mapping: mapping dict obtained from es
:param required_source: source (list of properties) to get from the mapping
:return: the mapping ready to be applied to the subset index
"""
mappings_to_apply
=
{
'properties'
:
{}
}
for
source_property
in
required_source
:
print
(
f'locating:
{
source_property
}
'
)
for
current_property
in
required_source
:
mapping_to_apply
=
get_mapping_to_apply_in_subset_index
(
index_mapping
,
current_property
)
mappings_to_apply
[
'properties'
][
current_property
]
=
mapping_to_apply
print
(
index_mapping
)
return
mappings_to_apply
def
get_mapping_to_apply_in_subset_index
(
index_mapping
,
property_path
):
...
...
@@ -44,14 +49,11 @@ def get_mapping_to_apply_in_subset_index(index_mapping, property_path):
is_nested
=
source_property_config
.
get
(
'properties'
)
is
not
None
if
not
is_nested
:
mapping_to_apply
=
{
'type'
:
source_property_config
[
'type'
]
}
return
mapping_to_apply
mapping_to_apply
=
{
'properties'
:
{}
}
...
...
app/es_subset_generator/test/test_mappings_handling.py
View file @
d204bffe
...
...
@@ -22,8 +22,18 @@ class TestMappingsHandling(unittest.TestCase):
with
open
(
sample_mapping_path
,
'rt'
)
as
sample_mapping_file
:
mapping_from_base_index
=
json
.
load
(
sample_mapping_file
)
source
=
[
'pref_name'
]
mappings
.
parse_mapping_from_es_response
(
mapping_from_base_index
,
source
)
# FINISH THIS!
mappings_to_apply_got
=
mappings
.
parse_mapping_from_es_response
(
mapping_from_base_index
,
source
)
mappings_to_apply_must_be
=
{
"properties"
:
{
'pref_name'
:
{
'type'
:
'keyword'
},
}
}
self
.
assertEqual
(
mappings_to_apply_got
,
mappings_to_apply_must_be
,
msg
=
'The mappings were not produced correctly!'
)
def
test_locates_source_config_of_property
(
self
):
"""
...
...
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