Replies: 7 comments 4 replies
-
My point about the choice of YAML: YAML is a very complex data format. That means two things:
So, what I'm simply proposing is to use the simplest file format we can get away with. Something like TOML for example: But: I'm not saying the choice of YAML is necessarily bad, but I want to stress that such a choice brings with it potential problems as well. So be aware of them before making the choice and investing the time. Regarding keeping the YAML schema in line with changes in the framework: |
Beta Was this translation helpful? Give feedback.
-
While taking the brave path of moving on with these changes, there are few considerations not to be forgotten: The RML (through TRestMetadata methods) implements the following capabilities:
Those are some features I remember by heart. I don't say that all should be implemented in a future implementation, but if we invested our time to write those at some point it was for a reason. = Drawbacks
But more important, we should remember that Another problem is that some inherited classes use directly xml library functions. At some point I tried to push to have all xml code encapsulated inside Probably XML is not the best, but from a personal point of view it still readable, and moving to other formats would require to change the present user habits to a new scheme. I cannot adventure the consequences, from my point of view is a considerable work load, and we may end up on the scenario that is a question of taste and simply getting used to something that was already stablished. Most problems using XML have probably a solution, and we have full control on that. From my personal user experience is clear that I am comfortable with XML, if others cannot live with, then, we must find a way to use both formats at the same time. Then at some point, when everyone would be using the new scheme, and it is clear everything is working, do the transition. It might be a long way to get there. There was a major change in RML sometime ago, and from experience, it took us some time to adapt. @nkx111 may have other insights. ===== There are other features one could dream of, i.e. automatic reading of metadata members as follows:
and could be read as follows, or with YALM or TOML format.
|
Beta Was this translation helpful? Give feedback.
-
Currently my solution would be to include this dependency directly on the cmake script, meaning it will clone and build the yaml-cpp library on the first build of REST. This allows the project to set a fixed version of the library and avoids the user having to install it. It takes very little time to build this library by the way, much less time than for example the google testing framework for c++. If required we could update it by changing a single line in the cmake and it would be transparent to users, hopefully its not required to update it frequently, if at all.
I guess people should restrain from using all these freatures then as they are not supported by the framework, not sure if you raise this as a security concern. I don't think RML files are or will be very simple, they are practically a programming language already, but without all the good things about one such as linting. At this point perhaps we should be considering using python scripts as the configuration files (half joking). Edit: I guess you mean something like this.
I like your suggestion about toml, it was also in my list of possible alternatives to XML. To be honest I chose yaml because it seems very complete and many tools I use already use this format, such as the CI tools (GitLab's and GitHub's Actions) or my home's Home Assistant installation. Taking a look into one of the TOML libraries, such as https://github.com/marzer/tomlplusplus I can see its pretty similar to https://github.com/jbeder/yaml-cpp. However I don't see much about validation through schemas, only toml-lang/toml#792. I also found about https://github.com/crdoconnor/strictyaml which is supposed to solve these problems, there are many interesting points in the README. It has some interesting comments about toml too. The biggest drawback seems that there are no parsers in other languages except python. Personally I disagree with implementing things such as logical expressions, loops etc in the configuration file parser. It would be interesting to find another project which faced this problem and see which solution it chose. |
Beta Was this translation helpful? Give feedback.
-
We need for loops to create |
Beta Was this translation helpful? Give feedback.
-
Wow, I didn't know issues could be moved to discussions! |
Beta Was this translation helpful? Give feedback.
-
The simplist way to satisfy every one is to add a class to convert yaml to rml. I am not familiar with yaml, but from the first view I find it similar with xml in the *hierarchy. Then it is straight forward to do the conversion. For TOML it seems too simple to populate. I just have a try manually: <TRestManager name="CoBoDataAnalysis" title="Example" verboseLevel="info" >
<TRestRun name="SJTU_Proto" >
<parameter name="runNumber" value="auto"/>//change this value to "auto" to enable database
<parameter name="outputFileName" value="RUN[RunNumber]_[Time]_[LastProcess].root" />
<addMetadata name="PandaReadout_MxM" file="meta.root"/>
<TRestDetectorGas name="Xenon-TMA 1Pct 10-10E3Vcm" pressure="10atm" electricField="1000V/cm" file="server"/>
</TRestRun>
<TRestProcessRunner name="Processor" verboseLevel="info">
<parameter name="eventsToProcess" value="0" />
<parameter name="threadNumber" value="2"/>
<parameter name="outputEventStorage" value="on"/>
<addProcess type="TRestRawMultiCoBoAsAdToSignalProcess" name="virtualDAQ" value="ON"/>
<addProcess type="TRestRawSignalAnalysisProcess" name="sAna" value="ON">
<observable name="BaseLineSigmaMean" value="ON" />
<observable name="ThresholdIntegral" value="ON" />
</addProcess>
<addProcess type="TRestRawReadoutAnalysisProcess" name="rA" value="ON">
<parameter name="observable" value="all"/>
</addProcess>
</TRestProcessRunner>
<addTask command="Processor->RunProcess()" value="ON"/>
<globals>
<searchPath value="$ENV{REST_INPUTDATA}/definitions/"/>
<parameter name="verboseLevel" value="essential" />
<parameter name="mainDataPath" value="" />
<parameter name="pointThreshold" value="3" />
<parameter name="pointsOverThreshold" value="3" />
</globals>
</TRestManager> TRestRun:
name: SJTU_Proto
runNumber: auto
outputFileName: RUN[RunNumber]_[Time]_[LastProcess].root
addMetadata:
- name: PandaReadout_MxM
- file: meta.root
TRestDetectorGas:
name: Xenon-TMA 1Pct 10-10E3Vcm
pressure: 10atm
electricField: 1000V/cm
file: server
TRestProcessRunner:
name: Processor
verboseLevel: info
eventsToProcess: 0
threadNumber: 2
outputEventStorage: on
addProcess:
- type: TRestRawMultiCoBoAsAdToSignalProcess
name: virtualDAQ
value: on
- type: TRestRawSignalAnalysisProcess
name: sAna
value: on
observable:
- name: BaseLineSigmaMean
value: on
- name: ThresholdIntegral
value: on
- type: TRestRawReadoutAnalysisProcess
name: rA
value: on
observable: all
addTask:
- command: Processor->RunProcess()
value: on
globals:
searchPath: $ENV{REST_INPUTDATA}/definitions/
verboseLevel: essential
mainDataPath: ""
pointThreshold: 3
pointsOverThreshold: 3
@lobis is that correct in syntax? It seems the conversion is logically clear, which makes the coding easier. Note that the rml "parameter" is generalized(i.e., equivalent to the attribute of parent element), and are all set as yaml's config sections, without appearance of the "parameter" keyword. |
Beta Was this translation helpful? Give feedback.
-
Well, I suggest we just keep the current implementation of "for loop reading from rml". What to change is not origin rml: <readoutModule name="module" size="((nChannels+1)*pitch-1*pitch/2,(nChannels+1)*pitch-pitch/2-pitch/4)" tolerance="1.e-4" >
// Y-strips
<for variable="nCh" from="1" to="nChannels-2" step="1" >
<readoutChannel id="${nCh}" >
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}" origin="((1+${nCh})*pitch,pitch/4+${nPix}*pitch)" size="(pixelSize,pixelSize)" rotation="45" />
</for>
<addPixel id="nChannels" origin="((1+${nCh})*pitch-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch,pitch/2)" rotation="0" />
</readoutChannel>
</for>
</readoutChannel>
</readoutModule>
without for loop: <readoutModule name="module" size="((nChannels+1)*pitch-1*pitch/2,(nChannels+1)*pitch-pitch/2-pitch/4)" tolerance="1.e-4" >
// Y-strips
<readoutChannelArray repeat="nChannels-1">
<id start="1" step="1" />
<x start="2*pitch" step="pitch" />
<y value="pitch/4"/>
<readoutPixelArray repeat="nChannels-1" size="(pixelSize,pixelSize)" rotation="45">
<id start="0" step="1" />
<x value="0" /> //relative to readout channel coordinate
<y start="0" step="pitch"/>
</readoutPixelArray >
<readoutPixel id="nChannels" origin="(-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch,pitch/2)" rotation="0" />
</readoutChannelArray>
</readoutModule> yaml: readoutModule:
name: module
size: ((nChannels+1)*pitch-1*pitch/2,(nChannels+1)*pitch-pitch/2-pitch/4)
tolerance: 1.e-4
readoutChannelArray:
repeat: nChannels-1
id:
start: 1
step: 1
x:
start: 2*pitch
step: pitch
y: pitch/4
readoutPixelArray:
repeat: nChannels-1
id:
start: 1
step: 1
x: 0
y:
start: 0
step: pitch
size: (pixelSize,pixelSize)
rotation: 45
readoutPixel:
id: nChannels
origin: (-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)
size: (pitch,pitch/2)
rotation: 0
|
Beta Was this translation helpful? Give feedback.
-
I think YAML is an overall better format for our use case compared to XML, the only read advantage of XML being that we are used to it.
We can make use of a schema to help the user correctly write / modify an RML file. (this can also be done with XML if anyone dares...).
a PoC is available at https://github.com/lobis/radiation-transport/tree/main/libraries/Simulation/Config, as you can see the amount of code needed is much smaller than what we need to
TRestMetadata
.There are two ways to do this:
Extend (rewrite) our
TRestMetadata
classes to support both XML and YAML files. I think this would add too much complexity to our already complex code.Write a parallel
TRestMetadata
(TRestConfiguration
?) in an experimental namespace and work to support all current configurations, translate all RML files in the framework and once it is stablished deprecate the XML files.I like the second option the most but it is up for discussion.
Beta Was this translation helpful? Give feedback.
All reactions