diff --git a/skymap_scanner/recos/__init__.py b/skymap_scanner/recos/__init__.py index 53abea12b..b07773198 100644 --- a/skymap_scanner/recos/__init__.py +++ b/skymap_scanner/recos/__init__.py @@ -3,10 +3,10 @@ # mypy: ignore-errors # fmt: off +from abc import ABC, abstractmethod import importlib import pkgutil -from abc import ABC, abstractmethod -from typing import Any, List, TYPE_CHECKING, Tuple, Union +from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union if TYPE_CHECKING: # https://stackoverflow.com/a/65265627 from ..utils.pixel_classes import RecoPixelVariation @@ -17,8 +17,8 @@ try: # these are only used for typehints, so mock imports are fine from icecube.dataclasses import I3Position # type: ignore[import] from icecube.icetray import I3Frame # type: ignore[import] - from icecube import astro # type: ignore[import] -except ImportError: # type: ignore[import] + from icecube import astro # type: ignore[import] +except ImportError: # type: ignore[import] I3Position = Any I3Frame = Any @@ -88,7 +88,7 @@ def traysegment(self, tray, name, logger, **kwargs: Any) -> None: @staticmethod @abstractmethod def to_recopixelvariation( - frame: I3Frame, geometry: I3Frame + frame: I3Frame, geometry: I3Frame ) -> "RecoPixelVariation": raise NotImplementedError() @@ -123,9 +123,10 @@ def get_reco_spline_requirements(name: str) -> List[str]: raise UnsupportedRecoAlgoException(name) from e raise # something when wrong AFTER accessing sub-module + def set_pointing_ra_dec( - particle_name_possibilities: Union[List[str], None], - p_frame: I3Frame + particle_name_possibilities: Union[List[str], None], + p_frame: I3Frame ) -> Union[Tuple[float, float], None]: """Retrieves the direction for a pointed scan""" pointing_ra_dec = None diff --git a/skymap_scanner/recos/crash_dummy.py b/skymap_scanner/recos/crash_dummy.py index 3060c421c..ce07e9eeb 100644 --- a/skymap_scanner/recos/crash_dummy.py +++ b/skymap_scanner/recos/crash_dummy.py @@ -1,5 +1,6 @@ """IceTray segment for a dummy reco (will crash w/in a given probability).""" +import os import random import time from typing import Final @@ -21,9 +22,11 @@ def traysegment(tray, name, logger, **kwargs): def crash(frame): rand = random.random() - logger.debug(f"crash probability: {ENV.SKYSCAN_CRASH_DUMMY_PROBABILITY=}") + logger.debug( + f"crash probability: {os.getenv('SKYSCAN_CRASH_DUMMY_PROBABILITY')}" + ) - if rand < ENV.SKYSCAN_CRASH_DUMMY_PROBABILITY: + if rand < float(os.getenv("SKYSCAN_CRASH_DUMMY_PROBABILITY")): logger.debug(f"crash! {rand=}") # now, pick what to fail with diff --git a/skymap_scanner/recos/splinempe.py b/skymap_scanner/recos/splinempe.py index fc7472fb4..d797c403f 100644 --- a/skymap_scanner/recos/splinempe.py +++ b/skymap_scanner/recos/splinempe.py @@ -4,22 +4,40 @@ # fmt: off import datetime -from typing import Final - import numpy as np +from typing import Final, List + + +from icecube.icetray import I3Units # type: ignore[import] + # NOTE: icecube module imports are required to make IceTray modules and services available. -from icecube import (dataclasses) # type: ignore[import] # noqa: F401 -from icecube.STTools.seededRT.configuration_services import \ - I3DOMLinkSeededRTConfigurationService # type: ignore[import] +from icecube import ( # type: ignore[import] # noqa: F401 + dataclasses, + DomTools, + frame_object_diff, + gulliver, + gulliver_modules, + icetray, + lilliput, + mue, + spline_reco, + photonics_service, + recclasses, + simclasses, + STTools, + VHESelfVeto, +) + # Class bindings directly accessed by the python code are imported explicitly. -from icecube.icetray import I3Frame, I3Units, traysegment # type: ignore[import]; type: ignore[import] -from icecube.lilliput import i3minuit, scipymin # type: ignore[import] +from icecube.icetray import I3Frame, traysegment # type: ignore[import] +from icecube.lilliput import scipymin, i3minuit # type: ignore[import] from icecube.photonics_service import I3PhotoSplineService # type: ignore[import] +from icecube.STTools.seededRT.configuration_services import I3DOMLinkSeededRTConfigurationService # type: ignore[import] -from . import RecoInterface, VertexGenerator -from .common.pulse_proc import mask_deepcore from .. import config as cfg from ..utils.pixel_classes import RecoPixelVariation +from . import RecoInterface, VertexGenerator +from .common.pulse_proc import mask_deepcore class SplineMPE(RecoInterface): diff --git a/skymap_scanner/recos/splinempe_pointed.py b/skymap_scanner/recos/splinempe_pointed.py index 0440a15b6..0dbd1100e 100644 --- a/skymap_scanner/recos/splinempe_pointed.py +++ b/skymap_scanner/recos/splinempe_pointed.py @@ -5,8 +5,8 @@ from typing import Final -from . import RecoInterface, splinempe - +from . import splinempe +from . import RecoInterface class SplineMPEPointed(splinempe.SplineMPE): diff --git a/skymap_scanner/utils/pixel_classes.py b/skymap_scanner/utils/pixel_classes.py index 79d67fc10..bb3fe9e08 100644 --- a/skymap_scanner/utils/pixel_classes.py +++ b/skymap_scanner/utils/pixel_classes.py @@ -4,7 +4,8 @@ import time from typing import Any, Dict, Tuple -from .. import config as cfg, recos +from .. import config as cfg +from .. import recos try: # these are only used for typehints, so mock imports are fine from icecube.dataclasses import I3Position # type: ignore[import]