Comments (8)
Regarding the multiple keys - the functionality to avoid this is already there, as you can see in other examples. This file was overlooked, I'll fix it in the next commit.
The integer values also work, you can use integer instead of string for sndBufSize, etc.
from fairroot.
fair enough.
what I am reaching at would be some kind of an official schema for the device(s) configuration, or really, anything under the "fairMQOptions"
key.
i.e. something like that, in Go:
type Config struct {
Options Options `json:"fairMQOptions"`
}
type Options struct {
Devices []Device `json:"devices"`
}
type Device struct {
ID string `json:"id"`
Channels []Channel `json:"channels"`
}
type Channel struct {
Name string `json:"name"`
Sockets []Socket `json:"sockets"`
}
type Socket struct {
Type string `json:"type"`
Method string `json:"method"`
Address string `json:"address"`
SendBufSize int `json:"sndBufSize"`
RecvBufSize int `json:"rcvBufSize"`
RateLogging int `json:"rateLogging"`
}
this would help document what is accepted by FairMQ
as a configuration file.
I can produce a little Go program that tries to load JSON
files from the FairRoot repo and detect those which do not abide to the above schema.
(EDIT: updated the json:"sockets"
struct-tag of type Channel
)
from fairroot.
ah!
and what about the "key"
and "id"
keys in: "examples/MQ/2-sampler-processor-sink/ex2-sampler-processor-sink.json"
?
have they different meaning? different usage?
thanks.
-s
from fairroot.
The "id"
corresponds to the device ID, which should be unique across the topology. The "key"
allows multiple devices to share same configuration. In the second example multiple processors are started with the same config.
The Go snippet above it looks good, except socket can also be multiple. The program you mention would indeed be helpful.
The idea was to allow singular keys (device, channel, etc.) for cases where there is only one entry, to avoid having to create an array.
There is one more new feature that hasn't been used a lot yet - if no socket is specified, common settings defined under channel will be applied to the socket(s) of this channel. You can see it in the json of the third example.
from fairroot.
the command at:
https://github.com/sbinet-alice/fer/blob/master/cmd/fer-validate-json/main.go
gives something like this:
$> fer-validate-json -v ./example/cmd/testdata/ex2-sampler-processor-sink.json
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "channel" keyword (device="sampler1")
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "socket" keyword (device="sampler1.data1")
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "socket" keyword (device="processor.data1")
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "socket" keyword (device="processor.data2")
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "channel" keyword (device="sink1")
2016/11/09 10:44:36 ./example/cmd/testdata/ex2-sampler-processor-sink.json: use of "socket" keyword (device="sink1.data2")
2016/11/09 10:44:36 [./example/cmd/testdata/ex2-sampler-processor-sink.json] validation FAILED
it doesn't detect int
as string
, yet.
(it wasn't clear whether this was something you wanted to enforce)
from fairroot.
The singular words are valid if they are not repeated (e.g. "socket" for single object or "sockets" for an array).
Both int and string work for the numerical values from the perspective of the FairMQParser. Maybe put it as a warning?
from fairroot.
I've updated all the non-standard JSON files. Now everything should be valid JSON. I also added a readme in fairmq/options to describe the details of the JSON configuration.
from fairroot.
ok.
the command fer-json-validate
now produces:
$> fer-json-validate -v ./toto.json
fer-json-validate: [./toto.json] validation FAILED:
ref={fairMQOptions {devices [{id sampler1 channel {name data1 socket {type push method bind address tcp://*:5555 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}channel {name data1 socket {type push method bind address tcp://*:5555 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}}{key processor channels [{name data1 socket {type pull method connect address tcp://localhost:5555 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}{name data2 socket {type push method connect address tcp://localhost:5556 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}]}{id sink1 channel {name data2 socket {type pull method bind address tcp://*:5556 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}}]}}
chk={fairMQOptions {devices [{id sampler1 channel {name data1 socket {type push method bind address tcp://*:5555 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}}{key processor channels [{name data1 socket {type pull method connect address tcp://localhost:5555 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}{name data2 socket {type push method connect address tcp://localhost:5556 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}]}{id sink1 channel {name data2 socket {type pull method bind address tcp://*:5556 sndBufSize 1000 rcvBufSize 1000 rateLogging 0}}}]}}
when toto.json
has multiple "channel"
keys.
less pretty, but still useful.
I have also produced a json
reformatter a-la clang-format
(or, rather, like go fmt
from where clang-format
draws its inspiration).
it's there:
https://github.com/sbinet-alice/fer/blob/master/cmd/fer-json-fmt/main.go
automatically applying this kind of reformatter would reduce the git-diff-noise...
wrt the int
VS string
issue, I think it would be better to be stricter to begin with (with maybe be more lenient if need be).
i.e. only accept int
for the buffer sizes and rates.
from fairroot.
Related Issues (20)
- Sink closed before generator finalizes HOT 3
- Adopt latest FairMQ APIs
- Update CI matrix HOT 1
- `flatc: warning: field names should be lowercase snake_case`
- cling fatal error: module file not found HOT 2
- Fixing Geoloader leak probably introduced new bugs HOT 4
- CI: Refine jenkins `clang-tidy` analyzer
- `warning: 'virtual bool FairTimeStamp::operator<(const FairTimeStamp*) const' was hidden [-Woverloaded-virtual=]`
- RPATH resolution sometimes broken when linking against `FairRoot::FastSim` HOT 7
- Further cleanup ascii geometry related classes
- Make install tree FHS compliant
- Document `clang-format` version used by our CI
- Can we deprecate FairGeoInterface::{createGeometry,createAll,deleteSet}
- Error message for empty container in FairRunTimeDB HOT 3
- Catch2 Test failed when using the compiler from a custom location HOT 5
- FairRootConfig.cmake should find relevant dependencies HOT 16
- Move CMake find modules to FairCMakeModules
- Export more `FairRoot_*_DIR` variables in the new CMake package
- Re-evaluate support of `find_dependency`-style CMake package mode
- Dedicated CI tests that run examples and project templates against `n >= 2` latest FairRoot releases
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fairroot.