Commit 43de44f8 authored by Gavin's avatar Gavin
Browse files

updated network.py to use logging

parent b2751694
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import os
from shutil import copyfile
import threading
from time import gmtime, strftime, time
import warnings
import logging
from itertools import combinations

import networkx as nx
@@ -58,6 +58,8 @@ from autocnet.spatial.isis import point_info
from autocnet.spatial.surface import GdalDem, EllipsoidDem
from autocnet.transformation.spatial import reproject, og2oc

# set up the logging file
log = logging.getLogger(__name__)
#np.warnings.filterwarnings('ignore')

# 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):
            if fp and fp.IsValid():
                valid_datasets.append(i)
            else:
                warnings.warn(
                log.warning(
                    'Missing or invalid geospatial data for {}'.format(i.base_name))

        # Grab the footprints and test for intersection
@@ -250,7 +252,7 @@ class CandidateGraph(nx.Graph):
                    adjacency_dict[i.file_name].append(j.file_name)
                    adjacency_dict[j.file_name].append(i.file_name)
            except:
                warnings.warn(
                log.warning(
                    'Failed to calculate intersection between {} and {}'.format(i, j))
        return cls.from_adjacency(adjacency_dict)

@@ -377,7 +379,7 @@ class CandidateGraph(nx.Graph):
            else:
                image_path = image_name
            if not os.path.exists(image_path):
                warnings.warn("Cannot find {}".format(image_path))
                log.warning("Cannot find {}".format(image_path))
                return
            n = self.graph["node_counter"]
            self.graph["node_counter"] += 1
@@ -395,7 +397,7 @@ class CandidateGraph(nx.Graph):
        if new_node is not None and adj is not None:
            for adj_img in adj:
                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
                new_idx = new_node["node_id"]
                adj_idx = self.graph["node_name_map"][adj_img]
@@ -1007,7 +1009,7 @@ class CandidateGraph(nx.Graph):
        """

        if not self.is_connected():
            warnings.warn(
            log.warning(
                'The given graph is not complete and may yield garbage.')

        for s, d, edge in self.edges.data('edge'):
@@ -1630,7 +1632,7 @@ class NetworkCandidateGraph(CandidateGraph):
        Push messages to the redis queue for DB objects e.g., Points, Measures
        """
        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:
            # Support either an SQL query string, or a simple dict based query
@@ -1943,7 +1945,7 @@ class NetworkCandidateGraph(CandidateGraph):
        fpaths = [self.nodes[i]['data']['image_path'] for i in ids]
        for f in self.files:
            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
        df.rename(columns={'pointtype':'pointType',
@@ -2038,7 +2040,7 @@ class NetworkCandidateGraph(CandidateGraph):
        elif os.path.exists(filelist):
            filelist = io_utils.file_to_list(filelist)
        else:
            warnings.warn('Unable to parse the passed filelist')
           log.warning('Unable to parse the passed filelist')

        if clear_db:
            self.clear_db()
@@ -2257,7 +2259,7 @@ class NetworkCandidateGraph(CandidateGraph):
                    try:
                        session.execute(f'ALTER SEQUENCE {t}_id_seq RESTART WITH 1')
                    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):
        """
@@ -2559,7 +2561,7 @@ class NetworkCandidateGraph(CandidateGraph):
                                          walltime='00:20:00',
                                          chunksize=1000,
                                          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.')

        # Setup the redis queue