diff options
| author | pi coding agent <pi@localhost> | 2026-10-22 21:31:52 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-10-22 16:35:12 -0500 |
| commit | 2bc7e2c194dbb3f22c6e44202abc9ea2846d3504 (patch) | |
| tree | d835c396863819e97d5375894621fbec4857f67e | |
| parent | d9b18832317be76657bf271724be89ed44833d21 (diff) | |
| download | gn-uploader-2bc7e2c194dbb3f22c6e44202abc9ea2846d3504.tar.gz | |
docs: capture Stage 01 file resolution and comment-description decisions
Update the genotypes-upload WIP docs for today's decisions and progress: - design: record the decided comment -> description behaviour (strip '#', trim whitespace, one line each, editable textbox, feeds the R/qtl2 control file), with description storage still undecided; - implementation: note the shared uploader.files.resolve_uploaded_file, the genotypes wiring, and the phenotypes bug fixes; correct the stale claim that the Stage 01 form inputs are missing; - tasks: mark uploaded-file resolution done, correct the form-inputs task, record the comment-description format, and add the deferred monadic-refactor technical-debt item.
| -rw-r--r-- | WIP/geno-uploads-design-notes.md | 29 | ||||
| -rw-r--r-- | WIP/geno-uploads-implementation-notes.md | 51 | ||||
| -rw-r--r-- | WIP/geno-uploads-tasks-and-todos.md | 27 |
3 files changed, 80 insertions, 27 deletions
diff --git a/WIP/geno-uploads-design-notes.md b/WIP/geno-uploads-design-notes.md index f8108cc..48cb95f 100644 --- a/WIP/geno-uploads-design-notes.md +++ b/WIP/geno-uploads-design-notes.md @@ -30,8 +30,10 @@ design source of truth: - Collect the list of markers. - Identify which fields are the markers/chromosome (and cM/Mb) fields. - Collect the set of unique genotype symbols. - - Collect comment lines into a human-readable description (see open - questions; currently *not* implemented). + - Collect comment lines into a human-readable description: strip the leading + `#`, trim surrounding whitespace from each line, and preserve each line + separately (see “Comment → description” below; currently *not* + implemented). 2. **Stage 02 — Establish basic study information** - What is the study design? @@ -76,6 +78,20 @@ file whose earlier stage failed or is incomplete. (How this gating is realised in the background-job system is an open design question — see the background-jobs design notes in `gn-libs/WIP/background-jobs-design-notes.md`.) +### Comment → description (decided) + +Comment lines become a user-editable description that will later go into the +R/qtl2 bundle's control file (and possibly the database). For each comment +line: + +- strip the leading `#` character; +- strip leading/trailing whitespace; +- keep the lines separate (one line each) and present them to the user in a + textbox as-is; +- let the user edit the final description before it is used. + +Open UI question: how to visually demarcate consecutive lines in the textbox. + ## Stage 01 data contract (target) The stats collector should produce enough information for the later stages: @@ -88,17 +104,16 @@ The stats collector should produce enough information for the later stages: - `markers_list`; - parse errors encountered (column mismatches, etc.); - **a free-text description built from comment lines** (desired; not yet - implemented). + implemented). Each comment line is cleaned (leading `#` and surrounding + whitespace removed) and kept as its own line. The current implementation of Stage 01 is described in the implementation notes. ## Open design questions -- **Comment → description format.** Which comment lines become the - description? How are multiple comment lines joined (newlines? paragraphs?) - and where is the result stored/presented? Should inline/trailing comments - count? (Tracked as a task.) +- **Description storage.** The description feeds the R/qtl2 control file; it is + undecided whether it is also persisted to the database. - **Encoding representation.** How do we represent a user-confirmed encoding so that it is stable for QC and conversion (symbol → label/missing marker)? - **Validation vs. confirmation.** Where exactly is the boundary between "what diff --git a/WIP/geno-uploads-implementation-notes.md b/WIP/geno-uploads-implementation-notes.md index ec60573..e4baf3c 100644 --- a/WIP/geno-uploads-implementation-notes.md +++ b/WIP/geno-uploads-implementation-notes.md @@ -13,9 +13,10 @@ the concerns/deviations discovered while building it. It supersedes the - **Stage 01 engine: implemented and tested.** The statistics collector exists at `uploader/scripts/genotypes/preprocess_csv_collect_info.py`. -- **Stage 01 wiring into the upload flow: not done.** The upload view builds a - placeholder job description but neither runs the collector nor starts a - background job. +- **Stage 01 wiring into the upload flow: in progress.** The uploaded file is + resolved for both the resumable and direct upload paths and handed to the + collector stub; mapping the form metadata to the collector config, running + the collector and persisting its results are still pending. - **Stages 02–07: not implemented** (still design/TODO comment blocks in `uploader/genotypes/views.py`). @@ -87,10 +88,30 @@ comment.char, na_strings, transposed `tests/genotypes/` (pytest): accumulation, single-threaded stats, merge semantics, and single- vs multi-processed equivalence across chunk sizes, -including transposed files and files with errors. **21 passing.** +including transposed files and files with errors. + +`tests/uploader/test_files.py`: the generic uploaded-file resolver (direct and +resumable uploads, hashed/unhashed, error cases). Together with +`tests/genotypes/` this is **31 passing**. ## Integration concerns (upload flow) +### Uploaded-file resolution (done) + +`uploader.files.resolve_uploaded_file(form, files, upload_dir, fieldname, +hashed=True)` resolves either a chunked/resumable upload (the JSON blob +returned by the resumable upload endpoint) or a direct multipart upload, +returning `Right((path, original_name))` or `Left(message)`. It lives in +`uploader.files` because it is generic — the only per-caller input is the field +name — and it is the consumer counterpart of the resumable-upload contract that +package owns. + +- `add_genotype_records` uses it with the `genotypes-records-file` field. +- `process_phenotypes_individual_files` was refactored onto it, fixing: + directly-uploaded optional files being skipped, a `BadRequestKeyError` for + missing direct files, unhandled resumable-data errors, and a fragile + double-prefixed path. + ### The view does not run the collector In `uploader/genotypes/views.py`: @@ -104,16 +125,18 @@ In `uploader/genotypes/views.py`: ### Config-key mismatch to bridge The view's `csv_meta` uses `sep`, `comment.char`, `na.strings`, while the -collector expects `separator`, `comment.char`, `na_strings` plus -`markers`, `chromosome`, `cm`, `mb`, `transposed`. An adapter (and the missing -markers/chromosome/cM/Mb choices) is needed when wiring Stage 01. - -### Missing Stage 01 inputs in the form - -The upload form currently supplies the file, separator, comment char and NA -strings, but not the markers/chromosome/cM/Mb field names or the -transposed-ness that the collector needs. These must be added to the Stage 01 -UI/flow. +collector expects `separator`, `comment.char`, `na_strings` plus `markers`, +`chromosome`, `cm`, `mb`, `transposed`. An adapter is needed (`comment.char` +already matches). + +### Stage 01 form inputs exist; the view must read them + +The upload form +(`uploader/templates/genotypes/add-genotypes-records-csv.html`) already +provides `markers_field`, `chromosomes_field`, `centimorgans_field`, +`megabases_field`, `transposed`, plus the shared `file-separator`, +`file-comment-char` and `file-na` inputs. The work is to read and map them to +the collector's config (see above), not to add new inputs. ### Comment description missing diff --git a/WIP/geno-uploads-tasks-and-todos.md b/WIP/geno-uploads-tasks-and-todos.md index 45075d8..cf52c44 100644 --- a/WIP/geno-uploads-tasks-and-todos.md +++ b/WIP/geno-uploads-tasks-and-todos.md @@ -19,15 +19,22 @@ implementation notes. - ✅ Unit tests for accumulation, merge and equivalence (`tests/genotypes/`). - ✅ Fix threshold / header-skip / `blank_lines` defects. - ⬜ **Collect comment lines into a multiline description string** (currently - only counted, text discarded). Decide the format (line joining, which - comments count) — see design open questions. + only counted, text discarded). Format decided: strip the leading `#`, trim + surrounding whitespace, keep one line per comment, present in an editable + textbox for the user; the result feeds the R/qtl2 control file (see design + notes). Still to do: implement it and settle the textbox styling. +- 💭 Decide whether the final description is also persisted to the database, or + only written into the R/qtl2 control file. - 🚧 **Wire the collector into the upload view** (`add_genotype_records`): + - ✅ Resolve the uploaded file for both the resumable and direct upload paths, + via `uploader.files.resolve_uploaded_file`. + - ⬜ Read the form's metadata (`markers_field`, `chromosomes_field`, + `centimorgans_field`, `megabases_field`, `transposed`, `file-separator`, + `file-comment-char`, `file-na`) and map it to the collector's config keys + (`markers`, `chromosome`, `cm`, `mb`, `transposed`, `separator`, + `comment.char`, `na_strings`). The inputs already exist in the form. - ⬜ Run the collector (or schedule it) instead of returning the stub `_collect_geno_csv_stats_` dict. - - ⬜ Adapt the view's `csv_meta` keys (`sep`/`na.strings`) to the collector's - config keys (`separator`/`na_strings`). - - ⬜ Add the missing Stage 01 form inputs: markers field, chromosome field, - cM/Mb fields, transposed flag. - ⬜ Persist/return the resulting `FileStats` for the next stage. ## Stage 02 — Study design & genotype encoding @@ -53,6 +60,14 @@ implementation notes. - ⬜ Stage 06: generate `.geno` (and other artefacts). - ⬜ Stage 07: pre-compute mapping(s). +## Refactoring / technical debt + +- 💭 **Deferred:** once `add_genotype_records` grows to cover the later stages, + refactor it into a monadic pipeline rather than a series of guard clauses — + resolve the uploaded file, then chain each stage with `.then(...)`, ending + with `.either(_handle_error_path, _handle_success_path)`. Deferred until the + view is large enough for the split to pay off. + ## Background jobs - 💭 Decide whether genotype upload stays "one script == one job" or becomes |
