diff options
author | Frederick Muriuki Muriithi | 2024-12-03 16:05:05 -0600 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-12-03 16:05:05 -0600 |
commit | 0165fa73fb092960c472c4baab16c164f9f55ccf (patch) | |
tree | f8a65eac1a26f09a80d407ad838fab1c18ee1792 /scripts/rqtl2/phenotypes_qc.py | |
parent | 1ed9a130988681941669295329fda88fe075f40d (diff) | |
download | gn-uploader-0165fa73fb092960c472c4baab16c164f9f55ccf.tar.gz |
Update file metadata using a mapping
Update the metadata using a mapping rather than updating a field at a
time to make it easier to ensure everything is updated in one go.
Diffstat (limited to 'scripts/rqtl2/phenotypes_qc.py')
-rw-r--r-- | scripts/rqtl2/phenotypes_qc.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/rqtl2/phenotypes_qc.py b/scripts/rqtl2/phenotypes_qc.py index 7a52d09..f539cad 100644 --- a/scripts/rqtl2/phenotypes_qc.py +++ b/scripts/rqtl2/phenotypes_qc.py @@ -213,12 +213,21 @@ def qc_phenocovar_file( _line["description"], "The description is not provided!")),) + rconn.hset(file_fqkey(fqkey, "metadata", filepath), + mapping={ + "status": "checking", + "linecount": _lc+1, + "total-errors": len(_errs) + }) return _errs, _lc+1 _errors, _linecount = reduce(collect_errors, _csvfile, (_errors, 1)) - rconn.hset( - f"{fqkey}:metadata", - mapping={"linecount": _linecount, "total-errors": len(_errors)}) + rconn.hset(file_fqkey(fqkey, "metadata", filepath), + mapping={ + "status": "completed", + "linecount": _linecount, + "total-errors": len(_errors) + }) return {filepath.name: {"errors": _errors, "linecount": _linecount}} @@ -316,14 +325,22 @@ def qc_pheno_file(# pylint: disable=[too-many-arguments] value) _errs = _errs + ((save_error(_err),) if bool(_err) else tuple()) - rconn.hset(f"{fqkey}:metadata", "linecount", _lc+1) - rconn.hset(f"{fqkey}:metadata", "total-errors", len(_errs)) + rconn.hset(file_fqkey(fqkey, "metadata", filepath), + mapping={ + "status": "checking", + "linecount": _lc+1, + "total-errors": len(_errs) + }) return _errs, _lc+1 - logger.debug(f"[{filepath.name}] Collecting errors") _errors, _linecount = reduce(collect_errors, _csvfile, (_errors, 1)) - logger.debug(f"[{filepath.name}] Finished collecting errors. Returning results …") - return {filepath.name: {"errors": _errors, "linecount": linecount}} + rconn.hset(file_fqkey(fqkey, "metadata", filepath), + mapping={ + "status": "completed", + "linecount": _linecount, + "total-errors": len(_errors) + }) + return {filepath.name: {"errors": _errors, "linecount": _linecount}} def phenotype_names(filepath: Path, |