diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 780ddd19..87e3a12a 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -29,10 +29,10 @@ jobs: python: 3.8 toxenv: codestyle - - name: Python 3.7 with minimal dependencies + - name: Python 3.8 with minimal dependencies os: ubuntu-latest - python: 3.7 - toxenv: py37-test + python: 3.8 + toxenv: py38-test - name: Python 3.8 with all optional dependencies and coverage checking os: ubuntu-latest diff --git a/CHANGES.md b/CHANGES.md index 7d840d58..490d497d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +1.1.3 (2023-11-17) +------------------ +- Fixes to use BANZAI LoggingAdapter + 1.1.2 (2023-07-25) ------------------ - Update NRES Frame Factory to handle UNKNOWN as a valid empty coordinate diff --git a/Dockerfile b/Dockerfile index 26c030c2..d14cee5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM docker.lco.global/banzai:1.9.8 +FROM ghcr.io/lcogt/banzai:1.13.1 USER root -RUN conda install -y coveralls sphinx statsmodels docutils=0.15 +RUN conda install -y coveralls sphinx statsmodels docutils -RUN pip install astropy==4.2 +RUN pip install astropy==5.3.4 COPY --chown=10087:10000 . /lco/banzai-nres diff --git a/banzai_nres/__init__.py b/banzai_nres/__init__.py index fc3eca20..d374b46a 100644 --- a/banzai_nres/__init__.py +++ b/banzai_nres/__init__.py @@ -1,8 +1,3 @@ # ---------------------------------------------------------------------------- from ._astropy_init import * # noqa # ---------------------------------------------------------------------------- - -import logging -from banzai.logs import BanzaiLogger - -logging.setLoggerClass(BanzaiLogger) diff --git a/banzai_nres/classify.py b/banzai_nres/classify.py index 3110aeb0..b4559f1a 100644 --- a/banzai_nres/classify.py +++ b/banzai_nres/classify.py @@ -1,6 +1,7 @@ from banzai.stages import Stage from banzai_nres.frames import NRESObservationFrame from banzai_nres import dbs +from banzai.logs import get_logger import warnings from astropy import units from astropy.time import Time @@ -10,11 +11,10 @@ from banzai_nres import phoenix import numpy as np from banzai.utils import import_utils -import logging import astroquery.exceptions -logger = logging.getLogger('banzai') +logger = get_logger() def find_object_in_catalog(image, db_address, gaia_class, simbad_class): diff --git a/banzai_nres/dbs.py b/banzai_nres/dbs.py index 0cdca544..465b1563 100644 --- a/banzai_nres/dbs.py +++ b/banzai_nres/dbs.py @@ -2,16 +2,16 @@ from sqlalchemy import Column, String, Integer, Float, Index, ForeignKey import boto3 import banzai.dbs +from banzai.logs import get_logger import os from glob import glob -import logging from sqlalchemy import func, desc from sqlalchemy.ext.hybrid import hybrid_method import numpy as np from banzai_nres.utils.phoenix_utils import parse_phoenix_header -logger = logging.getLogger('banzai') +logger = get_logger() class PhoenixModel(Base): diff --git a/banzai_nres/extract.py b/banzai_nres/extract.py index f3a0205f..62aeb6ff 100644 --- a/banzai_nres/extract.py +++ b/banzai_nres/extract.py @@ -3,11 +3,11 @@ from banzai.stages import Stage from banzai_nres.frames import Spectrum1D, NRESObservationFrame from banzai_nres.utils.trace_utils import get_trace_region -import logging from banzai.data import ArrayData +from banzai.logs import get_logger -logger = logging.getLogger('banzai') +logger = get_logger() class WeightedExtract(Stage): diff --git a/banzai_nres/frames.py b/banzai_nres/frames.py index b38a2d8f..2db461b8 100644 --- a/banzai_nres/frames.py +++ b/banzai_nres/frames.py @@ -2,10 +2,10 @@ from banzai.lco import LCOFrameFactory, LCOObservationFrame, LCOCalibrationFrame from banzai.frames import ObservationFrame from banzai.data import DataProduct, ArrayData, HeaderOnly, DataTable +from banzai.logs import get_logger from matplotlib.backends.backend_pdf import PdfPages from matplotlib import pyplot from io import BytesIO -import logging from typing import Optional import numpy as np from astropy.table import Table @@ -15,7 +15,7 @@ from banzai.utils import fits_utils -logger = logging.getLogger('banzai') +logger = get_logger() class Spectrum1D: diff --git a/banzai_nres/main.py b/banzai_nres/main.py index 4154525b..84f46ef2 100644 --- a/banzai_nres/main.py +++ b/banzai_nres/main.py @@ -23,11 +23,10 @@ import numpy as np import multiprocessing -import logging import argparse import requests -logger = logging.getLogger(__name__) +logger = logs.get_logger() def nres_run_realtime_pipeline(): diff --git a/banzai_nres/pdf.py b/banzai_nres/pdf.py index 0678f821..56e1057d 100644 --- a/banzai_nres/pdf.py +++ b/banzai_nres/pdf.py @@ -4,11 +4,11 @@ from astropy import units from banzai.stages import Stage +from banzai.logs import get_logger from banzai_nres import phoenix -import logging from banzai_nres.qc.qc_science import get_snr -logger = logging.getLogger('banzai') +logger = get_logger() class MakePDFSummary(Stage): diff --git a/banzai_nres/phoenix.py b/banzai_nres/phoenix.py index 6446f0f9..130b6328 100644 --- a/banzai_nres/phoenix.py +++ b/banzai_nres/phoenix.py @@ -10,10 +10,9 @@ from scipy import interpolate from banzai_nres.continuum import ContinuumNormalizer from banzai_nres.utils import phoenix_utils -import logging +from banzai.logs import get_logger - -logger = logging.getLogger('banzai') +logger = get_logger() class PhoenixModelLoader: diff --git a/banzai_nres/qc/qc_science.py b/banzai_nres/qc/qc_science.py index 19a80d9b..1fe7a894 100644 --- a/banzai_nres/qc/qc_science.py +++ b/banzai_nres/qc/qc_science.py @@ -1,8 +1,8 @@ import numpy as np from banzai.stages import Stage -import logging +from banzai.logs import get_logger -logger = logging.getLogger('banzai') +logger = get_logger() # This defines the order for which we calculate the SNR value for the header. # By default this is the order containing the Mg b lines. diff --git a/banzai_nres/qc/qc_wavelength.py b/banzai_nres/qc/qc_wavelength.py index b3740eb9..dfcb8bac 100644 --- a/banzai_nres/qc/qc_wavelength.py +++ b/banzai_nres/qc/qc_wavelength.py @@ -1,14 +1,14 @@ import numpy as np from banzai.stages import Stage from banzai.utils import qc +from banzai.logs import get_logger from astropy import constants from astropy import units from xwavecal.utils.wavelength_utils import find_nearest from banzai.utils.stats import robust_standard_deviation -import logging -logger = logging.getLogger('banzai') +logger = get_logger() class AssessWavelengthSolution(Stage): diff --git a/banzai_nres/rv.py b/banzai_nres/rv.py index f8e3862e..1d808af8 100644 --- a/banzai_nres/rv.py +++ b/banzai_nres/rv.py @@ -1,6 +1,7 @@ from banzai.stages import Stage from banzai.frames import ObservationFrame from banzai import dbs +from banzai.logs import get_logger from banzai.data import DataTable import numpy as np from astropy.table import Table, QTable @@ -10,10 +11,9 @@ from astropy import units from banzai.utils import stats from astropy.stats import sigma_clip -import logging from banzai_nres import phoenix -logger = logging.getLogger('banzai') +logger = get_logger() # wavelength regions selected by eye by Mirek on 09 16 2020 wherever there are large (H alpha like, i.e. broad wings) diff --git a/banzai_nres/tests/test_e2e.py b/banzai_nres/tests/test_e2e.py index 368e28bb..97ae015b 100644 --- a/banzai_nres/tests/test_e2e.py +++ b/banzai_nres/tests/test_e2e.py @@ -1,6 +1,7 @@ import pytest from banzai.tests.utils import FakeResponse, get_min_and_max_dates from banzai_nres import settings +from banzai.logs import get_logger import os import mock import numpy as np @@ -20,9 +21,7 @@ import banzai_nres.dbs import json -import logging - -logger = logging.getLogger('banzai') +logger = get_logger() TEST_PACKAGE = 'banzai_nres.tests' diff --git a/banzai_nres/traces.py b/banzai_nres/traces.py index 5b3c0ccf..393d626e 100644 --- a/banzai_nres/traces.py +++ b/banzai_nres/traces.py @@ -6,13 +6,13 @@ G. Mirek Brandt (gmbrandt@ucsb.edu) """ from banzai.stages import Stage -import logging +from banzai.logs import get_logger from scipy import ndimage import numpy as np from banzai_nres.fitting import fit_polynomial from banzai.data import ArrayData -logger = logging.getLogger('banzai') +logger = get_logger() # Minimum separation between peaks in the image that could be separate traces MIN_TRACE_SEPARATION = 10 diff --git a/banzai_nres/utils/continuum_utils.py b/banzai_nres/utils/continuum_utils.py index 389b1094..ff4481c1 100644 --- a/banzai_nres/utils/continuum_utils.py +++ b/banzai_nres/utils/continuum_utils.py @@ -1,10 +1,10 @@ import numpy as np from scipy.ndimage import binary_dilation, percentile_filter from scipy.ndimage import gaussian_filter1d -import logging from banzai.utils.stats import robust_standard_deviation +from banzai.logs import get_logger -logger = logging.getLogger('banzai') +logger = get_logger() def mark_features(flux, sigma=3, continuum_formal_error=None, detector_resolution=4): diff --git a/banzai_nres/utils/wavelength_utils.py b/banzai_nres/utils/wavelength_utils.py index 99eda9bb..7973fe53 100644 --- a/banzai_nres/utils/wavelength_utils.py +++ b/banzai_nres/utils/wavelength_utils.py @@ -2,10 +2,9 @@ from photutils.detection import DAOStarFinder from astropy.table import Table from banzai.utils.stats import robust_standard_deviation +from banzai.logs import get_logger -import logging - -logger = logging.getLogger('banzai') +logger = get_logger() def identify_features(data, err, mask=None, nsigma=2., fwhm=6.0, **kwargs): diff --git a/banzai_nres/wavelength.py b/banzai_nres/wavelength.py index 5e5b02d0..ecbcc83f 100644 --- a/banzai_nres/wavelength.py +++ b/banzai_nres/wavelength.py @@ -3,6 +3,7 @@ from banzai.stages import Stage from banzai.data import DataTable, ArrayData from banzai.calibrations import CalibrationStacker, CalibrationUser +from banzai.logs import get_logger from astropy import table from banzai_nres.frames import NRESObservationFrame @@ -13,13 +14,12 @@ from xwavecal.fibers import IdentifyFibers import sep -import logging import os import pkg_resources from astropy.table import Table -logger = logging.getLogger('banzai') +logger = get_logger() WAVELENGTH_SOLUTION_MODEL = {0: [0, 1, 2, 3, 4, 5], 1: [0, 1, 2, 3, 4, 5], diff --git a/docs/banzai_nres/ExampleReduction.ipynb b/docs/banzai_nres/ExampleReduction.ipynb index da8839ea..d68c117e 100644 --- a/docs/banzai_nres/ExampleReduction.ipynb +++ b/docs/banzai_nres/ExampleReduction.ipynb @@ -28,8 +28,7 @@ "from banzai_nres import settings\n", "from banzai import dbs\n", "from banzai.utils.stage_utils import run_pipeline_stages\n", - "import logging\n", - "from banzai.logs import set_log_level\n", + "from banzai.logs import set_log_level, get_logger\n", "from glob import glob\n", "\n", "import pkg_resources" @@ -50,7 +49,7 @@ "outputs": [], "source": [ "set_log_level('DEBUG')\n", - "logger = logging.getLogger('banzai')" + "logger = get_logger()" ] }, { diff --git a/tox.ini b/tox.ini index c1c3d6ff..ba474fb5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist = - py{37,38}-test{,-alldeps,-devdeps}{,-cov} - py{37,38}-test-numpy{117,118,119,120} - py{37,38}-test-astropy{30,40,41,42,lts} + py{38,39}-test{,-alldeps,-devdeps}{,-cov} + py{38,39}-test-numpy{117,118,119,120} + py{38,39}-test-astropy{30,40,41,42,lts} build_docs linkcheck codestyle