Skip to content

Commit

Permalink
fix: python 3.11 compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tiadams committed Oct 15, 2024
1 parent a557058 commit c1383f3
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions datastew/repository/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ def _sentence_embedder_exists(self, name: str) -> bool:
"operator": "Equal",
"valueText": name
}).do()
return len(result["data"]["Get"]["Mapping"]) > 0
result_data = result["data"]["Get"]["Mapping"]
if result_data is not None:
return len(result_data) > 0
else:
return False
except Exception as e:
raise RuntimeError(f"Failed to check if sentence embedder exists: {e}")

Expand All @@ -470,7 +474,11 @@ def _terminology_exists(self, name: str) -> bool:
"operator": "Equal",
"valueText": name
}).do()
return len(result["data"]["Get"]["Terminology"]) > 0
result_data = result["data"]["Get"]["Terminology"]
if result_data is not None:
return len(result_data) > 0
else:
return False
except Exception as e:
raise RuntimeError(f"Failed to check if terminology exists: {e}")

Expand All @@ -481,7 +489,11 @@ def _concept_exists(self, concept_id: str) -> bool:
"operator": "Equal",
"valueText": concept_id
}).do()
return len(result["data"]["Get"]["Concept"]) > 0
result_data = result["data"]["Get"]["Concept"]
if result_data is not None:
return len(result_data) > 0
else:
return False
except Exception as e:
raise RuntimeError(f"Failed to check if concept exists: {e}")

Expand All @@ -491,6 +503,10 @@ def _mapping_exists(self, embedding) -> bool:
"vector": embedding,
"distance": float(0) # Ensure distance is explicitly casted to float
}).do()
return len(result["data"]["Get"]["Mapping"]) > 0
result_data = result["data"]["Get"]["Mapping"]
if result_data is not None:
return len(result_data) > 0
else:
return False
except Exception as e:
raise RuntimeError(f"Failed to check if mapping exists: {e}")

0 comments on commit c1383f3

Please sign in to comment.