Skip to content

Commit

Permalink
Merge pull request #110 from LCOGT/fix/logging-adapter
Browse files Browse the repository at this point in the history
Fix/logging adapter
  • Loading branch information
mgdaily authored Dec 5, 2023
2 parents 5533ad0 + b74ef54 commit a5efc83
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 0 additions & 5 deletions banzai_nres/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# ----------------------------------------------------------------------------
from ._astropy_init import * # noqa
# ----------------------------------------------------------------------------

import logging
from banzai.logs import BanzaiLogger

logging.setLoggerClass(BanzaiLogger)
4 changes: 2 additions & 2 deletions banzai_nres/classify.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/dbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +15,7 @@
from banzai.utils import fits_utils


logger = logging.getLogger('banzai')
logger = get_logger()


class Spectrum1D:
Expand Down
3 changes: 1 addition & 2 deletions banzai_nres/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions banzai_nres/phoenix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/qc/qc_science.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/qc/qc_wavelength.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/rv.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions banzai_nres/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,9 +21,7 @@
import banzai_nres.dbs
import json

import logging

logger = logging.getLogger('banzai')
logger = get_logger()

TEST_PACKAGE = 'banzai_nres.tests'

Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
G. Mirek Brandt ([email protected])
"""
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
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/utils/continuum_utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
5 changes: 2 additions & 3 deletions banzai_nres/utils/wavelength_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions banzai_nres/wavelength.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand Down
5 changes: 2 additions & 3 deletions docs/banzai_nres/ExampleReduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -50,7 +49,7 @@
"outputs": [],
"source": [
"set_log_level('DEBUG')\n",
"logger = logging.getLogger('banzai')"
"logger = get_logger()"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a5efc83

Please sign in to comment.