% Created 2021-02-04 Thu 12:12
% Intended LaTeX compiler: pdflatex
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{pdfpages}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{xspace}
\usepackage{libertine}
\usepackage{fontawesome}
\mode<beamer>{\usetheme{Boadilla}}
\setbeamertemplate{navigation symbols}{}
\hypersetup{colorlinks}
\setbeamerfont{alerted text}{series=\bfseries}
\usetheme{default}
\author{Brett Viren}
\date{\today}
\title{Jumbled thoughts on configuring multiprocess minidaqapp}
\hypersetup{
 pdfauthor={Brett Viren},
 pdftitle={Jumbled thoughts on configuring multiprocess minidaqapp},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.1.90 (Org mode 9.4.4)}, 
 pdflang={English}}
\begin{document}

\maketitle

\begin{frame}[label={sec:org4dee73f}]{Boundary conditions}
\begin{itemize}
\item Description of desired processes in form of a list of job names and their modules
\item Target configuration needed for simple shell command line launch and command but with guesses about factoring for eventual CCM (RC, PM, etc).
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org78fa42c}]{Meta Configuration}
Given list of desired processes:
\begin{itemize}
\item Understand common information
\item Factor into ``meta parameter set'' MPS
\item Describe MPS in schema
\item Provide object generation code
\end{itemize}

Object generation:
\begin{itemize}
\item Given MPS object, make per-process command sets
\item Generate config file for trivial process launcher
\end{itemize}
\end{frame}


\begin{frame}[label={sec:orgec12a2a}]{Conceptual model of CCM to target}
Chicken-and-egg problem right now for CCM/config.

\begin{itemize}
\item \footnotesize Can not build the next ``meta'' levels without knowing what we actually need.

\item People providing those levels need to know something about how they are configured.
\end{itemize}

Break the cycle by develop some initial straw model which both can
work toward.
\end{frame}

\begin{frame}[label={sec:orgbe81bf7}]{A portion of my mental model of CCM}
\footnotesize

\begin{description}
\item[{\(\mathcal{S}_R\)}] Schema to holistically describe configuration for a \alert{type of run} \(R\)
\item[{\(\mathcal{C}_r\)}] Object to describe configuration for a \alert{specific run} \(r\) of type \(R\)
\item[{\(f_{gen}(\mathcal{S}_R) \to \mathcal{C}_r\)}] generator of schema-valid configuration object (now scripts, later web gui)
\item[{\(F_{rc}(\mathcal{C}_r) \to run\)}] \emph{Run Control} produces running DAQ as a functional side effect, given configuration.  It is composed of parts:
\item[{\(f_{link}(\mathcal{C}_r) \to \{\mathcal{L}\}\)}] produce set of URLs of process's REST \emph{Command Facility} instances
\item[{\(f_{proc}(\mathcal{C}_r) \to \{\mathcal{P}\}\)}] produce set of per-process configuration objects (commands) with info needed to start the processes
\item[{\(F_{pm}(\mathcal{P}) \to proc\)}] A \emph{Process Manager} starts a process
\item[{\(f_{init}(\mathcal{C}_r) \to \{c_{init}\}\)}] A filter function produces a set of \alert{init} command objects for processes.
\item[{\(F_{rc}(\{\mathcal{L}\}, \{c_{init}\}) \to S_{initialized}\)}] RC sends \alert{init} commands bringing DAQ to \emph{initialized} state.
\item[{\(f_{conf}(\mathcal{C}_r) \to \{c_{conf}\}\)}] A filter function produces a set of \alert{conf} command objects for processes.
\item[{\(F_{rc}(\{\mathcal{L}\}, \{c_{conf}\}) \to S_{configured}\)}] RC sends \alert{conf} commands bringing DAQ to \emph{configured} state.
\item[{etc}] other command types, and possibly some new ones to enact a new command for ``light weight'' configuration.
\end{description}
\end{frame}


\begin{frame}[label={sec:orgab4cb9e},fragile]{Near term development}
 Trivially mock up RC/PM duties in order to provide straw use case for factoring \(\mathcal{S}_R\) and providing \(f_{gen}()\).

Mock will look something like this:
\begin{itemize}
\item \footnotesize Based on description from minidaqapp experts, define schema for MPS parts of \(\mathcal{S}_R\).
\item Use \texttt{moo.otypes} Python to generate MPS objects.
\item Adapter to use MPS object and reuse per-module \texttt{moo.otypes} code to produce per process command objects.
\item Implement \(f_{link}()\) by extracting from MPS.
\item Implement \(f_{proc}()\) and \(F_{pm}\) by generating \href{https://github.com/ddollar/foreman}{foreman} config file with moo template and \(\mathcal{C}_r\) and execute with simple \href{https://github.com/chrismytton/shoreman}{shoreman} bash script.
\item Implement sending of commands similar to now (\texttt{ddrepl} style) but which operate on a set of \alert{init} or set of \alert{conf} instead of one at a time.
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org1dbbfd3},fragile]{Foreman/shoreman}
 \footnotesize

The \texttt{shoreman} Bash script literally ``just'' runs command lines and waits
for them to finish, giving useful log capture and clean \texttt{Ctrl-c} death.  Its config file is in Foreman format:

\scriptsize
\begin{verbatim}
# minidaq.proc file generated by moo
gencfg gencfg.py -o config.json -i meta.jsonnet -s schema.jsonnet
proc1  daq_application --commandFacility rest://hostname:8081
proc2  daq_application --commandFacility rest://hostname:8082
\end{verbatim}

\footnotesize
Run like:

\begin{verbatim}
$ shoreman minidaq.proc
$ mockrc.py -c config.json init
$ mockrc.py -c config.json conf  
\end{verbatim}

\begin{description}
\item[{\texttt{shoreman}}] super dumb process manager
\item[{\texttt{gencfg.py}}] \(f_{gen}()\)
\item[{\texttt{mockrc.py}}] super dumb RC's \(f_{cmd}()\)
\end{description}
\end{frame}
\end{document}
