Skip to content

Abstract out consumers to CLI program.

Luke Davis requested to merge feature/cli_consumers into dev

Each consumer is separated into a Click command that lazily imports their modules when they're needed.

Example outputs:

$ spiir-consumer --help
Usage: spiir-consumer [OPTIONS] COMMAND [ARGS]...

Options:
  -u, --username TEXT     Username for SCIMMA hop authentication credentials
                          in auth.toml
  -s, --server TEXT       URL of hop-client server to stream topics from.
                          [default: kafka://kafka.scimma.org/]
  -g, --group TEXT        Name of GraceDB group  [default: gracedb-playground]
  -t, --topics TEXT       IGWN Kafka topics for the listener to subscribe to.
                          [default: test_spiir_allsky,
                          test_spiir_earlywarning]
  -c, --credentials TEXT  Location of auth.toml credentials file  [default:
                          ~/.config/hop/auth.toml]
  --save-dir TEXT         Output directory for payload and output files.
                          [default: ./results/]
  --upload-gracedb        Whether to upload output to GraceDb
  --log-file TEXT         Specify location to output log file
  -v, --verbose           Set logging level to INFO.
  -d, --debug             Set logging level to DEBUG.
  --help                  Show this message and exit.

Commands:
  coinc        Graphs time series for SNR and PSD of each IFO.
  event        Saves all uploaded event files to disk.
  far-contour  Computes far_contour figure.
  p-astro      Predicts p_astro.
  sealgw       Computes Sealgw skymap.
$ spiir-consumer sealgw --help
Usage: spiir-consumer sealgw [OPTIONS] SEAL_CONFIG

  SEAL_CONFIG: Path to SealGW config file.

Options:
  --nthreads INTEGER  Specify number of threads to use.  [default: 8]
  --nlevel INTEGER    Specify level for healpix.  [default: 5]
  --help              Show this message and exit.
$ spiir-consumer --save-dir ./results/ --upload-gracedb -t test_spiir_allsky -t cbc_spiir_allsky -t test_spiir_earlywarning -t cbc_spiir_earlywarning --group gracedb-playground --username luke.davis-9a879216 --log-file ./logs/p-astro-consumer.log --debug p-astro ./fgmc.pkl ./mchirp_area.pkl
2023-10-26 00:41:04 - spiir - DEBUG - Initialising file log output to ./logs/p-astro-consumer.log.
2023-10-26 00:41:07 - spiir.io.igwn.alert.consumer - DEBUG - [PAstroConsumer] Loading luke.davis-9a879216 credentials from /home/spiir/.config/hop/auth.toml
2023-10-26 00:41:07 - spiir.io.igwn.alert.consumer - DEBUG - [PAstroConsumer] Listening to topics: test_spiir_allsky, cbc_spiir_allsky, test_spiir_earlywarning, cbc_spiir_earlywarning.
Edited by Luke Davis

Merge request reports