Skip to content

Commit a6d11a6

Browse files
authored
Merge pull request #14 from Sheshuk/v0.9
Updated for snap_base v2.0 syntax
2 parents e15c75b + 0345c55 commit a6d11a6

File tree

7 files changed

+57
-95
lines changed

7 files changed

+57
-95
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: [3.9]
19+
python-version: ["3.10", "3.11", "3.12"]
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -27,8 +27,7 @@ jobs:
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
30-
python -m pip install flake8 pytest hypothesis pytest-asyncio
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
python -m pip install ".[test]"
3231
- name: Lint with flake8
3332
run: |
3433
# stop the build if there are Python syntax errors or undefined names

README.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,6 @@ This package contains plugins for [SNAP](https://github.com/Sheshuk/snap-base) f
1212
python -m pip install snap-combine
1313
```
1414

15-
## Plugins
16-
17-
This package contains plugins which can be used in new snap pipeline configurations.
18-
19-
#### Monitoring: `snap.util.monitor`
20-
21-
* `tqdm_ticker`: a provides [tqdm](https://github.com/tqdm/tqdm)-based ticker, which counts the data flow and data rate through current step.
22-
23-
#### Generating client data: `snap.client.fake`
24-
25-
* `sample_ts`: Generates the neutrino interaction timestamps, using the given rate. Can simulate the supernova signal at the given time.
26-
27-
#### Processing client data: `snap.client`
28-
29-
* `sigcalc.ShapeAnalysis`: calculate supernova significance using shape analysis
30-
* `setId`: change the datablock ID
31-
32-
#### Combination: `snap.combine`:
33-
34-
* `Buffer`: accumulate the data to synchrnize before combining
35-
* `methods.Fisher`: combine data using Fisher's combination method
36-
* `methods.Stouffer`: combine data using Stouffer's combination method
37-
38-
#### Triggering: `snap.util.threshold`
39-
40-
* Threshold: select and forward only portions of data with significance above given threshold
41-
42-
#### Misc: `snap.util`
43-
44-
* `dump_to_file`: Dump data to given file
45-
4615
## Example
4716

4817
Example configurations provided the `examples` dir use these steps to
@@ -51,17 +20,17 @@ Example configurations provided the `examples` dir use these steps to
5120

5221
On client side run
5322
```
54-
snap client_sender.yml -n node1
23+
DETECTOR="det_name_1" snap_run client_sender.yml
5524
```
5625

57-
Optionally in another session:
26+
Optionally in another terminal session:
5827
```
59-
snap client_sender.yml -n node2
28+
DETECTOR="det_name_2" snap_run client_sender.yml
6029
```
6130

6231
In another session (combination side):
6332
```
64-
snap combine.yml
33+
snap_run combine.yml
6534
```
6635

6736
You should see the monitoring ticks for all nodes.

examples/client_sender.yml

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
signal_shapes:
2-
- &signal1
3-
- [-2.0, 0, 10]
4-
- [0, 10, 0]
1+
config:
2+
- &detector_id "${DETECTOR}"
3+
- &seconds_to_SN 30
4+
- &bg_level 1
5+
- signal_shapes:
6+
- &signal1
7+
- [-2.0, 0, 10]
8+
- [0, 10, 0]
59

6-
- &signal2
7-
- [0, 20]
8-
- [20, 0]
10+
- &signal2
11+
- [0, 20]
12+
- [20, 0]
913

1014

11-
node:
12-
generate:
13-
source:
14-
.client.fake.sample_ts: {B: 1, S: *signal1, tSN: 10}
15-
steps:
16-
- .client.fake.realtime
17-
- .tqdm.counter: {desc: "Data"}
18-
- .client.sigcalc.CountAna: { B: 2, time_window: [0,5], dt: 0.1, tChunk_min: 1}
19-
- .tqdm.counter: {desc: "DataBlocks"}
20-
to: [send]
21-
send:
22-
steps:
23-
- .client.setId: {id: "client1"}
24-
- .io.zmq.send: {address: "ipc://ipc_combiner"}
25-
15+
node: !Node
16+
- !chain
17+
- !from .client.fake.sample_ts: {B: *bg_level, S: *signal1, tSN: *seconds_to_SN}
18+
- .client.fake.realtime: {}
19+
- .tqdm.counter: {desc: "Data"}
20+
- .client.sigcalc.CountAna: { B: *bg_level, time_window: [0,5], dt: 0.1, tChunk_min: 1}
21+
- .tqdm.counter: {desc: "DataBlocks"}
22+
- !to Sender
2623

27-
node2:
28-
detonate:
29-
source:
30-
.client.fake.detonator: {delay: 15}
31-
steps:
32-
- .timing.every: {seconds: 60}
33-
- .output.dump: {prefix: "detonator"}
34-
to: generate
24+
- !chain:Sender
25+
- .client.setId: {id: *detector_id}
26+
- .io.zmq.send: {address: "ipc://ipc_combiner"}
27+
3528

36-
generate:
37-
steps:
38-
- .client.fake.Generator: {B: 1, S: *signal1}
39-
- .client.fake.realtime
40-
- .tqdm.counter: {desc: "Data"}
41-
#to: process
29+
node2: !Node
30+
- !chain:TimeBomb
31+
- !from .client.fake.detonator: {delay: 15}
32+
- .timing.every: {seconds: 60}
33+
- .output.dump: {prefix: "TimeBomb:"}
34+
- !to Generate
35+
36+
- !chain:Generate
37+
- .client.fake.Generator: {B: 1, S: *signal1}
38+
- .client.fake.realtime
39+
- .tqdm.counter: {desc: "Data"}
4240

examples/combine.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
node:
2-
receive:
3-
source:
4-
.io.zmq.recv: {address: "ipc://ipc_combiner"}
5-
steps:
6-
- .tqdm.counter: {desc: "Data received"}
7-
- .output.dump_to_file: {fname: "data_received.dat"}
1+
node: !Node
2+
- !chain
3+
- !from .io.zmq.recv: {address: "ipc://ipc_combiner"}
4+
- .tqdm.counter: {desc: "Data received"}
5+
- .output.dump_to_file: {fname: "data_received.dat"}
6+
- !to Combine
87

9-
- .combine.Buffer: {delay: 5, timeout: 600}
10-
- .combine.methods.Fisher
11-
- .tqdm.counter: {desc: "Data combined"}
12-
- .output.dump_to_file: {fname: "data_combined.dat"}
13-
14-
- .process.Threshold: {thr: 5}
15-
- .tqdm.counter: {desc: "Triggers"}
16-
- .output.dump_to_file: {fname: "data_triggered.dat"}
8+
- !chain:Combine
9+
- .combine.Buffer: {delay: 5, timeout: 600}
10+
- .combine.methods.Fisher
11+
- .tqdm.counter: {desc: "Data combined"}
12+
- .output.dump_to_file: {fname: "data_combined.dat"}
1713

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
packages=['snap.elements.combine','snap.elements.process','snap.elements.client'],
1414
py_modules=['snap.datablock'],
1515
install_requires=['numpy >= 1.19',
16-
'snap-base[io] >=1.3.3',
17-
'sn_stat==0.3.3',
16+
'snap-base >=2.0.3',
17+
'sn_stat>=0.3.4',
1818
],
19-
extras_require={'doc':['sphinx', 'sphinx-rtd-theme']},
19+
extras_require={'doc':['sphinx', 'sphinx-rtd-theme'],
20+
'test':['flake8','pytest','hypothesis','pytest-asyncio']
21+
},
2022
python_requires='>=3.7'
2123
)
2224

snap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version_combine__="0.8"
1+
__version_combine__="0.9.0"

test/test_databuffer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ def test_new_clients(ts):
1818
assert buf.clients == {d1.id: d1}
1919
buf.put(d2)
2020
assert buf.clients == {d.id: d for d in [d1,d2]}
21-
with pytest.raises(ValueError):
22-
buf.put(d2)
2321

2422
@given(ts=times)
2523
def test_append_data(ts):

0 commit comments

Comments
 (0)