Skip to content

Commit

Permalink
CNF posrec urlconfig fix (#1519)
Browse files Browse the repository at this point in the history
* change peaklet cnf posrec model urlconfig to point to xedocs

* change flow to cnf

* add xedocs version requiremement

* change urlconfig name of cnf model to cnf_pred_function to be less generic

* Bug fix

* Bug fix

---------

Co-authored-by: Juehang Qin <qinjuehang@rice.edu>
Co-authored-by: Giovanni Volta <38431109+GiovanniVolta@users.noreply.github.com>
Co-authored-by: dachengx <dx2227@columbia.edu>
  • Loading branch information
4 people authored Jan 24, 2025
1 parent 4519fa7 commit 0c44889
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mistune = "==0.8.4"
pymongo = "*"
requests = "*"
utilix = ">=0.11.0"
xedocs = "*"
xedocs = ">=0.2.32"
commonmark = { version = "0.9.1", optional = true }
nbsphinx = { version = "0.8.9", optional = true }
recommonmark = { version = "0.7.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion straxen/config/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_item_or_attr(obj, key, default=None):

@URLConfig.register("resource")
def get_resource(name: str, fmt: str = "text", readable: bool = False, **kwargs):
"""Fetch a straxen resource Allow a direct download using <fmt='abs_path'> otherwise kwargs are
"""Fetch a straxen resource, allow a direct download using <fmt='abs_path'> otherwise kwargs are
passed directly to straxen.get_resource."""
if fmt == "abs_path":
downloader = utilix.mongo_storage.MongoDownloader()
Expand Down
11 changes: 6 additions & 5 deletions straxen/plugins/peaklets/peaklet_positions_cnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PeakletPositionsCNF(PeakletPositionsBase):
- sig: Confidence level of the contour
- log_area_scale: Scaling parameter for log area
- n_top_pmts: Number of top PMTs
- pred_function: Path to the compiled JAX function for predictions
- cnf_pred_function: Path to the compiled JAX function for predictions
"""

Expand Down Expand Up @@ -56,10 +56,11 @@ class PeakletPositionsCNF(PeakletPositionsBase):
help="Scaling parameter for log area",
)

pred_function = straxen.URLConfig(
cnf_pred_function = straxen.URLConfig(
default=(
"jax://resource://flow_20240730.tar.gz?"
"n_poly=plugin.n_poly&sig=plugin.sig&fmt=abs_path"
"jax://resource://xedocs://posrec_models"
"?kind=cnf&attr=value&n_poly=plugin.n_poly&sig=plugin.sig&fmt=abs_path"
"&version=ONLINE&run_id=plugin.run_id"
),
help="Compiled JAX function",
)
Expand Down Expand Up @@ -150,7 +151,7 @@ def vectorized_prediction_chunk(self, flow_condition):
else:
inputs = np.zeros((self.N_chunk_max, self.n_top_pmts + 1))
inputs[:N_entries] = flow_condition
xy, contour = self.pred_function(inputs)
xy, contour = self.cnf_pred_function(inputs)
return xy[:N_entries], contour[:N_entries]

def prediction_loop(self, flow_condition):
Expand Down

0 comments on commit 0c44889

Please sign in to comment.