diff --git a/autocnet/graph/cluster_submit.py b/autocnet/graph/cluster_submit.py index 0cf5db49eafab8182a412ad6a827122a32347cb5..5e240b20c4d310b41f73f4a7c30dcb7273dd1b7a 100644 --- a/autocnet/graph/cluster_submit.py +++ b/autocnet/graph/cluster_submit.py @@ -232,7 +232,6 @@ def main(): # pragma: no cover args = vars(parse_args()) # set up the logger logging.basicConfig(level=os.environ.get("autocnet_loglevel", "INFO")) - log.error("hello") # Get the message queue = StrictRedis(host=args['host'], port=args['port'], db=0) manage_messages(args, queue) diff --git a/autocnet/graph/edge.py b/autocnet/graph/edge.py index 0221528a072e4bf497bdd64eae4ca112bcf1d931..569d84d160c901e7ac3506ff3e1977eff989ed5d 100644 --- a/autocnet/graph/edge.py +++ b/autocnet/graph/edge.py @@ -1,7 +1,7 @@ from collections import defaultdict, MutableMapping, Counter from functools import wraps, singledispatch import json -import warnings +import logging import numpy as np import pandas as pd @@ -29,6 +29,9 @@ from autocnet.io.db.wrappers import DbDataFrame from plio.io.io_gdal import GeoDataset from csmapi import csmapi +# set up the logging file +log = logging.getLogger(__name__) + class Edge(dict, MutableMapping): """ Attributes @@ -54,6 +57,7 @@ class Edge(dict, MutableMapping): self['fundamental_matrix'] = None self.subpixel_matches = pd.DataFrame() self._matches = pd.DataFrame() + self._caplog = log self['source_mbr'] = None self['destin_mbr'] = None @@ -176,7 +180,7 @@ class Edge(dict, MutableMapping): tar_desc = self.destination.descriptors if not 'xm' in ref_kps.columns: - warnings.warn('To ring match body centered coordinates (xm, ym, zm) must be in the keypoints') + log.warning('To ring match body centered coordinates (xm, ym, zm) must be in the keypoints') return ref_feats = ref_kps[['x', 'y', 'xm', 'ym', 'zm']].values tar_feats = tar_kps[['x', 'y', 'xm', 'ym', 'zm']].values @@ -234,7 +238,7 @@ class Edge(dict, MutableMapping): node = getattr(self, on) camera = getattr(node, 'camera') if camera is None: - warnings.warn('Unable to project matches without a sensor model.') + log.warning('Unable to project matches without a sensor model.') return matches = self.matches @@ -274,7 +278,7 @@ class Edge(dict, MutableMapping): def overlap_check(self): """Creates a mask for matches on the overlap""" if not (self["source_mbr"] and self["destin_mbr"]): - warnings.warn( + log.warning( "Cannot use overlap constraint, minimum bounding rectangles" " have not been computed for one or more Nodes") return @@ -378,7 +382,7 @@ class Edge(dict, MutableMapping): of reprojective error indexed to the matches data frame """ if self.fundamental_matrix is None: - warnings.warn('No fundamental matrix has been compute for this edge.') + log.error('No fundamental matrix has been compute for this edge.') matches, mask = self.clean(clean_keys) s_keypoints, d_keypoints = self.get_match_coordinates(clean_keys=clean_keys) @@ -699,7 +703,7 @@ class Edge(dict, MutableMapping): except: smbr = self.source.geodata.xy_extent dmbr = self.source.geodata.xy_extent - warnings.warn("Overlap between {} and {} could not be " + log.warning("Overlap between {} and {} could not be " "computed. Using the full image extents".format(self.source['image_name'], self.destination['image_name'])) smbr = [smbr[0][0], smbr[1][0], smbr[0][1], smbr[1][1]] diff --git a/autocnet/graph/tests/test_edge.py b/autocnet/graph/tests/test_edge.py index d5a563e927e3327c6f1fb646f758cb5dbca5e6f0..dd05711e3b7b3a75af43d14df137e109598bab10 100644 --- a/autocnet/graph/tests/test_edge.py +++ b/autocnet/graph/tests/test_edge.py @@ -16,6 +16,8 @@ from autocnet.utils.utils import array_to_poly from .. import edge from .. import node +import logging +log = logging.getLogger(__name__) class TestEdge(unittest.TestCase): @@ -326,9 +328,9 @@ class TestEdge(unittest.TestCase): # Should fail if no src & dst mbrs on edge; Warns user & mask isn't # populated - with pytest.warns(UserWarning): + with self.assertLogs() as captured: e.overlap_check() - self.assertTrue("overlap" not in e.masks) + self.assertTrue("Overlap between" not in captured.records[0].getMessage()) # and it is the proper one # Should work after MBRs are set e["source_mbr"] = (1, 1, 1, 1)