Skip to content

Commit 6f6d187

Browse files
committed
do not write to temp file, let snakemake handle things
1 parent 96cab8f commit 6f6d187

File tree

4 files changed

+6
-41
lines changed

4 files changed

+6
-41
lines changed

workflow/src/legenddataflow/scripts/tier/raw_blind.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"""
1212

1313
import argparse
14-
from pathlib import Path
1514

1615
import numexpr as ne
1716
import numpy as np
@@ -111,12 +110,6 @@ def build_tier_raw_blind() -> None:
111110
# gets events that should not be blinded
112111
tokeep = allind[np.logical_not(np.isin(allind, toblind))]
113112

114-
# make some temp file to write the output to before renaming it
115-
rng = np.random.default_rng()
116-
rand_num = f"{rng.integers(0,99999):05d}"
117-
temp_output = f"{args.output}.{rand_num}"
118-
Path(temp_output).parent.mkdir(parents=True, exist_ok=True)
119-
120113
for channel in all_channels:
121114
try:
122115
chnum = int(channel[2::])
@@ -126,7 +119,7 @@ def build_tier_raw_blind() -> None:
126119
store.write_object(
127120
chobj,
128121
channel,
129-
lh5_file=temp_output,
122+
lh5_file=args.output,
130123
wo_mode="w",
131124
**hdf_settings,
132125
)
@@ -139,7 +132,7 @@ def build_tier_raw_blind() -> None:
139132
chobj,
140133
group=channel,
141134
name="raw",
142-
lh5_file=temp_output,
135+
lh5_file=args.output,
143136
wo_mode="w",
144137
**hdf_settings,
145138
)
@@ -157,11 +150,7 @@ def build_tier_raw_blind() -> None:
157150
blinded_chobj,
158151
group=channel,
159152
name="raw",
160-
lh5_file=temp_output,
153+
lh5_file=args.output,
161154
wo_mode="w",
162155
**hdf_settings,
163156
)
164-
165-
# rename the temp file
166-
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
167-
Path(temp_output).rename(args.output)

workflow/src/legenddataflow/scripts/tier/raw_fcio.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from copy import deepcopy
33
from pathlib import Path
44

5-
import numpy as np
65
from daq2lh5 import build_raw
76
from dbetto import TextDB
87
from dbetto.catalog import Props
@@ -62,11 +61,4 @@ def build_tier_raw_fcio() -> None:
6261
if "muon_config" in channel_dict:
6362
raise NotImplementedError()
6463

65-
rng = np.random.default_rng()
66-
rand_num = f"{rng.integers(0,99999):05d}"
67-
temp_output = f"{args.output}.{rand_num}"
68-
69-
build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)
70-
71-
# rename the temp file
72-
Path(temp_output).rename(args.output)
64+
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)

workflow/src/legenddataflow/scripts/tier/raw_orca.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import logging
33
from pathlib import Path
44

5-
import numpy as np
65
from daq2lh5 import build_raw
76
from dbetto import TextDB
87
from dbetto.catalog import Props
@@ -100,11 +99,4 @@ def build_tier_raw_orca() -> None:
10099
)
101100
Props.add_to(all_config, muon_config)
102101

103-
rng = np.random.default_rng()
104-
rand_num = f"{rng.integers(0,99999):05d}"
105-
temp_output = f"{args.output}.{rand_num}"
106-
107-
build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)
108-
109-
# rename the temp file
110-
Path(temp_output).rename(args.output)
102+
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)

workflow/src/legenddataflow/scripts/tier/tcm.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
2-
from pathlib import Path
32

43
import lgdo.lh5 as lh5
5-
import numpy as np
64
from daq2lh5.orca import orca_flashcam
75
from dbetto import TextDB
86
from dbetto.catalog import Props
@@ -28,10 +26,6 @@ def build_tier_tcm() -> None:
2826

2927
settings = Props.read_from(config_dict["inputs"]["config"])
3028

31-
rng = np.random.default_rng()
32-
temp_output = f"{args.output}.{rng.integers(0, 99999):05d}"
33-
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
34-
3529
# get the list of channels by fcid
3630
ch_list = lh5.ls(args.input, "/ch*")
3731
fcid_channels = {}
@@ -46,10 +40,8 @@ def build_tier_tcm() -> None:
4640
for fcid, fcid_dict in fcid_channels.items():
4741
build_tcm(
4842
[(args.input, fcid_dict)],
49-
out_file=temp_output,
43+
out_file=args.output,
5044
out_name=f"hardware_tcm_{fcid}",
5145
wo_mode="o",
5246
**settings,
5347
)
54-
55-
Path(temp_output).rename(args.output)

0 commit comments

Comments
 (0)