Skip to content
Snippets Groups Projects
Commit 43de44f8 authored by Gavin's avatar Gavin
Browse files

updated network.py to use logging

parent b2751694
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import os ...@@ -7,7 +7,7 @@ import os
from shutil import copyfile from shutil import copyfile
import threading import threading
from time import gmtime, strftime, time from time import gmtime, strftime, time
import warnings import logging
from itertools import combinations from itertools import combinations
import networkx as nx import networkx as nx
...@@ -58,6 +58,8 @@ from autocnet.spatial.isis import point_info ...@@ -58,6 +58,8 @@ from autocnet.spatial.isis import point_info
from autocnet.spatial.surface import GdalDem, EllipsoidDem from autocnet.spatial.surface import GdalDem, EllipsoidDem
from autocnet.transformation.spatial import reproject, og2oc from autocnet.transformation.spatial import reproject, og2oc
# set up the logging file
log = logging.getLogger(__name__)
#np.warnings.filterwarnings('ignore') #np.warnings.filterwarnings('ignore')
# The total number of pixels squared that can fit into the keys number of GB of RAM for SIFT. # The total number of pixels squared that can fit into the keys number of GB of RAM for SIFT.
...@@ -237,7 +239,7 @@ class CandidateGraph(nx.Graph): ...@@ -237,7 +239,7 @@ class CandidateGraph(nx.Graph):
if fp and fp.IsValid(): if fp and fp.IsValid():
valid_datasets.append(i) valid_datasets.append(i)
else: else:
warnings.warn( log.warning(
'Missing or invalid geospatial data for {}'.format(i.base_name)) 'Missing or invalid geospatial data for {}'.format(i.base_name))
# Grab the footprints and test for intersection # Grab the footprints and test for intersection
...@@ -250,7 +252,7 @@ class CandidateGraph(nx.Graph): ...@@ -250,7 +252,7 @@ class CandidateGraph(nx.Graph):
adjacency_dict[i.file_name].append(j.file_name) adjacency_dict[i.file_name].append(j.file_name)
adjacency_dict[j.file_name].append(i.file_name) adjacency_dict[j.file_name].append(i.file_name)
except: except:
warnings.warn( log.warning(
'Failed to calculate intersection between {} and {}'.format(i, j)) 'Failed to calculate intersection between {} and {}'.format(i, j))
return cls.from_adjacency(adjacency_dict) return cls.from_adjacency(adjacency_dict)
...@@ -377,7 +379,7 @@ class CandidateGraph(nx.Graph): ...@@ -377,7 +379,7 @@ class CandidateGraph(nx.Graph):
else: else:
image_path = image_name image_path = image_name
if not os.path.exists(image_path): if not os.path.exists(image_path):
warnings.warn("Cannot find {}".format(image_path)) log.warning("Cannot find {}".format(image_path))
return return
n = self.graph["node_counter"] n = self.graph["node_counter"]
self.graph["node_counter"] += 1 self.graph["node_counter"] += 1
...@@ -395,7 +397,7 @@ class CandidateGraph(nx.Graph): ...@@ -395,7 +397,7 @@ class CandidateGraph(nx.Graph):
if new_node is not None and adj is not None: if new_node is not None and adj is not None:
for adj_img in adj: for adj_img in adj:
if adj_img not in self.graph["node_name_map"].keys(): if adj_img not in self.graph["node_name_map"].keys():
warnings.warn("{} not found in the graph".format(adj_img)) log.warning("{} not found in the graph".format(adj_img))
continue continue
new_idx = new_node["node_id"] new_idx = new_node["node_id"]
adj_idx = self.graph["node_name_map"][adj_img] adj_idx = self.graph["node_name_map"][adj_img]
...@@ -1007,7 +1009,7 @@ class CandidateGraph(nx.Graph): ...@@ -1007,7 +1009,7 @@ class CandidateGraph(nx.Graph):
""" """
if not self.is_connected(): if not self.is_connected():
warnings.warn( log.warning(
'The given graph is not complete and may yield garbage.') 'The given graph is not complete and may yield garbage.')
for s, d, edge in self.edges.data('edge'): for s, d, edge in self.edges.data('edge'):
...@@ -1630,7 +1632,7 @@ class NetworkCandidateGraph(CandidateGraph): ...@@ -1630,7 +1632,7 @@ class NetworkCandidateGraph(CandidateGraph):
Push messages to the redis queue for DB objects e.g., Points, Measures Push messages to the redis queue for DB objects e.g., Points, Measures
""" """
if filters and query_string: if filters and query_string:
warnings.warn('Use of filters and query_string are mutually exclusive.') log.warning('Use of filters and query_string are mutually exclusive.')
with self.session_scope() as session: with self.session_scope() as session:
# Support either an SQL query string, or a simple dict based query # Support either an SQL query string, or a simple dict based query
...@@ -1943,7 +1945,7 @@ class NetworkCandidateGraph(CandidateGraph): ...@@ -1943,7 +1945,7 @@ class NetworkCandidateGraph(CandidateGraph):
fpaths = [self.nodes[i]['data']['image_path'] for i in ids] fpaths = [self.nodes[i]['data']['image_path'] for i in ids]
for f in self.files: for f in self.files:
if f not in fpaths: if f not in fpaths:
warnings.warn(f'{f} in candidate graph but not in output network.') log.warning(f'{f} in candidate graph but not in output network.')
# Remap the df columns back to ISIS # Remap the df columns back to ISIS
df.rename(columns={'pointtype':'pointType', df.rename(columns={'pointtype':'pointType',
...@@ -2038,7 +2040,7 @@ class NetworkCandidateGraph(CandidateGraph): ...@@ -2038,7 +2040,7 @@ class NetworkCandidateGraph(CandidateGraph):
elif os.path.exists(filelist): elif os.path.exists(filelist):
filelist = io_utils.file_to_list(filelist) filelist = io_utils.file_to_list(filelist)
else: else:
warnings.warn('Unable to parse the passed filelist') log.warning('Unable to parse the passed filelist')
if clear_db: if clear_db:
self.clear_db() self.clear_db()
...@@ -2257,7 +2259,7 @@ class NetworkCandidateGraph(CandidateGraph): ...@@ -2257,7 +2259,7 @@ class NetworkCandidateGraph(CandidateGraph):
try: try:
session.execute(f'ALTER SEQUENCE {t}_id_seq RESTART WITH 1') session.execute(f'ALTER SEQUENCE {t}_id_seq RESTART WITH 1')
except Exception as e: except Exception as e:
warnings.warn(f'Failed to reset primary id sequence for table {t}') log.warning(f'Failed to reset primary id sequence for table {t}')
def cnet_to_db(self, cnet): def cnet_to_db(self, cnet):
""" """
...@@ -2559,7 +2561,7 @@ class NetworkCandidateGraph(CandidateGraph): ...@@ -2559,7 +2561,7 @@ class NetworkCandidateGraph(CandidateGraph):
walltime='00:20:00', walltime='00:20:00',
chunksize=1000, chunksize=1000,
exclude=None): exclude=None):
warnings.warn('This function is not well tested. No tests currently exists \ log.warning('This function is not well tested. No tests currently exists \
in the test suite for this version of the function.') in the test suite for this version of the function.')
# Setup the redis queue # Setup the redis queue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment