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 runid from lineage #128

Merged
merged 8 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ cd saltax
pip install ./ --user
```
## Tutorial
Please check notebooks in `notebooks/`
Please check notebooks in `notebooks/`.

## Computing
Please see folder `jobs/` for slurm job submission
Please see folder `jobs/` for slurm job submission. Below you can see a benchmark from a 26seconds Ar37 run, sprinkled 50Hz flat beta band. You can roughly estimate the overhead by scaling it, neglecting the rate dependence in overhead.

| Step | Overhead [sec] (salt) | Overhead [sec] (simu) |
| :-------------------: | :-------------------: | :-------------------: |
| `microphysics_summary`| 19 | |
| `raw_records_simu` | 210 | |
| `records` | 15 | |
| `peaklets` | 68 | 9 |
| `peak_basics` | 3 | 1 |
| `event_info` | 63 | 11 |
2 changes: 0 additions & 2 deletions saltax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__version__ = "0.1.1"

from . import instructions
from .instructions import *

Expand Down
37 changes: 18 additions & 19 deletions saltax/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from immutabledict import immutabledict
import fuse
import logging

# import pema
import pandas as pd
from utilix import xent_collection


logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger("fuse.context")
Expand Down Expand Up @@ -46,9 +46,6 @@
# ~Infinite raw_records file size to avoid downchunking
MAX_RAW_RECORDS_FILE_SIZE_MB = 1e9

# fuse placeholder parameters
CORRECTION_RUN_ID_DEFAULT = "046477"

# straxen XENONnT options/configuration
XNT_COMMON_OPTS = straxen.contexts.xnt_common_opts.copy()
XNT_COMMON_CONFIG = straxen.contexts.xnt_common_config.copy()
Expand Down Expand Up @@ -112,6 +109,20 @@
SALTAX_MODES = ["data", "simu", "salt"]


def validate_runid(runid):
"""Validate runid in RunDB to see if you can use it for computation.

:param runid: run number in integer
:return: None
"""
try:
doc = xent_collection().find_one({"number": runid})
if doc is None:
raise ValueError(f"Run {runid} not found in RunDB")
except Exception as e:
raise ValueError(f"Run {runid} not found in RunDB: {e}")


def get_generator(generator_name):
"""Return the generator function for the given instruction mode.

Expand Down Expand Up @@ -166,11 +177,6 @@ def xenonnt_salted_fuse(
:param kwargs: Extra options to pass to strax.Context or generator
:return: strax context
"""
# Manually assign a correction_run_id if runid is None
if runid is None:
corrections_run_id = CORRECTION_RUN_ID_DEFAULT
else:
corrections_run_id = runid
if (corrections_version is None) & (not run_without_proper_corrections):
raise ValueError(
"Specify a corrections_version. If you want to run without proper "
Expand Down Expand Up @@ -209,15 +215,6 @@ def xenonnt_salted_fuse(
simulation_config_file = "fuse_config_nt_{:s}.json".format(simu_config_version)
fuse.context.set_simulation_config_file(st, simulation_config_file)

local_versions = st.config
for config_name, url_config in local_versions.items():
if isinstance(url_config, str):
if "run_id" in url_config:
local_versions[config_name] = straxen.URLConfig.format_url_kwargs(
url_config, run_id=corrections_run_id
)
st.config = local_versions

# Update some run specific config
for mc_config, processing_config in run_id_specific_config.items():
if processing_config in st.config:
Expand Down Expand Up @@ -475,6 +472,7 @@ def fxenonnt(
)
log.warning("Welcome to data-loading only mode!")
else:
validate_runid(runid)
log.warning("Welcome to computation mode which only works for run %s!" % (runid))

return xenonnt_salted_fuse(
Expand Down Expand Up @@ -544,6 +542,7 @@ def sxenonnt(
)
log.warning("Welcome to data-loading only mode!")
else:
validate_runid(runid)
log.warning("Welcome to computation mode which only works for run %s!" % (runid))

return xenonnt_salted_wfsim(
Expand Down
1 change: 0 additions & 1 deletion saltax/instructions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
__version__ = "0.1.1"
from . import generator
from .generator import *
1 change: 0 additions & 1 deletion saltax/match/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__version__ = "0.1.1"
from . import match
from .match import *
from . import visual
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
author="Lanqing Yuan",
description="Salting analysis framework for XENONnT.",
long_description=readme,
version="0.1.1",
version="0.1.2",
install_requires=requires,
setup_requires=["pytest-runner"],
tests_require=requires + ["pytest", "hypothesis", "boltons"],
Expand Down
Loading