Skip to content

bring importers into line, and improve documentation - #465

Merged
grahamegrieve merged 2 commits into
mainfrom
2026-12-gg-v2-import-fixes
Dec 3, 2026
Merged

grahamegrieve merged 2 commits into
mainfrom
2026-12-gg-v2-import-fixes

Conversation

@grahamegrieve

Copy link
Copy Markdown
Contributor

@jmandel: notes about documentation

  • Overwriting deletes the old file first. I first wrote that a failed import leaves the old file in place, but TerminologyBuilder deletes an existing destination as soon as the import starts. The docs now say so, and suggest importing to a new name if the old file is in use.
  • They're still not interactive like the classic importers. --source and --dest are still required, and nothing is remembered between runs.
  • loinc-v2 has no --languages. Add LOINC language selection and fix import CLI options #445's language selection only applies to the classic LOINC importer.

@jmandel jmandel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I ran the branch locally: -v/--version, the earlier names, the missing-version error, the refusal of an existing destination with no terminal (file left untouched), and -y all behave as documented, and the overwrite note in the readme matches what TerminologyBuilder does.

One thing that does not work yet: --verbose never prints the stack trace.

$ tx-import loinc-v2 import -s ./empty -d ./new.db -v 2.83 --verbose
✗ loinc-v2 import failed: required LOINC file missing: ./empty/LoincTable/Loinc.csv

Same output with tx-import --verbose loinc-v2 import .... I think the program-level --verbose in tx-import.js takes the flag, so the import command's o.verbose stays undefined. The unit test passes because it calls the action with { verbose: true } directly. Reading the flag with optsWithGlobals() in importAction (or dropping the per-command --verbose and reading the program's) should fix it. Not blocking.

The Security Scan failure is the tar advisories, not this change.

@jmandel

jmandel commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up on --verbose: I confirmed the cause and tested a fix on this branch.

With commander 14, the program-level --verbose takes the flag wherever it appears, so the import action sees o.verbose === undefined while cmd.optsWithGlobals().verbose is true. This two-line change makes the stack print for both tx-import loinc-v2 import ... --verbose and tx-import --verbose loinc-v2 import ... (checked with loinc-v2 and snomed-v2); without the flag the output is unchanged, and the 7 tests in sqlite-v2-cli-options.test.js still pass.

--- a/tx/importers/sqlite-v2/cli-options.js
+++ b/tx/importers/sqlite-v2/cli-options.js
@@ function importAction(module, fn) {
-  return async (o) => {
+  return async (o, cmd) => {
     try {
       await fn(o);
     } catch (error) {
       module.logError(`${module.getName()} import failed: ${error.message}`);
-      if (o.verbose) {
+      if (o.verbose || (cmd && cmd.optsWithGlobals().verbose)) {
         console.error(error.stack);
       }

@grahamegrieve
grahamegrieve merged commit a57bd37 into main Dec 3, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants