Skip to content

Commit d9e0de0

Browse files
committed
Change behavior for delivery_dir = None, adding clarity
Added truth table to README for clarity Made delivery_dir throw an assertion if it is None (should not happen since this scenario would only happen if dry-run is False, in which case both export_dir and delivery_dir have to be specified.
1 parent 89dbdee commit d9e0de0

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

_delphi_utils_python/delphi_utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ def delete_move_files():
104104
1. Delete files in export-dir if delivery-dir is specified and is different
105105
from export_dir (aka only delete files produced by the most recent run)
106106
2. If validation-failures-dir is specified, move failed files there instead
107+
If dry-run tag is True, then this function should not (and currently does not) get called
107108
"""
108109
params = read_params()
109110
export_dir = params["common"].get("export_dir", None)
110111
delivery_dir = params["delivery"].get("delivery_dir", None)
111-
if delivery_dir is None:
112-
return
113112
validation_failure_dir = params["validation"]["common"].get("validation_failure_dir", None)
114-
115113
# Create validation_failure_dir if it doesn't exist
116114
if (validation_failure_dir is not None) and (not os.path.exists(validation_failure_dir)):
117115
os.mkdir(validation_failure_dir)
118116
# Double-checking that export-dir is not delivery-dir
119-
assert(export_dir is not None and export_dir != delivery_dir)
117+
# Throw assertion error if delivery_dir or export_dir is unspecified
118+
assert(delivery_dir is not None and export_dir is not None)
119+
assert(export_dir != delivery_dir)
120120
files_to_delete = os.listdir(export_dir)
121121
for file_name in files_to_delete:
122122
if file_name.endswith(".csv") or file_name.endswith(".CSV"):

_delphi_utils_python/delphi_utils/validator/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ deactivate
4343
rm -r env
4444
```
4545

46+
### Using the runner
47+
48+
The validator can also be called using the runner, which performs the entire pipeline:
49+
50+
* Calling the indicator's `run` module
51+
* Running the validator on newly obtained CSV files, if validator is specified
52+
* If validation is unsuccessful, remove or transfer current files in the run
53+
* Archive files if archiver is specified and there are no validation failures
54+
* Transfer files to delivery directory if specified in params
55+
56+
The following truth table describes behavior of the third bullet point:
57+
58+
| case | dry_run | validation failure | export dir | delivery dir | v failure dir | action |
59+
| - | - | - | - | - | - | - |
60+
| 1 | true | never | * | * | * | no effect |
61+
| 2 | false | no | * | * | * | no effect |
62+
| 3 | false | yes | X | X | * | throw assertion exception |
63+
| 4 | false | yes | X | None | * | throw assertion exception |
64+
| 5 | false | yes | X | Y != X | None | delete CSV from X |
65+
| 6 | false | yes | X | Y != X | Z | move CSV from X to Z |
66+
4667
### Customization
4768

4869
All of the user-changable parameters are stored in the `validation` field of the indicator's `params.json` file. If `params.json` does not already include a `validation` field, please copy that provided in this module's `params.json.template`.

0 commit comments

Comments
 (0)