Skip to content

Commit

Permalink
handle None location case and remove print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonw committed Mar 13, 2024
1 parent ea69950 commit 8db2a23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion funlib/persistence/graphs/pgsql_graph_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def _read_metadata(self) -> Optional[dict[str, Any]]:
return None

def _select_query(self, query) -> Iterable[Any]:
print(query)
self.__exec(query)
return self.cur

Expand Down
14 changes: 6 additions & 8 deletions funlib/persistence/graphs/sql_graph_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,6 @@ def read_nodes(
for values in self._select_query(select_statement)
]

for values in self._select_query(select_statement):
print(values)
print(self.node_attrs.keys())
print(nodes)

return nodes

def num_nodes(self, roi: Roi) -> int:
Expand Down Expand Up @@ -445,7 +440,7 @@ def write_edges(
u, v = min(u, v), max(u, v)
pos_u = self.__get_node_pos(nodes[u])

if not roi.contains(pos_u):
if pos_u is None or not roi.contains(pos_u):
logger.debug(
(
f"Skipping edge with {self.endpoint_names[0]} {{}}, {self.endpoint_names[1]} {{}},"
Expand Down Expand Up @@ -660,8 +655,11 @@ def __remove_keys(self, dictionary, keys):

return {k: v for k, v in dictionary.items() if k not in keys}

def __get_node_pos(self, n: dict[str, Any]) -> Coordinate:
return Coordinate(n[self.position_attribute])
def __get_node_pos(self, n: dict[str, Any]) -> Optional[Coordinate]:
try:
return Coordinate(n[self.position_attribute])
except KeyError:
return None

def __convert_to_sql(self, x: Any) -> str:
if isinstance(x, str):
Expand Down

0 comments on commit 8db2a23

Please sign in to comment.