Skip to content

Commit

Permalink
fix issue of test indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Aug 23, 2024
1 parent 5e06368 commit ec58235
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 44 deletions.
9 changes: 6 additions & 3 deletions omero_search_engine/api/v1/resources/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,12 @@ def run_query(self, query_, resource):
# main_attributes,return_containers=self.return_containers)
global res_and_main_attributes, res_or_main_attributes
if res_and_main_attributes:
main_attributes["and_main_attributes"] = (
main_attributes.get("and_main_attributes") + res_and_main_attributes
)
if main_attributes.get("and_main_attributes"):
main_attributes["and_main_attributes"] = (
main_attributes.get("and_main_attributes") + res_and_main_attributes
)
else:
main_attributes["and_main_attributes"] = res_and_main_attributes
if resource == "image" and self.return_containers:
res = search_query(
query,
Expand Down
85 changes: 44 additions & 41 deletions omero_search_engine/validation/results_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,51 +872,54 @@ def test_no_images():


def get_omero_stats():
values = ["Attribute", "No. buckets", "Total number", "Resource"]
base_folder = search_omero_app.config.get("BASE_FOLDER")
if not os.path.isdir(base_folder):
base_folder = os.path.expanduser("~")
stats_file = os.path.join(base_folder, "stats.csv")

from omero_search_engine.api.v1.resources.resource_analyser import (
get_restircted_search_terms,
query_cashed_bucket,
)
for data_source in search_omero_app.config.database_connectors.keys():
values = ["Attribute", "No. buckets", "Total number", "Resource", "Data Source"]
base_folder = search_omero_app.config.get("BASE_FOLDER")
if not os.path.isdir(base_folder):
base_folder = os.path.expanduser("~")
stats_file = os.path.join(base_folder, "stats.csv")

from omero_search_engine.api.v1.resources.resource_analyser import (
get_restircted_search_terms,
query_cashed_bucket,
)

data = []
terms = get_restircted_search_terms()
data.append(",".join(values))
for resource, names in terms.items():
for name in names:
if name == "name":
continue
returned_results = query_cashed_bucket(name, resource)
if resource == "image":
data.append(
"%s, %s, %s,%s"
% (
name,
returned_results.get("total_number_of_buckets"),
returned_results.get("total_number_of_image"),
resource,
data = []
terms = get_restircted_search_terms()
data.append(",".join(values))
for resource, names in terms.items():
for name in names:
if name == "name":
continue
returned_results = query_cashed_bucket(name, resource, [data_source])
if resource == "image":
data.append(
"%s, %s, %s,%s,%s"
% (
name,
returned_results.get("total_number_of_buckets"),
returned_results.get("total_number_of_image"),
resource,
data_source,
)
)
)
else:
kk = "total_number_of_%s" % resource
data.append(
"%s, %s, %s,%s"
% (
name,
returned_results.get("total_number_of_buckets"),
returned_results.get(kk),
resource,
else:
kk = "total_number_of_%s" % resource
data.append(
"%s, %s, %s,%s,%s"
% (
name,
returned_results.get("total_number_of_buckets"),
returned_results.get(kk),
resource,
data_source,
)
)
)

for dat in returned_results.get("data"):
if not dat["Value"]:
print("Value is empty string", dat["Key"])
report = "\n".join(data)
for dat in returned_results.get("data"):
if not dat["Value"]:
print("Value is empty string", dat["Key"])
report = "\n".join(data)

with open(stats_file, "w") as f:
f.write(report)
Expand Down

0 comments on commit ec58235

Please sign in to comment.