Skip to content

Commit c59639b

Browse files
committedMar 15, 2025·
implement config option to disable filedb generation
1 parent d9608da commit c59639b

File tree

2 files changed

+41
-36
lines changed

2 files changed

+41
-36
lines changed
 

‎dataflow-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# legend_metadata_version: main
22
allow_none_par: false
3+
build_file_dbs: true
34

45
paths:
56
sandbox_path: $_/sandbox

‎workflow/src/legenddataflow/scripts/complete_run.py

+40-36
Original file line numberDiff line numberDiff line change
@@ -244,57 +244,61 @@ def build_file_dbs(gen_tier_path, outdir):
244244
print(f"INFO: ...took {dt}")
245245

246246

247-
file_db_config = {}
248-
249-
if (
250-
os.getenv("PRODENV") is not None
251-
and os.getenv("PRODENV") in snakemake.params.filedb_path
252-
):
253-
prodenv = as_ro(os.getenv("PRODENV"))
247+
def fformat(tier):
248+
abs_path = patterns.get_pattern_tier(
249+
snakemake.params.setup, tier, check_in_cycle=False
250+
)
251+
return str(abs_path).replace(ut.get_tier_path(snakemake.params.setup, tier), "")
254252

255-
def tdirs(tier):
256-
return as_ro(ut.get_tier_path(snakemake.params.setup, tier)).replace(
257-
prodenv, ""
258-
)
259253

260-
file_db_config["data_dir"] = "$PRODENV"
254+
if snakemake.params.setup.get("build_file_dbs", True):
255+
file_db_config = {}
261256

262-
else:
263-
print("WARNING: $PRODENV not set, the FileDB will not be relocatable")
257+
if (
258+
os.getenv("PRODENV") is not None
259+
and os.getenv("PRODENV") in snakemake.params.filedb_path
260+
):
261+
prodenv = as_ro(os.getenv("PRODENV"))
264262

265-
def tdirs(tier):
266-
return as_ro(ut.get_tier_path(snakemake.params.setup, tier))
263+
def tdirs(tier):
264+
return as_ro(ut.get_tier_path(snakemake.params.setup, tier)).replace(
265+
prodenv, ""
266+
)
267267

268-
file_db_config["data_dir"] = "/"
268+
file_db_config["data_dir"] = "$PRODENV"
269269

270+
else:
271+
print("WARNING: $PRODENV not set, the FileDB will not be relocatable")
270272

271-
file_db_config["tier_dirs"] = {
272-
k: tdirs(k) for k in snakemake.params.setup["table_format"]
273-
}
273+
def tdirs(tier):
274+
return as_ro(ut.get_tier_path(snakemake.params.setup, tier))
274275

276+
file_db_config["data_dir"] = "/"
275277

276-
def fformat(tier):
277-
abs_path = patterns.get_pattern_tier(
278-
snakemake.params.setup, tier, check_in_cycle=False
279-
)
280-
return str(abs_path).replace(ut.get_tier_path(snakemake.params.setup, tier), "")
281-
278+
file_db_config["tier_dirs"] = {
279+
k: tdirs(k) for k in snakemake.params.setup["table_format"]
280+
}
282281

283-
file_db_config |= {
284-
"file_format": {k: fformat(k) for k in snakemake.params.setup["table_format"]},
285-
"table_format": snakemake.params.setup["table_format"],
286-
}
282+
file_db_config |= {
283+
"file_format": {k: fformat(k) for k in snakemake.params.setup["table_format"]},
284+
"table_format": snakemake.params.setup["table_format"],
285+
}
287286

288287
if snakemake.wildcards.tier != "daq":
289-
print(f"INFO: ...building FileDBs with {snakemake.threads} threads")
288+
if snakemake.params.setup.get("build_file_dbs", True):
289+
print(f"INFO: ...building FileDBs with {snakemake.threads} threads")
290290

291-
Path(snakemake.params.filedb_path).mkdir(parents=True, exist_ok=True)
291+
Path(snakemake.params.filedb_path).mkdir(parents=True, exist_ok=True)
292292

293-
with (Path(snakemake.params.filedb_path) / "file_db_config.json").open("w") as f:
294-
json.dump(file_db_config, f, indent=2)
293+
with (Path(snakemake.params.filedb_path) / "file_db_config.json").open(
294+
"w"
295+
) as f:
296+
json.dump(file_db_config, f, indent=2)
295297

296-
build_file_dbs(ut.tier_path(snakemake.params.setup), snakemake.params.filedb_path)
297-
(Path(snakemake.params.filedb_path) / "file_db_config.json").unlink()
298+
build_file_dbs(
299+
ut.tier_path(snakemake.params.setup), snakemake.params.filedb_path
300+
)
301+
(Path(snakemake.params.filedb_path) / "file_db_config.json").unlink()
298302

299303
build_valid_keys(
300304
Path(ut.tmp_par_path(snakemake.params.setup)) / "*_db.json",

0 commit comments

Comments
 (0)
Please sign in to comment.