Command Line Interface
This module defines the main Typer application for the Any-to-Any Terminology Mapping (AATM) package. It provides commands for initializing the local project environment, launching the search user interface, and running terminology mapping tasks from either a config file or command-line options.
The CLI is responsible for orchestrating high-level workflows such as:
- setting up local helper directories and Git ignore rules
- validating vocabulary and embedding model inputs
- building local SQLite and vector databases for terminology mapping
- collecting interactive user input for setup choices
- loading and displaying mapping task configurations
- starting synchronous terminology mapping runs
- launching the Streamlit-based search interface
Commands:
-
init: Set up the local environment for OMOP vocabulary processing and vector database creation. -
search-ui: Launch the Streamlit-based search interface. -
map: Run a terminology mapping task from a configuration file or from explicit CLI arguments. -
amap: Placeholder for future asynchronous mapping support. -
serve: Serves a minimal FastAPI application with AATM's functionality.
Attributes:
| Name | Type | Description |
|---|---|---|
LOCAL_HELPER_PATH |
Path
|
Path to the local helper directory used by AATM to store generated artifacts and local resources. |
DEFAULT_VOCAB_DIR |
Path
|
Default directory containing OMOP vocabulary files. |
DEFAULT_EMBEDDING_MODEL |
str
|
Default embedding model used when building the local vector database. |
SUPPORTED_EMBEDDING_MODELS |
List[str]
|
List of embedding model identifiers supported by the CLI setup workflow. |
STANDARD_VOCABULARIES |
List[str]
|
List of supported standard vocabularies available for terminology mapping. |
DEFAULT_STANDARD_VOCABULARIES |
List[str]
|
Default subset of standard vocabularies selected during initialization. |
AATM_LOGO |
str
|
Multiline ASCII logo displayed in the CLI welcome screen. |
Examples:
Initialize the local environment with defaults:
$ aatm init
Initialize with a custom vocabulary directory:
$ aatm init --vocab-dir ./vocabularies
Run a mapping task from a config file:
$ aatm map --task-config-path config.yaml
Run a mapping task from explicit options:
$ aatm map --input-file concepts.csv --output-dir outputs \
--translator-id my_translator --retriever-id my_retriever \
--selector-id my_selector
Launch the search UI:
$ aatm search-ui
Note
This module is intended to serve as the main CLI entrypoint for the package. It coordinates user interaction and delegates implementation details to lower-level utilities and domain-specific components.
init(vocab_dir=None, embedding_model=None, standard_vocabs=None)
Initialize the local AATM environment.
This command prepares the local project environment required for
terminology mapping with OMOP vocabularies. It creates the helper
directory used by AATM, ensures .aatm is listed in .gitignore,
validates user inputs, builds the local SQLite vocabulary database,
prepares mapping datasets for the selected standard vocabularies,
and creates the local vector database used for retrieval.
When embedding_model or standard_vocabs are not provided, the
command interactively prompts the user to choose among the supported
options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vocab_dir
|
Annotated[str, Option(--vocab - dir, -vd, help='Path to the OMOP vocabularies directory.', show_default=False)]
|
Path to the directory containing the OMOP vocabulary files. If not provided, the default vocabulary directory is used. |
None
|
embedding_model
|
Annotated[Optional[str], Option(--embedding - model, -e, help='Name of the embedding model to use.', show_default=False)]
|
Name of the embedding model to use for building the local vector database. If not provided, the user is prompted to select one interactively. |
None
|
standard_vocabs
|
Annotated[Optional[List[str]], Option(--standard - vocabs, -sv, help=f'List of standard vocabularies to use. Available options: {STANDARD_VOCABULARIES}.')]
|
List of standard vocabularies to include in the mapping datasets. If not provided, the user is prompted to select one or more interactively. |
None
|
Raises:
| Type | Description |
|---|---|
Exit
|
If the vocabulary directory does not exist, if the embedding model is not supported, or if any provided standard vocabulary is invalid. |
Examples:
Initialize using the default vocabulary directory:
$ aatm init
Initialize with a custom vocabulary directory:
$ aatm init --vocab-dir ./vocabularies
Initialize with an explicit embedding model:
$ aatm init --embedding-model qwen3-4B
Initialize with specific standard vocabularies:
$ aatm init --standard-vocabs LOINC --standard-vocabs SNOMED
Source code in aatm\main.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
search_ui()
Launch the Streamlit-based search interface.
This command locates the search_ui.py application in the same
package directory as this module and starts it using the current
Python interpreter with Streamlit.
Raises:
| Type | Description |
|---|---|
BadParameter
|
If the Streamlit application file cannot be found. |
CalledProcessError
|
If the Streamlit process exits with a non-zero status code. |
Source code in aatm\main.py
map(task_config_path=None, input_file=None, output_dir=None, translator_id=None, retriever_id=None, selector_id=None, reranker_id=None, batch_size=None, rate_limit=None, limit_to=None)
Run a terminology mapping task.
This command executes a terminology mapping workflow using either a
configuration file or parameters provided directly through the command
line. When a task configuration file is given, it is loaded and used to
build the mapping task. Otherwise, a TerminologyMappingTask is created
from the individual command options.
The command prints the loaded task configuration, instantiates a
TerminologyMapper from it, and starts the mapping process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_config_path
|
Optional[str]
|
Path to a task configuration file. When provided, the mapping task is loaded from this file. |
None
|
input_file
|
Optional[str]
|
Path to the input file containing source concepts to be mapped. Used when no task configuration file is provided. |
None
|
output_dir
|
Optional[str]
|
Path to the output directory where mapping results will be written. Used when no task configuration file is provided. |
None
|
translator_id
|
Optional[str]
|
Identifier of the translator to use in the mapping pipeline. |
None
|
retriever_id
|
Optional[str]
|
Identifier of the retriever to use in the mapping pipeline. |
None
|
selector_id
|
Optional[str]
|
Identifier of the selector to use in the mapping pipeline. |
None
|
reranker_id
|
Optional[str]
|
Identifier of the reranker to use in the mapping pipeline. |
None
|
batch_size
|
Optional[int]
|
Batch size to use during the mapping process. |
None
|
rate_limit
|
Optional[int]
|
Rate limit to apply when processing source concepts. |
None
|
limit_to
|
Optional[int]
|
Maximum number of source concepts to map. Useful for testing and debugging. |
None
|
Raises:
| Type | Description |
|---|---|
Exit
|
If |
Examples:
Run a mapping task from a config file:
$ aatm map --task-config-path config.yaml
Run a mapping task from explicit options:
$ aatm map --input-file concepts.csv --output-dir outputs \
--translator-id my_translator --retriever-id my_retriever \
--selector-id my_selector
Run a small test mapping job:
$ aatm map --input-file concepts.csv --output-dir outputs \
--limit-to 20
Source code in aatm\main.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
serve(host='0.0.0.0', port='8000', mode='dev', reload=False, workers=None, rate_limit=None, batch_size=100)
Serve a FastAPI application exposing AATM functionality.
This command validates the serving configuration, persists the API settings to disk, and launches the FastAPI application using the appropriate runtime mode. It supports development and production execution, optional hot reload, worker configuration, and request-processing parameters such as rate limits and batch size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
Annotated[Optional[str], Option(--host, -h, help=Host)]
|
Host interface on which the FastAPI application will listen. |
'0.0.0.0'
|
port
|
Annotated[str, Option(--port, -p, help=Port)]
|
Port on which the FastAPI application will listen. |
'8000'
|
mode
|
Annotated[Literal['prod', 'dev'], Option(--mode, -m, help="Serving mode: 'prod' or 'dev'")]
|
Serving mode. Use |
'dev'
|
reload
|
Annotated[bool | None, Option(--reload, help="Enables hot reload. Compatible with 'dev' mode only.")]
|
Whether to enable hot reload. This option is only effective in development mode. |
False
|
workers
|
Annotated[Optional[str], Option(--workers, -w, help='Number of workers')]
|
Number of worker processes to use. This option is only effective in production mode. |
None
|
rate_limit
|
Annotated[Optional[int], Option(--rate - limit, -r, help='Maximum number of documents allowed per minute')]
|
Maximum number of documents allowed per minute. |
None
|
batch_size
|
Annotated[int, Option(--batch - size, -b, help='Batch size')]
|
Batch size used by the API processing pipeline. |
100
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
BadParameter
|
If the FastAPI application entrypoint cannot be found. |
CalledProcessError
|
If the FastAPI process exits with a non-zero status. |
Source code in aatm\main.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |