Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f0b343d
KM3NeT conversion code added
Feb 27, 2025
36878b6
KM3NeT conversion code added
Feb 27, 2025
02e64b7
Installation and example information added.
Feb 27, 2025
da1340f
Update install.rst
giogiopg Mar 10, 2025
d16bec7
has_km3net_package added
Mar 10, 2025
bb546cf
Merge branch 'main' of https://github.com/KM3NeT/graphnet into main
Mar 10, 2025
d4814e2
Changes on km3net example
May 7, 2025
ad451ea
Updated example's readme, the installation instructions and the examp…
May 8, 2025
4762ef7
Merge branch 'graphnet-team:main' into main
giogiopg May 8, 2025
32f1cb0
Merge branch 'graphnet-team:main' into main
giogiopg May 13, 2025
b618a1f
Merge branch 'graphnet-team:main' into main
giogiopg Jun 23, 2025
7f906ec
Merge branch 'graphnet-team:main' into main
giogiopg Jun 23, 2025
447d985
Update km3nettruthextractor.py
giogiopg Jul 23, 2025
cde2038
Update km3nettruthextractor.py
giogiopg Jul 24, 2025
f7daa79
Update km3netpulseextractor.py
giogiopg Jul 24, 2025
8f62084
Merge branch 'graphnet-team:main' into main
giogiopg Jul 24, 2025
d42f8a2
Update install.rst
giogiopg Jul 24, 2025
a610137
Update km3netpulseextractor.py
giogiopg Jul 24, 2025
ba3fa8c
Merge branch 'graphnet-team:main' into main
giogiopg Aug 18, 2025
6a85e9b
Merge branch 'graphnet-team:main' into main
giogiopg Sep 2, 2025
fc711cc
Revise installation steps for tool-version agreement
giogiopg Sep 2, 2025
e3c7cff
Modify drop logic for DataFrame columns
giogiopg Sep 2, 2025
1870c2d
Merge branch 'graphnet-team:main' into main
giogiopg Sep 23, 2025
3a128cd
Merge branch 'graphnet-team:main' into main
giogiopg Oct 14, 2025
04c5055
Fix typos and clarify conda environment setup
giogiopg Oct 14, 2025
7f6859e
Improve installation instructions in install.rst
giogiopg Oct 14, 2025
c02e4db
fix `with:`
RasmusOrsoe Oct 21, 2025
e42ed54
specify flake8 config
RasmusOrsoe Oct 21, 2025
9821ed2
add whitespace fixer to pre-commit config
RasmusOrsoe Oct 21, 2025
9c9d295
bumpy py version in code-quality check workflow
RasmusOrsoe Oct 21, 2025
049f599
run ´pre-commit --all-files´
RasmusOrsoe Oct 21, 2025
08954f6
# noqa: C901 on `highest_energy_starting`
RasmusOrsoe Oct 21, 2025
e45f714
Merge branch 'graphnet-team:main' into main
giogiopg Oct 27, 2025
de50e86
Merge pull request #845 from RasmusOrsoe/fix_code_quality_workflow
RasmusOrsoe Nov 11, 2025
9957737
Enable from logits option in BCE
sevmag Oct 30, 2025
0315c7d
missing import and docstring
sevmag Nov 7, 2025
ad342c3
running new linting
sevmag Nov 11, 2025
0a89fa8
Fixing merging issue
sevmag Nov 11, 2025
fd53394
Merge pull request #847 from sevmag/bce_with_logits
sevmag Nov 11, 2025
42fe543
Merge branch 'main' into main
giogiopg Nov 12, 2025
2343816
Refactor imports in km3netpulseextractor.py
giogiopg Nov 12, 2025
66577ea
Add KM3NeTExtractor to GraphNeTFileReader
giogiopg Nov 18, 2025
88880f7
Add KM3NeTExtractor to data converter
giogiopg Nov 18, 2025
e407119
Remove unused padding_value in unique ID determination
giogiopg Nov 18, 2025
487df68
Change return type to List[int] in km3net_utilities.py
giogiopg Nov 18, 2025
65db331
Add SNOWSTORM constants for data processing
giogiopg Nov 19, 2025
a088f9a
flake8 code quality changes.
Nov 27, 2025
b9dc5a4
Merge pull request #848 from KM3NeT/main
giogiopg Dec 4, 2025
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
2 changes: 1 addition & 1 deletion .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ runs:
echo "Installing graphnet with flags: ${{ steps.flags.outputs.user_flag }} ${{ steps.flags.outputs.editable_flag }}"
echo "pip install ${{ steps.flags.outputs.user_flag }} ${{ steps.flags.outputs.editable_flag }} .[torch-${{ steps.flags.outputs.torch_flag }},${{ inputs.extras }}] -f https://data.pyg.org/whl/torch-${{ inputs.torch_version }}+${{ inputs.hardware }}.html"
pip install ${{ steps.flags.outputs.user_flag }} ${{ steps.flags.outputs.editable_flag }} .[torch-${{ steps.flags.outputs.torch_flag }},${{ inputs.extras }}] -f https://data.pyg.org/whl/torch-${{ inputs.torch_version }}+${{ inputs.hardware }}.html

pip install git+https://github.com/thoglu/jammy_flows.git
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fi

build-icetray:
name: Unit tests - IceTray (v1.13.0 - 3.10)
name: Unit tests - IceTray (v1.13.0 - 3.10)
needs: [ check-Qlty-credentials ]
runs-on: ubuntu-22.04
strategy:
Expand All @@ -43,7 +43,7 @@ jobs:
# GitHub Actions overwrite the docker container entrypoint
# inspect <image> --format '{{.Config.Entrypoint}}'
image: icecube/icetray:icetray-devel-v1.13.0-ubuntu22.04-2025-02-12

steps:
- name: Mimmick Docker Entrypoint
# The entrypoint of the container sets python paths
Expand All @@ -62,7 +62,7 @@ jobs:
- name: Verify IceCube is importable
run: python3 -c "import icecube; print('Import Successful')"
- name: Show python version
run: |
run: |
python3 --version
pip --version
pip3 list
Expand Down Expand Up @@ -122,9 +122,9 @@ jobs:
shell: bash
run: |
source ~/venv/bin/activate
coverage run --source=graphnet -m pytest tests/ --ignore=tests/examples/04_training --ignore=tests/utilities
coverage run --source=graphnet -m pytest tests/ --ignore=tests/examples/04_training --ignore=tests/utilities
coverage run -a --source=graphnet -m pytest tests/examples/04_training
coverage run -a --source=graphnet -m pytest tests/utilities
coverage run -a --source=graphnet -m pytest tests/utilities
coverage xml -o coverage.xml
coverage report -m
- name: Work around permission issue
Expand All @@ -136,7 +136,7 @@ jobs:
with:
token: ${{secrets.QLTY_TOKEN}}
files: coverage.xml


build-matrix-examples:
name: Examples - Ubuntu 22.04
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ jobs:
hook: ["black", "flake8", "docformatter", "pydocstyle", "mypy"]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install package
uses: ./.github/actions/install
with:


- name: Run ${{ matrix.hook }}
run: |
pip show ${{ matrix.hook }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
workflow_call:
inputs:
DOCKERHUB_NAME: { type: string, required: true }
DOCKERFILE_PATH: { type: string, required: true}
DOCKERFILE_PATH: { type: string, required: true}
GRAPHNET_VERSION: { type: string, default: "main" }
BASE_IMAGE: { type: string, default: "ubuntu:22.04" }
TORCH_CHOICE: { type: string, default: "torch-2.6.0" } # torch-2.7.0|2.6.0|2.5.1|no_torch
HARDWARE: { type: string, default: "cpu" } # cpu|cu118|cu121|cu124|cu126|cu128
PYTHON_VERSION: { type: string, default: "3.11" }
PLATFORMS: { type: string, default: "linux/amd64" }
CONTEXT_PATH: { type: string, default: "." }
CONTEXT_PATH: { type: string, default: "." }
secrets:
DOCKERHUB_USERNAME:
required: true
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ${{ inputs.CONTEXT_PATH }}
file: ${{ inputs.DOCKERFILE_PATH }}
file: ${{ inputs.DOCKERFILE_PATH }}
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.tag.outputs.full }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/paper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
path: paper/paper.pdf
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ data/examples/output/
**.pth
**.db
**.parquet
# Exception to pre-trained folders; here we want all .pth files
# Exception to pre-trained folders; here we want all .pth files
!/graphnet/src/graphnet/models/pretrained/**/**/**/**/**.pth
# Exception to geometry tables
# Exception to geometry tables
!/data/geometry_tables/**/**.parquet
!/data/tests/sqlite/upgrade_genie_step4_140028_000998_first_5_frames/upgrade_genie_step4_140028_000998_first_5_frames.db
!/data/tests/parquet/oscNext_genie_level7_v02/merged/**
Expand Down
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repos:
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
language_version: python3
- id: flake8
args: ["--config=.flake8", "--show-source", "--statistics"]
- repo: https://github.com/pycqa/docformatter
rev: v1.7.7
hooks:
Expand All @@ -26,4 +26,9 @@ repos:
hooks:
- id: mypy
args: [--follow-imports=silent, --disallow-untyped-defs, --disallow-incomplete-defs, --disallow-untyped-calls]
language_version: python3
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ version: 1.0.0
date-released: 2023-05-12
url: "https://github.com/graphnet-team/graphnet"
license: Apache-2.0
type: software
type: software
2 changes: 1 addition & 1 deletion black.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ extend-exclude = '''
versioneer.py
| src/graphnet/_version.py
)
'''
'''
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ selection:
train_nu_e: 60 random events ~ event_no % 5 > 1 & (dummy_pid == 12 | dummy_pid == -12)
train_nu_mu: 60 random events ~ event_no % 5 > 1 & (dummy_pid == 14 | dummy_pid == -14)
train_nu_tau: 60 random events ~ event_no % 5 > 1 & (dummy_pid == 16 | dummy_pid == -16)
train_mu: 60 random events ~ event_no % 5 > 1 & (dummy_pid == 13 | dummy_pid == -13)
train_mu: 60 random events ~ event_no % 5 > 1 & (dummy_pid == 13 | dummy_pid == -13)
2 changes: 1 addition & 1 deletion configs/datasets/training_example_data_parquet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ seed: 21
selection:
test: event_no % 5 == 0
validation: event_no % 5 == 1
train: event_no % 5 > 1
train: event_no % 5 > 1
2 changes: 1 addition & 1 deletion configs/datasets/training_example_data_sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ seed: 21
selection:
test: event_no % 5 == 0
validation: event_no % 5 == 1
train: event_no % 5 > 1
train: event_no % 5 > 1
Binary file not shown.
2 changes: 1 addition & 1 deletion docker/gnn-benchmarking/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ WORKDIR /root
ADD module.py ./module.py
ADD apply.py ./apply.py

CMD [ "/bin/bash" ]
CMD [ "/bin/bash" ]
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ RUN echo 'PS1="🐳 \[\033[38;2;86;138;242m\]graphnet@\h \[\033[0m\]❯ \[\033[0
RUN echo 'PS2="\[\033[38;5;236m\]❯\[\033[38;5;239m\]❯\[\033[0m\]❯ "' >> ~/.bashrc

# Default command for executing container.
CMD [ "/bin/bash" ]
CMD [ "/bin/bash" ]
48 changes: 47 additions & 1 deletion docs/source/installation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,52 @@ To achieve this, we recommend installing |graphnet|\ GraphNeT into a CVMFS with

Once installed, |graphnet|\ GraphNeT is available whenever you open the CVMFS locally.

Installation with km3io (KM3NeT)
-----------------------------------------------

This installation is only necessary if you want to process KM3NeT/ARCA or KM3NeT/ORCA files. Processing means converting them from a `.root` offline format into a suitable format for training using |graphnet|. If you already have your KM3NeT data in `SQLite` or `parquet` format and only want to train a model or perform inference on this database, this specific installation is not needed.

Note that this installation will add `km3io` ensuring it is built with a compatible versions. The steps below are provided for a conda environment, with an enviroment created in the same way it is done above in this page, but feel free to choose a different enviroment setup.

As mentioned, it is highly reommended to create a conda enviroment where your installation is done to do not mess up any dependecy. It can be done with the following commands:

.. code-block:: bash

# Create an environment with Python 3.10
conda create -p <full-path-to-env> --no-default-packages python=3.10 -y
# Activate the environment and move to the graphnet repository you just cloned. If using conda:
conda activate <full-path-to-env>

The isntallation of GraphNeT is then done by:

.. code-block:: bash

git clone https://github.com/graphnet-team/graphnet.git
cd graphnet

Choose the appropriate requirements file based on your system. Here there is just an example of installation with PyTorch-2.5.1 but check the matrix above for a full idea of all the versions can be installed.

For CPU-only enviroments:

.. code-block:: bash

pip3 install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu
pip3 install -e .[torch-25] -f https://data.pyg.org/whl/torch-2.5.1+cpu.html

For GPU enviroments with, for instance, CUDA 11.8 drivers:

.. code-block:: bash

pip3 install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
pip3 install -e .[torch-25] -f https://data.pyg.org/whl/torch-2.5.1+cu118.html

Downgrade setuptools for compatibility between km3io and GraphNeT.

.. code-block:: bash

pip3 install --force-reinstall setuptools==70.3.0
pip3 install km3io==1.2.0


.. note::
We recommend installing |graphnet|\ GraphNeT without GPU in clean metaprojects.

2 changes: 1 addition & 1 deletion examples/04_training/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This subfolder contains two main training scripts:
# Same as above, as this is the default model config.
(graphnet) $ python examples/04_training/03_train_dynedge_from_config.py \
--model-config configs/models/example_energy_reconstruction_model.yml

# Train a vertex position reconstruction model
(graphnet) $ python examples/04_training/03_train_dynedge_from_config.py \
--model-config configs/models/example_vertex_position_reconstruction_model.yml
Expand Down
2 changes: 1 addition & 1 deletion examples/05_liquido/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# LiquidO data conversion example

This directory contain examples of converting data from LiqidO to intermediate data formats suitable for deep learning in GraphNeT
This directory contain examples of converting data from LiqidO to intermediate data formats suitable for deep learning in GraphNeT
2 changes: 1 addition & 1 deletion examples/06_prometheus/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Prometheus data conversion example

This directory contain examples of converting data from the open-source neutrino telescope Prometheus simulation to intermediate data formats suitable for deep learning in GraphNeT.
This directory contain examples of converting data from the open-source neutrino telescope Prometheus simulation to intermediate data formats suitable for deep learning in GraphNeT.

More details on the Prometheus simulation project can be found [here](https://arxiv.org/pdf/2304.14526.pdf)
104 changes: 104 additions & 0 deletions examples/07_km3net/01_convert_km3net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""Code to run the extraction of km3net data."""

import os
import warnings

from graphnet.constants import EXAMPLE_OUTPUT_DIR, TEST_DATA_DIR
from graphnet.data.readers import KM3NeTReader
from graphnet.data.writers import ParquetWriter, SQLiteWriter
from graphnet.data import DataConverter
from graphnet.data.extractors.km3net import (
KM3NeTTruthExtractor,
KM3NeTFullPulseExtractor,
KM3NeTTriggPulseExtractor,
KM3NeTHNLTruthExtractor,
KM3NeTRegularRecoExtractor,
KM3NeTHNLRecoExtractor,
)

from graphnet.utilities.argparse import ArgumentParser


def main(backend: str, triggered: str, HNL: str, OUTPUT_DIR: str) -> None:
"""Convert ROOT files from KM3NeT to `backend` format."""
warnings.simplefilter(action="ignore", category=FutureWarning)

input_dir = [f"{TEST_DATA_DIR}/km3net"]
if OUTPUT_DIR != "None":
outdir = f"{OUTPUT_DIR}/{backend}"
else:
outdir = f"{EXAMPLE_OUTPUT_DIR}/{backend}"
os.makedirs(outdir, exist_ok=True)
print(60 * "*")
print(f"Saving to {outdir}")
print(60 * "*")
if backend == "parquet":
save_method = ParquetWriter(truth_table="truth")
elif backend == "sqlite":
save_method = SQLiteWriter() # type: ignore
else:
raise ValueError("Invalid backend choice")

if HNL == "km3net-vars":
truth_extractor = KM3NeTTruthExtractor(name="truth")
reco_extractor = KM3NeTRegularRecoExtractor(name="reco")
elif HNL == "hnl-vars":
truth_extractor = KM3NeTHNLTruthExtractor(name="truth") # type: ignore
reco_extractor = KM3NeTHNLRecoExtractor(name="reco") # type: ignore
else:
raise ValueError("Invalid HNL choice")

if triggered == "Triggered":
pulse_extractor = KM3NeTTriggPulseExtractor(name="pulse_map")
elif triggered == "Snapshot":
pulse_extractor = KM3NeTFullPulseExtractor(
name="pulse_map"
) # type: ignore
else:
raise ValueError("Invalid triggered choice")

converter = DataConverter(
file_reader=KM3NeTReader(),
save_method=save_method,
extractors=[truth_extractor, pulse_extractor, reco_extractor],
outdir=outdir,
num_workers=1,
)

converter(input_dir=input_dir)


if __name__ == "__main__":

# Parse command-line arguments
parser = ArgumentParser(
description="""
Convert root files from KM3NeT to an sqlite or parquet.
"""
)

parser.add_argument(
"backend",
choices=["sqlite", "parquet"],
help="Choose the backend format",
)
parser.add_argument(
"triggered",
choices=["Triggered", "Snapshot"],
help="Choose between triggered or snapshot pulse maps",
)
parser.add_argument(
"HNL",
choices=["km3net-vars", "hnl-vars"],
help="Km3net truth or adding Heavy Neutral Lepton info",
)
parser.add_argument(
"OUTPUT_DIR",
default="None",
help="Output directory (optional)",
)

args, unknown = parser.parse_known_args()

# Run example script
main(args.backend, args.triggered, args.HNL, args.OUTPUT_DIR)
Loading
Loading