Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Log Entry to Config File Bug #406

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions casanovo/casanovo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
import tqdm
from lightning.pytorch import seed_everything

from . import __version__
from . import utils
from .denovo import ModelRunner
from . import __version__, utils
from .config import Config
from .denovo import ModelRunner

logger = logging.getLogger("casanovo")
click.rich_click.USE_MARKDOWN = True
Expand Down Expand Up @@ -337,21 +336,46 @@ def version() -> None:


@main.command()
@click.option(
bittremieux marked this conversation as resolved.
Show resolved Hide resolved
"-d",
"--output_dir",
help="The destination directory for log and config file.",
type=click.Path(dir_okay=True),
required=False,
)
@click.option(
"-o",
"--output",
help="The output configuration file.",
default="casanovo.yaml",
"--output_root",
help="The root name for log and config file.",
type=click.Path(dir_okay=False),
required=False,
)
def configure(output: Path) -> None:
@click.option(
"-f",
"--force_overwrite",
help="Whether to overwrite output files.",
is_flag=True,
show_default=True,
default=False,
)
def configure(
output_dir: str, output_root: str, force_overwrite: bool
) -> None:
"""Generate a Casanovo configuration file to customize.

The casanovo configuration file is in the YAML format.
"""
Config.copy_default(str(output))
setup_logging(output, "info")
logger.info(f"Wrote {output}\n")
output_path, _ = _setup_output(
output_dir, output_root, force_overwrite, "info"
)
config_fname = output_root if output_root is not None else "casanovo"
config_fname = Path(config_fname).with_suffix(".yaml")
if not force_overwrite:
utils.check_dir_file_exists(output_path, str(config_fname))

config_path = str(output_path / config_fname)
Config.copy_default(config_path)
logger.info(f"Wrote {config_path}\n")
bittremieux marked this conversation as resolved.
Show resolved Hide resolved


def setup_logging(
Expand Down
Loading
Loading