Commit 52c67602 authored by Bogdan Vacaliuc's avatar Bogdan Vacaliuc
Browse files

script to execute a (non-interactive) mantid script and profile it

* provided to Pete Peterson on 2026-01-08 in PM
* text from earlier commit to private repo:

  1st cut of script to run a python script in the mantid environment and generate a profile output

  - TODO: handle optional arguments, allow spec of temporary folder for
    data, but both processes in the background and use foreground for logging
  - TODO: add parsing of .html into prometheus-style metrics

  The goal of future edits is to allow this script to be executed via cron
  jobs such that automated verification and profiling can be performed.
  The outputs of such steps to be formatted for the prometheus format.

  See:
  https://ornl-neutrons.atlassian.net/wiki/spaces/NDEVOPS/pages/8683644/Monitoring
  https://ornl-neutrons.atlassian.net/wiki/spaces/NDEVOPS/pages/537460737/Metrics+Gathering+for+Prometheus#The-Output-File
parent 060bd025
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
#!/bin/bash
TMP=$(mktemp)
ENV=${1:-mantid} ; shift
CMD=${2:-ScriptToExecuteWithProfile.py} ; shift

# execute main app in background
set -x
nsd-conda-wrap.sh ${ENV} --classic ${CMD} $@ > ${TMP} & pid=$!
# https://unix.stackexchange.com/questions/427115/listen-for-exit-of-process-given-pid-pid
trap 'tail --pid $pid -f /dev/null' EXIT

# execute profile process in foreground
nsd-conda-wrap.sh mantid_dev --classic -m mantidprofiler ${pid} --outfile ${TMP}.html && echo "Wrote ${TMP}.html"