nextstrain / augur

Pipeline components for real-time phylodynamic analysis
https://docs.nextstrain.org/projects/augur/
GNU Affero General Public License v3.0
268 stars 128 forks source link

Use identical help text for shared options #1597

Open victorlin opened 3 months ago

victorlin commented 3 months ago

_from https://github.com/nextstrain/augur/pull/1591#discussion_r1725712300_

Scope

Context

Help text for these arguments differ across subcommands. This is the --metadata-id-columns help text for augur merge:

  --metadata-id-columns COLUMN [COLUMN ...]
                        Possible metadata column names containing identifiers, considered in the order given. Columns will be considered for all metadata tables. Only one ID column will be inferred for each
                        table. (default: strain name)

for augur filter:

  --metadata-id-columns METADATA_ID_COLUMNS [METADATA_ID_COLUMNS ...]
                        names of possible metadata columns containing identifier information, ordered by priority. Only one ID column will be inferred. (default: ('strain', 'name'))

The augur filter version is used ~everywhere else. The augur merge version is an improvement of this from 0552f5f4cdac27a40eefe267f7db071f6cc357c4.

It has also propagated outside this repo to set_final_strain_name.py but I wouldn't worry about that as it's slated for removal.

Possible solutions

  1. Store help text in a shared variable.
  2. Use a shared parser config to add these options. Example:

    def add_input_metadata_options(parser):
        parser.add_argument("--metadata-id-columns", ...)
        parser.add_argument("--metadata-delimiters", ...)
        ...

    This might be more complicated to get right across all but helps reduce redundancy of not just the help text but also other parameters to add_argument including the option name.

For any solution, there should be a way to add an additional subcommand-specific snippet such as "Columns will be considered for all metadata tables" which is only applicable to augur merge.