Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose logging more convenient #359

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions clients/python/sliderule/earthdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,19 @@
import ssl
import urllib.request
import requests
import logging
import numpy
import geopandas
from datetime import datetime
from shapely.geometry.multipolygon import MultiPolygon
from shapely.geometry import Polygon
from sliderule import logger
import sliderule


###############################################################################
# GLOBALS
###############################################################################

# create logger
logger = logging.getLogger(__name__)

# profiling times for each major function
profiles = {}

Expand Down
5 changes: 1 addition & 4 deletions clients/python/sliderule/gedi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@
import numpy
import geopandas
import sliderule
from sliderule import earthdata
from sliderule import earthdata, logger

###############################################################################
# GLOBALS
###############################################################################

# create logger
logger = logging.getLogger(__name__)

# profiling times for each major function
profiles = {}

Expand Down
4 changes: 1 addition & 3 deletions clients/python/sliderule/h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import time
import logging
import numpy
import sliderule
from sliderule import logger

###############################################################################
# GLOBALS
###############################################################################

logger = logging.getLogger(__name__)

profiles = {}

ALL_ROWS = -1
Expand Down
5 changes: 1 addition & 4 deletions clients/python/sliderule/icesat2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@
import numpy
import geopandas
import sliderule
from sliderule import earthdata
from sliderule import earthdata, logger

###############################################################################
# GLOBALS
###############################################################################

# create logger
logger = logging.getLogger(__name__)

# profiling times for each major function
profiles = {}

Expand Down
22 changes: 11 additions & 11 deletions clients/python/sliderule/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

import sys
import json
import logging
import warnings
import datetime
import geopandas
import numpy as np
from sliderule import logger

# imports with warnings if not present
try:
Expand Down Expand Up @@ -404,17 +404,17 @@ def to_json(filename, **kwargs):
with open(filename, 'w') as fid:
json.dump(output, fid)
# print the filename and dictionary structure
logging.info(filename)
logging.info(list(output.keys()))
logger.info(filename)
logger.info(list(output.keys()))

# read request parameters and regions from JSON
def from_json(filename, **kwargs):
# load the JSON file
with open(filename, 'r') as fid:
attributes = json.load(fid)
# print the filename and dictionary structure
logging.info(filename)
logging.info(list(attributes.keys()))
logger.info(filename)
logger.info(list(attributes.keys()))
# try to get the sliderule adjustable parameters
SRparams = ['H_min_win', 'atl08_class', 'atl03_quality', 'ats', 'cnf',
'cnt', 'len', 'maxi', 'res', 'sigma_r_max', 'srt', 'yapc']
Expand Down Expand Up @@ -527,8 +527,8 @@ def to_nc(gdf, filename, **kwargs):
setattr(fileID, 'poly{0:d}_x'.format(i), json.dumps(lon))
setattr(fileID, 'poly{0:d}_y'.format(i), json.dumps(lat))
# Output netCDF structure information
logging.info(filename)
logging.info(list(fileID.variables.keys()))
logger.info(filename)
logger.info(list(fileID.variables.keys()))
# Closing the netCDF file
fileID.close()
warnings.filterwarnings("default")
Expand Down Expand Up @@ -709,8 +709,8 @@ def write_pytables(df, filename, attributes, **kwargs):
setattr(fileID.root._v_attrs, f'poly{i:d}_x', json.dumps(lon))
setattr(fileID.root._v_attrs, f'poly{i:d}_y', json.dumps(lat))
# Output HDF5 structure information
logging.info(filename)
logging.info(fileID.get_storer('sliderule_segments').non_index_axes[0][1])
logger.info(filename)
logger.info(fileID.get_storer('sliderule_segments').non_index_axes[0][1])
# Closing the HDF5 file
fileID.close()

Expand Down Expand Up @@ -790,8 +790,8 @@ def write_h5py(df, filename, attributes, **kwargs):
fileID.attrs[f'poly{i:d}_x'] = json.dumps(lon)
fileID.attrs[f'poly{i:d}_y'] = json.dumps(lat)
# Output HDF5 structure information
logging.info(filename)
logging.info(list(fileID.keys()))
logger.info(filename)
logger.info(list(fileID.keys()))
# Closing the HDF5 file
fileID.close()

Expand Down
10 changes: 1 addition & 9 deletions clients/python/sliderule/ipxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from sliderule import icesat2, sliderule
import logging

###############################################################################
# GLOBALS
###############################################################################

# create logger
logger = logging.getLogger(__name__)
from sliderule import icesat2, sliderule, logger

###############################################################################
# APIs
Expand Down
34 changes: 17 additions & 17 deletions clients/python/sliderule/ipysliderule.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import io
import sys
import copy
import logging
import datetime
import traceback
import numpy as np
Expand All @@ -43,6 +42,7 @@
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from traitlets.utils.bunch import Bunch
from sliderule import logger
import sliderule.io

# imports with warnings if not present
Expand Down Expand Up @@ -1334,13 +1334,13 @@ def RGT(self):
try:
rgt = int(self.rgt.value)
except:
logging.critical(f"RGT {self.rgt.value} is invalid")
logger.critical(f"RGT {self.rgt.value} is invalid")
return "0"
# verify ground track values
if (rgt >= 1) and (rgt <= 1387):
return self.rgt.value
else:
logging.critical(f"RGT {self.rgt.value} is outside available range")
logger.critical(f"RGT {self.rgt.value} is outside available range")
return "0"

@property
Expand Down Expand Up @@ -1384,7 +1384,7 @@ def orbital_cycle(self):
if (self.cycle.value in all_cycles):
return self.cycle.value
else:
logging.critical(f"Cycle {self.cycle.value} is outside available range")
logger.critical(f"Cycle {self.cycle.value} is outside available range")
return "0"

@property
Expand Down Expand Up @@ -2071,14 +2071,14 @@ def add_layer(self, **kwargs):
# simply attempt to add the layer or control
self.map.add(layer)
except ipyleaflet.LayerException as e:
logging.info(f"Layer {layer} already on map")
logger.info(f"Layer {layer} already on map")
pass
except ipyleaflet.ControlException as e:
logging.info(f"Control {layer} already on map")
logger.info(f"Control {layer} already on map")
pass
except Exception as e:
logging.critical(f"Could add layer {layer}")
logging.error(traceback.format_exc())
logger.critical(f"Could add layer {layer}")
logger.error(traceback.format_exc())
pass

# remove map layers
Expand Down Expand Up @@ -2126,14 +2126,14 @@ def remove_layer(self, **kwargs):
# simply attempt to remove the layer or control
self.map.remove(layer)
except ipyleaflet.LayerException as e:
logging.info(f"Layer {layer} already removed from map")
logger.info(f"Layer {layer} already removed from map")
pass
except ipyleaflet.ControlException as e:
logging.info(f"Control {layer} already removed from map")
logger.info(f"Control {layer} already removed from map")
pass
except Exception as e:
logging.critical(f"Could not remove layer {layer}")
logging.error(traceback.format_exc())
logger.critical(f"Could not remove layer {layer}")
logger.error(traceback.format_exc())
pass

# handle cursor movements for label
Expand Down Expand Up @@ -2214,7 +2214,7 @@ def GeoData(self, gdf, **kwargs):
kwargs.setdefault('colorbar', True)
kwargs.setdefault('position', 'topright')
# add warning that function is deprecated
logging.critical(f"Deprecated. Will be removed in a future release")
logger.critical(f"Deprecated. Will be removed in a future release")
# remove any prior instances of a data layer
if self.geojson is not None:
self.map.remove(self.geojson)
Expand Down Expand Up @@ -2609,14 +2609,14 @@ def remove(self, layer):
try:
self.map.remove(layer)
except ipyleaflet.LayerException as e:
logging.info(f"Layer {layer} already removed from map")
logger.info(f"Layer {layer} already removed from map")
pass
except ipyleaflet.ControlException as e:
logging.info(f"Control {layer} already removed from map")
logger.info(f"Control {layer} already removed from map")
pass
except Exception as e:
logging.critical(f"Could not remove layer {layer}")
logging.error(traceback.format_exc())
logger.critical(f"Could not remove layer {layer}")
logger.error(traceback.format_exc())
pass

# add colorbar widget to leaflet map
Expand Down
3 changes: 0 additions & 3 deletions clients/python/sliderule/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import logging
import numpy
import base64
import sliderule
Expand All @@ -38,8 +37,6 @@
# GLOBALS
###############################################################################

logger = logging.getLogger(__name__)

profiles = {}

###############################################################################
Expand Down
Loading
Loading