Skip to content

Commit

Permalink
Merge branch 'master' into fix_test_output
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjalling-dejong committed Jan 15, 2025
2 parents d81a029 + ae8ad5b commit fc84e2b
Show file tree
Hide file tree
Showing 24 changed files with 2,967 additions and 2,865 deletions.
93 changes: 0 additions & 93 deletions fm2prof/MaskOutputFile.py

This file was deleted.

2 changes: 1 addition & 1 deletion fm2prof/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "2.3.3"

from fm2prof.Fm2ProfRunner import Project
from fm2prof.fm2prof_runner import Project
46 changes: 26 additions & 20 deletions fm2prof/cli.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
"""CLI for Fm2Prof."""

from pathlib import Path
from typing import Optional

import typer
from tqdm import tqdm

from fm2prof import Project, __version__
from fm2prof.IniFile import IniFile
from fm2prof.ini_file import IniFile
from fm2prof.utils import Compare1D2D, VisualiseOutput

app = typer.Typer()


def _display_version(value: bool) -> None:
def _display_version(value: bool) -> None: # noqa:FBT001
if value:
typer.echo(f"Fm2Prof v{__version__}")
raise typer.Exit()
raise typer.Exit


@app.command("create")
def cli_create_new_project(projectname: str):
"""Creates a new project configuration from scratch, then exit"""
def cli_create_new_project(projectname: str) -> None:
"""Create a new project configuration from scratch, then exit."""
inifile = IniFile().print_configuration()
ini_path = f"{projectname}.ini"
ini_path = Path(f"{projectname}.ini")

with open(ini_path, "w") as f:
with ini_path.open("w") as f:
f.write(inifile)
typer.echo(f"{ini_path} written to file")
raise typer.Exit()
raise typer.Exit


@app.command("check")
def cli_check_project(projectname: str) -> None:
"""Load project, check filepaths, print errors then exit"""
"""Load project, check filepaths, print errors then exit."""
cf = Path(projectname).with_suffix(".ini")
project = Project(cf)
raise typer.Exit()
Project(cf)
raise typer.Exit


@app.command("compare")
def cli_compare_1d2d(
projectname: str, output_1d: str, output_2d: str, routes: str
) -> None:
"""BETA FUNCTIONALITY - compares 1D and 2D results"""

"""BETA FUNCTIONALITY - compares 1D and 2D results."""
cf = Path(projectname).with_suffix(".ini")
project = Project(cf)

Expand All @@ -58,17 +60,21 @@ def cli_compare_1d2d(
@app.command("run")
def cli_load_project(
projectname: str,
*,
overwrite: bool = typer.Option(
False, "--overwrite", "-o", help="Overwrite if output already exists"
False, # noqa: FBT003
"--overwrite",
"-o",
help="Overwrite if output already exists",
),
pp: bool = typer.Option(
False,
False, # noqa: FBT003
"--post-process",
"-p",
help="Post-process the results, generates figures",
),
) -> None:
"""Loads and runs a project"""
"""Load and run a project."""
cf = Path(projectname).with_suffix(".ini")
project = Project(cf)
project.run(overwrite=overwrite)
Expand All @@ -80,12 +86,12 @@ def cli_load_project(
for css in tqdm(vis.cross_sections):
vis.figure_cross_section(css)

raise typer.Exit()
raise typer.Exit


@app.callback()
def cli(
version: Optional[bool] = typer.Option(
version: Optional[bool] = typer.Option( # noqa: ARG001 FA100
None,
"--version",
"-v",
Expand All @@ -94,9 +100,9 @@ def cli(
is_eager=True,
),
) -> None:
"""Fm2Prof Command-line interface."""
typer.echo("Welcome to Fm2Prof")
return


def main():
def main(): # noqa: ANN201, D103
app()
Loading

0 comments on commit fc84e2b

Please sign in to comment.