Skip to content

Commit 1df2d34

Browse files
committed
add some Architectural Decisions
1 parent e486a7f commit 1df2d34

File tree

4 files changed

+147
-3
lines changed

4 files changed

+147
-3
lines changed

docs/developer/explanations/decisions/0002-switched-to-pip-skeleton.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
2. Adopt epics-containers.github.io for project structure
2-
=========================================================
1+
2. Adopt python3-pip-skeleton for project structure
2+
===================================================
33

44
Date: 2022-02-18
55

@@ -11,7 +11,7 @@ Accepted
1111
Context
1212
-------
1313

14-
We should use the following `pip-skeleton <https://github.com/epics-containers/epics-containers.github.io>`_.
14+
We should use the following `pip-skeleton <https://github.com/DiamondLightSource/python3-pip-skeleton>`_.
1515
The skeleton will ensure consistency in developer
1616
environments and package management.
1717

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
3. Use of substitution files to generate EPICS Databases
2+
========================================================
3+
4+
Date: 2023-11-30
5+
6+
Status
7+
------
8+
9+
Accepted
10+
11+
Context
12+
-------
13+
14+
There are two proposals for how EPICS Databases should be generated:
15+
16+
1. At IOC startup ``ibek`` should generate a substitution file that describes the
17+
required Databases.
18+
19+
The IOC instance yaml combined with the definitions from support module yaml
20+
controls what the generated substitution file will look like.
21+
22+
``ibek`` will then execute ``msi`` to generate the Databases from the
23+
substitution file.
24+
25+
2. The dbLoadRecord calls in the startup script will pass all macro substitutions
26+
in-line. Removing the need for a substitution file.
27+
28+
29+
Decision
30+
--------
31+
32+
Proposal 1 is accepted.
33+
34+
Some template files such as those in the ``pmac`` support module use the
35+
following pattern:
36+
37+
.. code-block::
38+
39+
substitute "P=$(PMAC):, M=CS$(CS):M1, ADDR=1, DESC=CS Motor A"
40+
include "pmacDirectMotor.template"
41+
42+
This pattern is supported by msi but not by the EPICS dbLoadRecord command which
43+
does not recognise the ``substitute`` command.
44+
45+
46+
Consequences
47+
------------
48+
49+
An extra file ``ioc.subst`` is seen in the runtime directory. In reality this
50+
is easier to read than a full Database file. So can be useful for debugging.
51+
52+
Finally those developers who are unable to use ``ibek yaml`` for some reason can
53+
supply their own substitution file and ibek will expand it at runtime. This is
54+
much more compact that supplying a full Database file and important due to the
55+
1MB limit on K8S ConfigMaps.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
4. How to configure autosave for IOCs
2+
=====================================
3+
4+
Date: 2023-11-30
5+
6+
Status
7+
------
8+
9+
Accepted
10+
11+
Context
12+
-------
13+
14+
There is a choice of supplying the list of PVs to autosave by:
15+
16+
- adding info tags to the Database Templates
17+
- supplying a raw req file with list of PVs to autosave
18+
19+
Decision
20+
--------
21+
22+
We will go with req files for the following reasons:
23+
24+
- https://epics.anl.gov/tech-talk/2019/msg01600.php
25+
- adding info tags would require upstream changes to most support modules
26+
- default req files are already supplied in many support modules
27+
- req files are in common use and many facilities may already have their own
28+
req files for support modules.
29+
30+
We expect to autogenerate the list of PVs to autosave from the IOC's. We could
31+
therefore generate a Database override file which adds info tags. But it is
32+
simpler to just generate a req file.
33+
34+
The mechanism for using req files is that defaults will come from the support
35+
module or from the generic IOC if the support module does not supply a req file.
36+
37+
Then override files can exist at the beamline level and / or at the IOC
38+
instance level. These will simply take the form of a req file with the same
39+
name as the one it is overriding.
40+
41+
Consequences
42+
------------
43+
44+
Everything is nice and simple.
45+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2. Use Python for scripting inside and outside containers
2+
=========================================================
3+
4+
Date: 2022-11-30
5+
6+
Status
7+
------
8+
9+
Accepted
10+
11+
Context
12+
-------
13+
14+
Inside the container, we use the ``ibek`` tool for scripting. Outside we
15+
use ``ec`` from ``epics-containers-cli``.
16+
17+
Much of what these tools do is
18+
call command line tools like ``docker``, ``helm``, ``kubectl``, compilers,
19+
etc. This seems like a natural fit for bash scripts.
20+
21+
These features were originally implemented in bash but were converted to
22+
python for the following reasons:
23+
24+
- python provides for much richer command line arguments
25+
- it is also much easier to provide rich help
26+
- managing errors is vastly improved with exception handling
27+
- the unit testing framework allows for 85% coverage in continuous integration
28+
- complex string handling is a common requirement and is much easier in python
29+
- there is a clear versioning strategy and packages can be installed with pip,
30+
meaning that you can check which version of the script you are running and
31+
report bugs against a specific version
32+
- the code is much easier to read and maintain
33+
- because the packages can be pip installed they can be used in CI and inside
34+
multiple containers without having to copy the scripts around
35+
36+
Decision
37+
--------
38+
39+
We always prefer Python and keep bash scripts to a minimum
40+
41+
Consequences
42+
------------
43+
44+
Scripting is much easier to maintain and is more reliable.

0 commit comments

Comments
 (0)