Skip to content

Commit

Permalink
fix issues and clean the code
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Sep 20, 2024
1 parent db80170 commit 8550ecb
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ jobs:
# run indexing indexing
python manage.py get_index_data_from_database -b False
# set up the seond database
python manage.py set_database_configuration -u localhost -s ${{ job.services.postgres_2.ports[5433] }} -n postgress -p passwprd -w omero_train -d omero_train -b omero_train.pgdump
python manage.py restore_postgresql_database -s omero1
python manage.py set_database_configuration -u localhost -s ${{ job.services.postgres_2.ports[5433] }} -n postgress -p passwprd -w omero_train -d omero_train -b omero_train.pgdump
#python manage.py restore_postgresql_database -s omero1
# run tests
python -m unittest discover -s unit_tests
upload:
Expand Down
6 changes: 3 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def get_index_data_from_database(resource="all", source="all", backup="True"):
if clean_index:
clean_index = False
# validat ethe indexing
test_indexing_search_query(
source=data_source, deep_check=False, check_studies=True
)
#test_indexing_search_query(
# source=data_source, deep_check=False, check_studies=True
#)

# backup the index data
# if backup:
Expand Down
9 changes: 3 additions & 6 deletions omero_search_engine/api/v1/resources/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def __init__(
self.return_columns = return_columns
self.return_containers = return_containers
self.data_source=data_source
print ("TOOOOOOOOOOOOOOOOOOZ::::::::", self.data_source)

def get_image_non_image_query(self):
res = None
Expand Down Expand Up @@ -429,7 +428,6 @@ def run_query(self, query_, resource):
data_source=self.data_source
)
else:
print("TOOOOOOOOOOOOOOOOZ2:",self.data_source)
res = search_query(
query,
resource,
Expand Down Expand Up @@ -461,14 +459,13 @@ def search_query(
search_omero_app.logger.info(
"-------------------------------------------------"
) # noqa
search_omero_app.logger.info(query)
search_omero_app.logger.info(main_attributes)
search_omero_app.logger.info("1: %s"%query)
search_omero_app.logger.info("2: %s"%main_attributes)
search_omero_app.logger.info(resource)
search_omero_app.logger.info(
"-------------------------------------------------"
) # noqa
print ("TOOOOOOOOOOZZ33::::", data_source)
search_omero_app.logger.info(("%s, %s") % (resource, query))
search_omero_app.logger.info(("1... %s, 2....%s") % (resource, query))
if not main_attributes:
q_data = {"query": {"query_details": query}}
elif resource == "image":
Expand Down
5 changes: 0 additions & 5 deletions omero_search_engine/api/v1/resources/resource_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,6 @@ def get_resource_names(resource, name=None, description=False):
for res in ress:
returned_results[res] = get_the_results(res, name, description)

print("#############################################")
print(returned_results)
print("#############################################")
return returned_results


Expand Down Expand Up @@ -965,10 +962,8 @@ def get_container_values_for_key(table_, container_name, csv, ret_data_source=No
ret_data_source = [itm.strip().lower() for itm in ret_data_source.split(',')]
for resourse, names_ in pr_names.items():
for data_source, names in names_.items():
print ("====>>>>>",data_source, names)
if ret_data_source:
if data_source.lower() not in ret_data_source:
print ("TTTTTCONAZZZ",ret_data_source)
continue
act_name = [
{"id": name["id"], "name": name["name"]}
Expand Down
6 changes: 0 additions & 6 deletions omero_search_engine/api/v1/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,6 @@ def search_resource_annotation(
@raw_elasticsearch_query: raw query sending directly to elasticsearch
"""
# try:
print ("tiiiiiiiiz")
print (data_source)
print("tiiiiiiiiz")
res_index = resource_elasticsearchindex.get(table_)
if not res_index:
return build_error_message(
Expand All @@ -1140,7 +1137,6 @@ def search_resource_annotation(
or len(query_details) == 0
or isinstance(query_details, str)
):
print("Error ")
return build_error_message(
"{query} is not a valid query".format(query=query)
)
Expand Down Expand Up @@ -1186,7 +1182,6 @@ def search_resource_annotation(
query = raw_elasticsearch_query
raw_query_to_send_back = copy.copy(raw_elasticsearch_query)
if return_containers:
print ("1222222222222222222222")
# code to return the containers only
# It will call the projects container first then
# search within screens
Expand Down Expand Up @@ -1214,7 +1209,6 @@ def search_resource_annotation(
studies = res + res_2
res = {"results": studies}
else:
print ("333333333333333333333")
res = search_index_using_search_after(
res_index, query, bookmark, pagination_dict, return_containers, data_source=data_source
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@ def delete_es_index(es_index):
search_omero_app.logger.info("ERROR:" + error["root_cause"])
search_omero_app.logger.info("TYPE:" + error["type"])
return False

# print out the response:
search_omero_app.logger.info("\nresponse:%s" % str(response))
else:
search_omero_app.logger.info("\nIndex %s is not found" % str(es_index))
return False
return True


def delete_data_from_index(resource):
if resource_elasticsearchindex.get(resource) and resource != "all":
es_index = resource_elasticsearchindex[resource]
Expand Down Expand Up @@ -730,7 +728,6 @@ def save_key_value_buckets(
push_keys_cache_index(
resource_keys, resource_table, data_source, es_index_2, name_results
)
print(type(resource_keys), type(resource_table), es_index_2, type(name_results))
if only_values:
continue
search_omero_app.logger.info(
Expand Down
7 changes: 4 additions & 3 deletions omero_search_engine/validation/results_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,15 +1054,16 @@ def get_no_images_sql_containers(data_source, write_report=True):
messages.append(
"######################## Checking %s ########################\n" % resource
)

search_omero_app.logger.info( "######################## Checking %s ########################\n" % resource)
# this may be used for a specific data source
for data_source, res_name__ in all_names.get(resource).items():
pass

for res_name_ in res_name__: # all_names.get(resource):
res_name = res_name_.get("name")
message1 = "Checking %s name: %s" % (resource, res_name)
messages.append(message1)
search_omero_app.logger.info(message1)

search_omero_app.logger.info("####>>>message: %s"%message1)
and_filters = [
{
"name": "name",
Expand Down
13 changes: 12 additions & 1 deletion unit_tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ def test_query_database(self):
data_source
].execute_query(sql)
self.assertIsNotNone(res)
self.assertEqual(res[0]["current_database"], "omero")
found_db_name = False
for source in search_omero_app.config.get("DATA_SOURCES"):
if source.get("DATABASE").get("DATABASE_NAME") == res[0]["current_database"]:
found_db_name = True
break

#for data_source in search_omero_app.config.database_connectors.keys():
# res = search_omero_app.config.database_connectors[
# data_source
# ].execute_query(sql)
# self.assertIsNotNone(res)
# self.assertEqual(res[0]["current_database"], "omero")

def validate_json_syntax(self, json_template):
try:
Expand Down

0 comments on commit 8550ecb

Please sign in to comment.