Skip to content

Commit

Permalink
Merge pull request #217 from VirtualFlyBrain/hotfix1
Browse files Browse the repository at this point in the history
removing white from the random colour selection
  • Loading branch information
Robbie1977 authored Sep 5, 2024
2 parents cb3be31 + 53f70d1 commit d1dcfd4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vfb_connect/cross_server_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ def generate_lab_colors(self, num_colors, min_distance=100, verbose=False):
rgb_colors = []

# Select the first color
lab_tree = KDTree([(0, 0, 0)]) # Start tree with black
lab_tree = KDTree([(255,255,255),(0, 0, 0)]) # Start tree with black and white

# Pick colors that are far apart from each other and from black
for lab in lab_colors[0:]:
Expand Down
9 changes: 8 additions & 1 deletion src/vfb_connect/neo/query_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
from inspect import getfullargspec
from string import Template
from time import sleep
from xml.sax import saxutils
import pandas as pd
import pkg_resources
Expand Down Expand Up @@ -609,7 +610,13 @@ def _get_Cached_TermInfo(self, short_forms: iter, summary=True, return_dataframe
short_forms = list(chain.from_iterable(short_forms)) if any(isinstance(i, list) for i in short_forms) else short_forms
print(f"Checking cache for results: short_forms={short_forms}") if verbose else None
print(f"Looking for {len(short_forms)} results.") if verbose else None
results = self._serialize_solr_output(vfb_solr.search('*', **{'fl': 'term_info','df': 'id', 'defType': 'edismax', 'q.op': 'OR','rows': len(short_forms)+10,'fq':'{!terms f=id}'+ ','.join(short_forms)}))
try:
result = vfb_solr.search('*', **{'fl': 'term_info','df': 'id', 'defType': 'edismax', 'q.op': 'OR','rows': len(short_forms)+10,'fq':'{!terms f=id}'+ ','.join(short_forms)})
except Exception as e:
print(f"\033[33mWarning:\033[0m Cache query failed. Error: {e}")
sleep(15) # Sleep for 15 seconds to avoid overloading the server
return self._get_Cached_TermInfo(short_forms, summary=summary, return_dataframe=return_dataframe, verbose=verbose)
results = self._serialize_solr_output(result)
print(f"Got {len(results)} results.") if verbose else None
if len(short_forms) != len(results):
print(f"Warning: Cache didn't return all results. Got {len(results)} out of {len(short_forms)}") if verbose else None
Expand Down
10 changes: 8 additions & 2 deletions src/vfb_connect/owl/owlery_query_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from time import sleep
import requests
import re
import json
Expand Down Expand Up @@ -70,11 +71,16 @@ def query(self, query_type, return_type,
if query_by_label:
query = self.labels_2_ids(query)
if verbose:
print("Running query: " + query)
print("Running query: " + query)
payload = {'object': query, 'prefixes': json.dumps(self.curies),
'direct': direct}
# print(payload)
r = requests.get(url=owl_endpoint, params=payload)
try:
r = requests.get(url=owl_endpoint, params=payload)
except requests.exceptions.RequestException as e:
print("\033[31mConnection Error:\033[0m " + str(e))
sleep(15)
return query(query_type, return_type, query, query_by_label, direct, verbose)
if verbose:
print("Query URL: " + r.url)
if r.status_code == 200:
Expand Down

0 comments on commit d1dcfd4

Please sign in to comment.