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

Add new script for benchmarking #157

Merged
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ee0b7dd
add benchmarking configuration file
HealthyPear Aug 25, 2021
1076ae1
add new script to launch and produce benchmark notebooks as HTML pages
HealthyPear Aug 25, 2021
7391c2e
add papermill as a development dependency
HealthyPear Aug 25, 2021
fe06d2a
add new associated entry point protopipe-BENCHMARK
HealthyPear Aug 25, 2021
f661f3e
Update benchmarks.yaml
HealthyPear Aug 30, 2021
b66fc2d
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Aug 31, 2021
aba8bb1
Use single quotes for compatibility with GRID interface
HealthyPear Sep 6, 2021
a512b0c
Merge branch 'feature-add_protopipe_BENCHMARK' of https://github.com/…
HealthyPear Sep 6, 2021
2312755
improve comments in config file
HealthyPear Sep 7, 2021
3caab3b
Update launch_benchmark.py
HealthyPear Sep 27, 2021
9ae3a97
Update benchmarks.yaml
HealthyPear Sep 27, 2021
2379629
Require jupyter lab >=3.1.10
HealthyPear Sep 27, 2021
3437fdc
Create benchmark.rst
HealthyPear Sep 27, 2021
35bb202
Update index.rst
HealthyPear Sep 27, 2021
7c1d790
Fix error message formatting
HealthyPear Sep 27, 2021
5bf39ca
Properly ignore benchmark plots
HealthyPear Sep 29, 2021
fe06e75
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Sep 29, 2021
6a232cc
Ignore also log files
HealthyPear Sep 29, 2021
6662279
Update launch_benchmark.py
HealthyPear Oct 1, 2021
777730d
Update benchmarks.yaml
HealthyPear Oct 1, 2021
1007aba
Update setup.py for benchmark test
HealthyPear Oct 1, 2021
52e73b5
Update .gitignore
HealthyPear Jan 22, 2022
30a053c
Update documentation about protopipe-BENCHMARK
HealthyPear Jan 22, 2022
c4b8381
Refactor input functions
HealthyPear Jan 22, 2022
c3f0ee5
Improve new benchmarking script
HealthyPear Jan 22, 2022
7841958
Update setup.py
HealthyPear Jan 22, 2022
c3d042d
Update benchmarking configuration file
HealthyPear Jan 22, 2022
ce3300b
Update data_training.py and write_dl2.py for test pipeline
HealthyPear Jan 24, 2022
89fca27
import load_config and get_camera_names from protopipe.pipeline.io
HealthyPear Jan 24, 2022
dd9ef55
Update config
HealthyPear Feb 15, 2022
d604946
Update docs: script page
HealthyPear Feb 15, 2022
c8d82a7
Update docs
HealthyPear Feb 15, 2022
50892c1
Add support for analysis' Jupyter Book
HealthyPear Feb 28, 2022
efd17e3
Update docs
HealthyPear Feb 28, 2022
b0dc131
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Mar 1, 2022
2e300aa
fixes/updates to the docs
HealthyPear Mar 1, 2022
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
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.pytest_cache

.DS_Store

# Compiled files
.pytest_cache
*.py[co]
*.pyc
*.a
Expand All @@ -29,7 +26,7 @@ docs/api
docs/_build

# Benchmark plots
plots/
**/plots

# Eclipse editor project files
.project
Expand Down Expand Up @@ -80,6 +77,7 @@ distribute-*.tar.gz
.sonarlint

# output files (should not be stored in git)
*.log
*.h5
*.hdf5
*.fits
Expand Down
153 changes: 153 additions & 0 deletions docs/scripts/benchmark_script.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
.. _benchmark_script:

Benchmarking
============

``protopipe-BENCHMARK`` is used to run benchmarks.
It allows to list available benchmarking notebooks, interface with them
and optionally convert them in HTML format for easier consultation.

.. warning::

The *calibration* benchmark notebook requires a *ctapipe* version more
recent than the one which *protopipe* supports (`ctapipe >= 0.12.0`).

By invoking the help argument, you can get help about how the script works:
``protopipe-BENCHMARK`` has 2 sub-commands ``list`` and ``launch``,

.. code-block::

usage: protopipe-BENCHMARK [-h] {list,launch} ...

Launch a benchmark notebook and convert it to an HTML page.
USAGE EXAMPLE:
--------------
>>> protopipe-BENCHMARK list
>>> protopipe-BENCHMARK launch -n TRAINING/benchmarks_DL1b_image-cleaning --config_file benchmarks.yaml


positional arguments:
{list,launch}
list List available benchmarks
launch Launch a specific benchmark

optional arguments:
-h, --help show this help message and exit

The ``launch`` command is essentially a convenient wrapper
around `papermill <https://papermill.readthedocs.io/en/latest/>`__ and
(optionally) `jupyter nbconvert <https://nbconvert.readthedocs.io/en/latest/>`__.

On the first time ``protopipe-BENCHMARK`` is used to create a notebook,
it also creates the template for a `Jupyter Book <https://jupyterbook.org/intro.html>`__
dedicated to the analysis at hand (each benchmarking notebook will become a page).
At the end of the analysis, the book can be trasferred to the
`Performance repository <https://gitlab.cta-observatory.org/mperesano/protopipe-results>`__
as a Pull Request (please, see the README of that repository).

.. code-block::

usage: protopipe-BENCHMARK launch [-h] [--help-notebook] -n NAME --config_file CONFIG_FILE [-k [KWARGS [KWARGS ...]]] [--outpath OUTPATH]
[--overwrite] [--suffix SUFFIX] [--no_export]

optional arguments:
-h, --help show this help message and exit
--help-notebook Print the list of available notebook parameters
-n NAME, --name NAME Pipeline step and name of the benchmark (for a list use `protopipe-BENCHMARK -l`)
--config_file CONFIG_FILE
Configuration file (default: stored under analysis 'config' folder)
-k [KWARGS [KWARGS ...]], --kwargs [KWARGS [KWARGS ...]]
Overwrite or specify other configuration options (e.g. --kwargs foo=bar fiz=biz)
--outpath OUTPATH If unset it will be read from benchmaks.yaml
--overwrite Execute the notebook even if it overwrites the old result.
--suffix SUFFIX Suffix for result and HTML files (default: None)
--no_export Do not convert the result notebook to any other format.

The configuration file used by this script is ``benchmarks.yaml`` of which an example is reported here,

.. code-block:: yaml

# This configuration file simplifies the usage of benchmarks throughout the
# entire analysis.
# It is recommended to fill it and specify any remaining options using
# the --kwargs flag of protopipe-BENCHMARKS
# To specify directories, please provide full paths
# Note: users which use a CTADIRAC container should use paths OUTSIDE of it

# General settings for you analysis
analyses_directory: "ANALYSES_DIRECTORY" # filled by the grid interface
analysis_name: "ANALYSIS_NAME" # filled by the grid interface
# to compare with a previous release or version
load_protopipe_previous: False # If True load data from a previous analysis
analysis_name_2: "" # if files have different names override them (--kwargs)

# Global plot aesthetics settings
use_seaborn: True
matplotlib_settings:
# recommended colormaps: 'viridis' or 'cividis'
cmap: "cividis"
# recommended styles: 'tableau-colorblind10' or 'seaborn-colorblind'
style: "seaborn-colorblind"
rc: { "font_size": 8, "font_family": "Fira Sans" }
scale: 1.5 # scale all plots by a factor
seaborn_settings:
theme:
style: "whitegrid"
context: "talk"
# override context and/or style
rc_context: {}
rc_style: { "xtick.bottom": True, "ytick.left": True }

# Requirements data
load_requirements: True
requirements_input_directory: ""

# CTAMARS reference data
# available at https://forge.in2p3.fr/projects/step-by-step-reference-mars-analysis/wiki
load_CTAMARS: False
# this is a setup *required* to run the notebooks smoothly!
input_data_CTAMARS:
parent_directory: ""
TRAINING/DL1: "TRAINING/DL1"
TRAINING/DL2: "TRAINING/DL2"
DL2: "" # not available
DL3:
indir: "DL3"
infile: ""
label: "CTAMARS"

# EVENTDISPLAY reference data (only ROOT format, for the moment)
# available from https://forge.in2p3.fr/projects/cta_analysis-and-simulations/wiki#Instrument-Response-Functions
load_EventDisplay: True
input_data_EventDisplay:
input_directory:
input_file:
label: "EventDisplay"

# Input data
input_filenames:
# The simtel file is supposed to be used as a test run
# WARNING: CTAMARS comparison requires a specific simtel file, see notebook.
simtel: "" # (only) this is meant to be a full path
# This is data produced with protopipe
# These files are pre-defined so you shouldn't need to edit them
TRAINING_energy_gamma: "TRAINING_energy_tail_gamma_merged.h5"
TRAINING_classification_gamma: "TRAINING_classification_tail_gamma_merged.h5"
TRAINING_classification_proton: "TRAINING_classification_tail_proton_merged.h5"
DL2_gamma: "DL2_tail_gamma_merged.h5"
DL2_proton: "DL2_energy_tail_gamma_merged.h5"
DL2_electron: "DL2_energy_tail_gamma_merged.h5"
# The DL3 filename depends on the simulation and analysis settings
# Defined by editing performance.yaml
DL3: ""

model_configuration_filenames:
energy: "RandomForestRegressor.yaml"
classification: "RandomForestClassifier.yaml"

# This MUST be data produced with ctapipe-process
# with the JSON files available from protopipe or custom ones
input_filenames_ctapipe:
DL1a_gamma: "events_protopipe_CTAMARS_calibration_1stPass.dl1.h5"
DL1a_gamma_2ndPass: "events_protopipe_CTAMARS_calibration_2ndPass.dl1.h5"

1 change: 1 addition & 0 deletions docs/scripts/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Details
model_diagnostics
DL2
optimization_cuts_IRFs
benchmark_script

The tables created in the :ref:`data_training` and :ref:`DL2` steps are written
on disk in HDF5_ format using the PyTables_ Python module.
Expand Down
Binary file removed docs/usage/AnalysisTree.png
Binary file not shown.
Binary file added docs/usage/example_creation_analysis_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading