Skip to content

Commit

Permalink
Fix pre-commit format
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Sep 29, 2024
1 parent 1e19b5d commit 32d7980
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
8 changes: 4 additions & 4 deletions omero_search_engine/api/v1/resources/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check_get_names(idr_, resource, attribute, return_exact=False):
if idr_:
idr_ = idr_.strip()
pr_names = get_resource_names(resource)
all_act_names=[]
all_act_names = []
if pr_names:
if not return_exact:
for data_source, pr_names_ in pr_names.items():
Expand All @@ -53,8 +53,8 @@ def check_get_names(idr_, resource, attribute, return_exact=False):
for name in pr_names_
if name[attribute] and idr_.lower() in name[attribute].lower()
]
print (act_name, data_source)
all_act_names=all_act_names+act_name
print(act_name, data_source)
all_act_names = all_act_names + act_name
else:
# This should be modified to query specific data source specific
for data_source, pr_names_ in pr_names.items():
Expand Down Expand Up @@ -465,7 +465,7 @@ def search_query(
"-------------------------------------------------"
) # noqa
# search_omero_app.logger.info("1. query: %s" % query)
search_omero_app.logger.info("2. main_attributes: %s "%main_attributes)
search_omero_app.logger.info("2. main_attributes: %s " % main_attributes)
search_omero_app.logger.info(resource)
search_omero_app.logger.info(
"-------------------------------------------------"
Expand Down
21 changes: 13 additions & 8 deletions omero_search_engine/api/v1/resources/resource_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def search_value_for_resource(
Search using key, part of the value and resource
"""
key_part_values_buckets_template = Template(
"""{"query":{"bool":{"must":[{"bool":{"must":[{
"""{"query":{"bool":{"must":[{"bool":{"must":[{
"match":{"Attribute.keyrnamenormalize":"$name"}},
{"wildcard":{"Value.keyvaluenormalize":"*$value*"}
}]}},{"bool":{"must":[{"match":{"resource.keyresource":"$resource"}
Expand Down Expand Up @@ -680,29 +680,34 @@ def search_value_for_resource(
"bool": {"must": {"match":{"resource.keyresource": "$resource"}}}}]}}}"""
)

resource_key_values_buckets_template = Template(
resource_key_values_buckets_template = Template( # noqa
"""
{"query":{"bool":{"must":[{"bool":{
"must":{"wildcard":{"Value.keyvaluenormalize":"*$value*"}}}},{
"bool": {"must": {"match":{"resource.keyresource": "$resource"}}}},{"bool":{
"must":{"terms":{ "data_source.keyvalue":$data_source}}}}]}},
"size": 9999, "sort":[{ "_script": {"script": "doc['Value.keyvaluenormalize'].value.length()","type": "number","order": "asc"}},{"items_in_the_bucket": "desc"}, {"id": "asc"}]}"""
"size": 9999, "sort":[{ "_script":
{"script": "doc['Value.keyvaluenormalize'].value.length()",
"type": "number","order": "asc"}},
{"items_in_the_bucket": "desc"}, {"id": "asc"}]}"""
)

key_values_buckets_template_2 = Template(
"""
{"query":{"bool":{"must":[{"bool":{"must":{"match":{"resource.keyresource":"$resource"}}}}]}}} """
{"query":{"bool":{"must":[{"bool":
{"must":{"match":{"resource.keyresource":"$resource"}}}}]}}} """
)

key_values_buckets_template_with_data_source = Template(
"""
{"query":{"bool":{"must":[{"bool":{"must":{"match":{"resource.keyresource":"$resource"}}}},{"bool": {"must":{"match": {"data_source.keyvalue":$data_source}}}}]}}} """
{"query":{"bool":{"must":[{"bool":{"must":{"match":{"resource.keyresource":"$resource"}}}},
{"bool":{"must":{"match": {"data_source.keyvalue":$data_source}}}}]}}} """
)

key_values_buckets_template_search_name = Template(
"""
{"query":{"bool":{"must":[{"bool":{"must":{"match":{"resource.keyresource":"$resource"}}}},{"bool": {"must":{"wildcard": {"resourcename.keyresourcename":"*$name*"}}}}]}}} """
)
{"query":{"bool":{"must":[{"bool":{"must":{"match":{"resource.keyresource":"$resource"}}}},
{"bool": {"must":{"wildcard": {"resourcename.keyresourcename":"*$name*"}}}}]}}} """
) # noqa


def connect_elasticsearch(es_index, query, count=False):
Expand Down
4 changes: 2 additions & 2 deletions omero_search_engine/api/v1/resources/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def index():
@resources.route("/data_resources/", methods=["GET"])
def return_data_resources():
"""
file: swagger_docs/datasources.yml
"""
file: swagger_docs/datasources.yml
"""
"""
used to return the available data resources
"""
Expand Down
3 changes: 1 addition & 2 deletions omero_search_engine/api/v1/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,13 +1170,12 @@ def search_resource_annotation(
main_attributes = {}
main_attributes["and_main_attributes"] = [clause]


and_filters = query_details.get("and_filters")
or_filters = query_details.get("or_filters")
case_sensitive = query_details.get("case_sensitive")
# check and fid if possible names and values inside
# filters conditions
#check_filters is cpmmented as it has no actual use and take time to excute
# check_filters is cpmmented as it has no actual use and take time to excute
# check_filters(table_, [and_filters, or_filters], case_sensitive)
query_string = elasticsearch_query_builder(
and_filters, or_filters, case_sensitive, main_attributes
Expand Down
7 changes: 3 additions & 4 deletions unit_tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

from omero_search_engine.validation.results_validator import (
Validator,
check_number_images_sql_containers_using_ids,
# check_number_images_sql_containers_using_ids,
)
from omero_search_engine.cache_functions.elasticsearch.transform_data import (
delete_es_index,
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_add_submit_query_delete_es_index(self):
"""'
test submit query and get results
"""
table = "image1"
# table = "image1"
table_2 = "image"
es_index = "image_keyvalue_pair_metadata_1"
es_index_2 = "key_values_resource_cach"
Expand Down Expand Up @@ -233,11 +233,10 @@ def test_or_query(self):
)
self.assertTrue(validator.identical)

#def test_no_images_containers(self):
# def test_no_images_containers(self):
# for data_source in search_omero_app.config.database_connectors.keys():
# self.assertTrue(check_number_images_sql_containers_using_ids(data_source))


def test_multi_or_quries(self):
pass

Expand Down

0 comments on commit 32d7980

Please sign in to comment.