Skip to content

Commit

Permalink
cli: fix and add make cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
David Wallace committed Mar 9, 2024
1 parent fcafab7 commit aadf5fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
15 changes: 2 additions & 13 deletions src/raman_fitting/interfaces/argparse_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():

parser.add_argument(
"-sIDs",
"--sample_IDs",
"--sample_ids",
nargs="+",
default=[],
help="Selection of names of SampleIDs from index to run over.",
Expand All @@ -52,10 +52,8 @@ def main():

parser.add_argument(
"--version",
# action=print(_version_text),
action="version",
version="%(prog)s {}".format(get_package_version()),
# const=_version_text,
help="Prints out the current version of the raman_fitting distribution, via importlib.metadata.version",
)

Expand All @@ -66,16 +64,7 @@ def main():
import raman_fitting as rf

extra_kwargs = {}
if args.run_mode == "normal":
pass
# _org_index = OrganizeRamanFiles()
# RL = RamanLoop(_org_index, run_mode ='normal')
elif args.run_mode.lower() == "debug":
pass
# IDEA Add a FAST TRACK for DEBUG
elif args.run_mode == "testing":
pass
elif args.run_mode == RunModes.EXAMPLES:
if args.run_mode == RunModes.EXAMPLES:
extra_kwargs.update(
{"fit_model_specific_names": ["2peaks", "3peaks", "4peaks"]}
)
Expand Down
33 changes: 20 additions & 13 deletions src/raman_fitting/interfaces/typer_cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import List, Optional
from typing_extensions import Annotated


from pathlib import Path
from enum import StrEnum, auto
from loguru import logger
from raman_fitting.config.path_settings import RunModes
from raman_fitting.delegating.main_delegator import MainDelegator
from raman_fitting.imports.files.file_indexer import initialize_index_from_source_files
from .utils import get_package_version

import typer
Expand All @@ -16,6 +15,7 @@
class MakeTypes(StrEnum):
INDEX = auto()
CONFIG = auto()
EXAMPLE = auto()


__version__ = "0.1.0"
Expand Down Expand Up @@ -64,24 +64,31 @@ def run(
],
run_mode: Annotated[RunModes, typer.Argument()] = RunModes.NORMAL,
):
if run_mode is None:
print("No make run mode passed")
raise typer.Exit()
kwargs = {"run_mode": run_mode}
if run_mode == RunModes.NORMAL:
pass
# _org_index = OrganizeRamanFiles()
# RL = RamanLoop(_org_index, run_mode ='normal')
elif run_mode.lower() == RunModes.DEBUG:
pass
# IDEA Add a FAST TRACK for DEBUG
elif run_mode == RunModes.EXAMPLES:
if run_mode == RunModes.EXAMPLES:
kwargs.update({"fit_model_specific_names": ["2peaks", "3peaks", "4peaks"]})
logger.info(f"Starting raman_fitting with CLI args:\n{run_mode}")
_main_run = MainDelegator(**kwargs)


@app.command()
def make(make_type: Annotated[MakeTypes, typer.Argument()]):
def make(
source_files: Annotated[List[Path], typer.Option()],
index_file: Annotated[List[Path], typer.Option()],
force_reindex: Annotated[bool, typer.Option("--force-reindex")] = False,
make_type: Annotated[MakeTypes, typer.Option()] = None,
):
if make_type is None:
print("No make type args passed")
raise typer.Exit()

if make_type == MakeTypes.INDEX:
pass # make index
initialize_index_from_source_files(
files=source_files, index_file=index_file, force_reindex=force_reindex
)

elif make_type == MakeTypes.CONFIG:
pass # make config
Expand Down

0 comments on commit aadf5fd

Please sign in to comment.