You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are multiple completion checks (individual fetch scripts, shared.check_completion_file_exists). Not all of them support --force.
Description
I expect a single shared function with appropriate arguments can satisfy all completion checks
probably two arguments:
args - argparse Namespace
files - dictionary: {file_path: minimum lines}
Shouldn't check without --enable-save
No need to parse file with csv to count lines
--force needs to be supported by scripts that use it.
parser.add_argument(
"--force",
action="store_true",
help="Generate new output files even if they already exist",
)
All scripts that support --force should have same argument stanza and arguments should be ordered normally
args.quarter may need to be added to scripts that use it
Recommend a minimum of two PRs:
for scripts that use shared.check_completion_file_exists
scripts that have their own completion check
Additional context
I worked on this briefly before giving up due to scope of changes, different priorites, etc. The following function should be a good starting place:
defcheck_for_completion(args, files):
""" Check if files exist and have at least the specified number of lines (if specified). Can be overrideend on the command line with the --force option. If fiels exist and have minimum number of specified lines, the script exits early by raising a QuantifyingException with an exit status code of 0. """ifnotargs.enable_saveorargs.force:
returnall_files_exist=Trueall_files_complete=Trueforpath, minimum_linesinfiles.items():
ifnotos.path.exists(path):
all_files_exist=Falseprint(f"{path} does not exist")
elifminimum_linesisnotNoneandminimum_lines>0:
withopen(path, "r", encoding="utf-8") asfile_obj:
reader=csv.DictReader(file_obj, dialect="unix")
iflen(list(reader)) <minimum_lines:
all_files_complete=Falseprint(f"{path} has too few lines")
ifall_files_existandall_files_complete:
raiseQuantifyingException(
"All output files are already present and appear complete for"f" {args.quarter}",
0,
)
Implementation
I would be interested in implementing this feature.
Hi @TimidRobot, I’d like to work on this issue. I’ve looked through the requirements and would like to start with the shared completion check changes. Please let me know if that approach works.
Activity
iamshravanijadhav commentedon Oct 8, 2026
Hi @TimidRobot, I’d like to work on this issue. I’ve looked through the requirements and would like to start with the shared completion check changes. Please let me know if that approach works.