Loading autocnet/graph/network.py +13 −11 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. Loading Loading @@ -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 Loading @@ -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) Loading Loading @@ -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 Loading @@ -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] Loading Loading @@ -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'): Loading Loading @@ -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 Loading Loading @@ -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', Loading Loading @@ -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() Loading Loading @@ -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): """ """ Loading Loading @@ -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 Loading Loading
autocnet/graph/network.py +13 −11 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. Loading Loading @@ -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 Loading @@ -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) Loading Loading @@ -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 Loading @@ -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] Loading Loading @@ -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'): Loading Loading @@ -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 Loading Loading @@ -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', Loading Loading @@ -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() Loading Loading @@ -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): """ """ Loading Loading @@ -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 Loading