Skip to content

Commit e81899a

Browse files
authored
Merge pull request #1273 from cmu-delphi/validation_gating_v2
Implement second pass at validation gating
2 parents 00b038c + 329829d commit e81899a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

_delphi_utils_python/delphi_utils/runner.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, Callable, Dict, Optional
55
from .archive import ArchiveDiffer, archiver_from_params
66
from .logger import get_structured_logger
7-
from .utils import read_params
7+
from .utils import read_params, transfer_files
88
from .validator.validate import Validator
99
from .validator.run import validator_from_params
1010

@@ -44,8 +44,11 @@ def run_indicator_pipeline(indicator_fn: Callable[[Params], None],
4444
validation_report.log(get_structured_logger(
4545
name = indicator_fn.__module__,
4646
filename=params["common"].get("log_filename", None)))
47-
if archiver and (not validator or validation_report.success()):
48-
archiver.run()
47+
if (not validator or validation_report.success()):
48+
if archiver:
49+
archiver.run()
50+
if "delivery" in params:
51+
transfer_files()
4952

5053

5154
if __name__ == "__main__":

_delphi_utils_python/delphi_utils/utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Read parameter files containing configuration information."""
22
# -*- coding: utf-8 -*-
33
from json import load,dump
4-
from os.path import exists
5-
from shutil import copyfile
4+
from shutil import copyfile, move
5+
import os
66
import sys
77

88
def read_params():
@@ -11,7 +11,7 @@ def read_params():
1111
If the file does not exist, it copies the file 'params.json.template' to
1212
'params.json' and then reads the file.
1313
"""
14-
if not exists("params.json"):
14+
if not os.path.exists("params.json"):
1515
copyfile("params.json.template", "params.json")
1616

1717
with open("params.json", "r") as json_file:
@@ -87,3 +87,12 @@ def params_run():
8787
with open("params.json", "w") as f:
8888
dump(params, f, sort_keys=True, indent=2)
8989
print(f"Updated {n} items")
90+
91+
def transfer_files():
92+
"""Transfer files to prepare for acquisition."""
93+
params = read_params()
94+
export_dir = params["common"].get("export_dir", None)
95+
delivery_dir = params["delivery"].get("delivery_dir", None)
96+
files_to_export = os.listdir(export_dir)
97+
for file_name in files_to_export:
98+
move(os.path.join(export_dir, file_name), delivery_dir)

0 commit comments

Comments
 (0)