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

Decouple spline staging from class declaration #192

Merged
merged 28 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7e02ed7
datastager in millipede original
mlincett May 11, 2023
7d2c665
<bot> update requirements-all.txt
wipacdevbot May 11, 2023
b4f73c7
<bot> update requirements-client-starter.txt
wipacdevbot May 11, 2023
aff999a
<bot> update requirements-nats.txt
wipacdevbot May 11, 2023
21e8208
<bot> update requirements-pulsar.txt
wipacdevbot May 11, 2023
0160311
<bot> update requirements-rabbitmq.txt
wipacdevbot May 11, 2023
ffc6d79
<bot> update requirements.txt
wipacdevbot May 11, 2023
e95b7f5
resolve names
mlincett May 11, 2023
299fd84
update millipede_wilks
mlincett May 11, 2023
417f11f
drop automatic determination of reco class name from module name
mlincett May 12, 2023
de5172b
import Final
mlincett May 12, 2023
35b098b
use instances of reco class instead of static attributes and methods
mlincett May 12, 2023
3c4d46a
setup reco
mlincett May 12, 2023
0c626a6
datastager import
mlincett May 12, 2023
f11ae9b
import in correct place
mlincett May 12, 2023
a2824fb
import config
mlincett May 12, 2023
fd164b7
config shenanigans
mlincett May 12, 2023
623a04b
drop staticmethod definition
mlincett May 12, 2023
cfae049
to_recopixelvariation as class method
mlincett May 12, 2023
69d8759
update millipede_wilks
mlincett May 12, 2023
89e6a06
syntax
mlincett May 12, 2023
cc55eb4
def exclusions() as classmethod
mlincett May 14, 2023
83e5238
<bot> update requirements-all.txt
wipacdevbot May 14, 2023
d2e8b02
<bot> update requirements-client-starter.txt
wipacdevbot May 14, 2023
ba5555d
<bot> update requirements-nats.txt
wipacdevbot May 14, 2023
45619c3
<bot> update requirements-pulsar.txt
wipacdevbot May 14, 2023
fd577a3
<bot> update requirements-rabbitmq.txt
wipacdevbot May 14, 2023
1cdce73
<bot> update requirements.txt
wipacdevbot May 14, 2023
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
10 changes: 5 additions & 5 deletions requirements-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via
# pulsar-client
# requests
Expand All @@ -28,9 +28,9 @@ cycler==0.11.0
# via matplotlib
ed25519==1.5
# via nkeys
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -80,7 +80,7 @@ packaging==23.1
# matplotlib
pandas==2.0.1
# via icecube-skyreader
pika==1.3.1
pika==1.3.2
# via oms-mqclient
pillow==9.5.0
# via matplotlib
Expand Down Expand Up @@ -117,7 +117,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
8 changes: 4 additions & 4 deletions requirements-client-starter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via requests
cffi==1.15.1
# via cryptography
Expand All @@ -24,9 +24,9 @@ cryptography==40.0.2
# via pyjwt
cycler==0.11.0
# via matplotlib
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -107,7 +107,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
8 changes: 4 additions & 4 deletions requirements-nats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via requests
cffi==1.15.1
# via cryptography
Expand All @@ -26,9 +26,9 @@ cycler==0.11.0
# via matplotlib
ed25519==1.5
# via nkeys
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -111,7 +111,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
8 changes: 4 additions & 4 deletions requirements-pulsar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via
# pulsar-client
# requests
Expand All @@ -26,9 +26,9 @@ cryptography==40.0.2
# via pyjwt
cycler==0.11.0
# via matplotlib
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -109,7 +109,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
10 changes: 5 additions & 5 deletions requirements-rabbitmq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via requests
cffi==1.15.1
# via cryptography
Expand All @@ -24,9 +24,9 @@ cryptography==40.0.2
# via pyjwt
cycler==0.11.0
# via matplotlib
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -72,7 +72,7 @@ packaging==23.1
# matplotlib
pandas==2.0.1
# via icecube-skyreader
pika==1.3.1
pika==1.3.2
# via oms-mqclient
pillow==9.5.0
# via matplotlib
Expand Down Expand Up @@ -107,7 +107,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astropy==5.2.2
# icecube-skyreader
cachetools==5.3.0
# via wipac-rest-tools
certifi==2022.12.7
certifi==2023.5.7
# via requests
cffi==1.15.1
# via cryptography
Expand All @@ -24,9 +24,9 @@ cryptography==40.0.2
# via pyjwt
cycler==0.11.0
# via matplotlib
ewms-pilot==0.10.0
ewms-pilot==0.10.2
# via skymap-scanner (setup.py)
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
healpy==1.16.2
# via
Expand Down Expand Up @@ -105,7 +105,7 @@ scipy==1.10.1
# via healpy
six==1.16.0
# via python-dateutil
tornado==6.3.1
tornado==6.3.2
# via wipac-rest-tools
types-cryptography==3.3.23.2
# via pyjwt
Expand Down
7 changes: 6 additions & 1 deletion skymap_scanner/client/reco_icetray.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ def notifyStart(frame):
base_filename=baseline_GCD_file,
)

# create instance of reco_algo object
RecoAlgo = recos.get_reco_interface_object(reco_algo)
reco = RecoAlgo()
reco.setup_reco()

# perform fit
tray.AddSegment(
recos.get_reco_interface_object(reco_algo).traysegment,
reco.traysegment,
f"{reco_algo}_traysegment",
logger=LOGGER,
seed=pframe[f"{cfg.OUTPUT_PARTICLE_NAME}"],
Expand Down
23 changes: 20 additions & 3 deletions skymap_scanner/recos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
if TYPE_CHECKING: # https://stackoverflow.com/a/65265627
from ..utils.pixel_classes import RecoPixelVariation

from .. import config as cfg
from ..utils.data_handling import DataStager

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]
Expand All @@ -31,6 +34,21 @@ class RecoInterface:
# The spline files will be looked up in pre-defined local paths or fetched from a remote data store.
SPLINE_REQUIREMENTS: List[str] = list()

def init(self):
raise NotImplementedError()

def setup_reco(self):
"""Performs the necessary operations to prepare the execution of the reconstruction traysegment."""
raise NotImplementedError()

def get_datastager(self):
datastager = DataStager(
local_paths=cfg.LOCAL_DATA_SOURCES,
local_subdir=cfg.LOCAL_SPLINE_SUBDIR,
remote_path=f"{cfg.REMOTE_DATA_SOURCE}/{cfg.REMOTE_SPLINE_SUBDIR}",
)
return datastager

@staticmethod
def traysegment(tray, name, logger, **kwargs: Any) -> None:
raise NotImplementedError()
Expand All @@ -49,13 +67,12 @@ def get_all_reco_algos() -> List[str]:
]


def get_reco_interface_object(name: str) -> RecoInterface:
def get_reco_interface_object(name: str) -> type[RecoInterface]:
mlincett marked this conversation as resolved.
Show resolved Hide resolved
"""Dynamically import the reco sub-module's class."""
try:
# Fetch module
module = importlib.import_module(f"{__name__}.{name.lower()}")
# Build the class name (i.e. reco_algo -> RecoAlgo).
return getattr(module, "".join(x.capitalize() for x in name.split("_")))
return module.RECO_CLASS
except ModuleNotFoundError as e:
if name not in get_all_reco_algos():
# checking this in 'except' allows us to use 'from e'
Expand Down
12 changes: 11 additions & 1 deletion skymap_scanner/recos/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
import random
import time
from typing import List
from typing import List, Final

from I3Tray import I3Units # type: ignore[import]
from icecube import ( # type: ignore[import] # noqa: F401
Expand All @@ -28,6 +28,12 @@
class Dummy(RecoInterface):
"""Logic for a dummy reco."""

def __init__(self):
pass

def setup_reco(self):
pass

@staticmethod
@icetray.traysegment
def traysegment(tray, name, logger, **kwargs):
Expand Down Expand Up @@ -69,3 +75,7 @@ def to_recopixelvariation(frame: I3Frame, geometry: I3Frame) -> RecoPixelVariati
time=frame["Dummy_time"].value,
energy=frame["Dummy_time"].value,
)


# Provide a standard alias for the reconstruction class provided by this module.
RECO_CLASS: Final[type[RecoInterface]] = Dummy
mlincett marked this conversation as resolved.
Show resolved Hide resolved
Loading