• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stfc / janus-core / 12317947314

13 Dec 2024 02:57PM UTC coverage: 44.571% (-50.6%) from 95.218%
12317947314

Pull #334

github

web-flow
Merge 17e42dc36 into 6d3310fb7
Pull Request #334: Test mac on self-hosted runner

234 of 525 relevant lines covered (44.57%)

1.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.29
/janus_core/cli/preprocess.py
1
# noqa: I002, FA102
2
"""Set up MLIP preprocessing commandline interface."""
3

4
# Issues with future annotations and typer
5
# c.f. https://github.com/maxb2/typer-config/issues/295
6
# from __future__ import annotations
7

8
from pathlib import Path
4✔
9
from typing import Annotated
4✔
10

11
from typer import Option, Typer
4✔
12

13
app = Typer()
4✔
14

15

16
@app.command()
4✔
17
def preprocess(
4✔
18
    mlip_config: Annotated[
19
        Path, Option(help="Configuration file to pass to MLIP CLI.")
20
    ],
21
    log: Annotated[Path, Option(help="Path to save logs to.")] = Path(
22
        "preprocess-log.yml"
23
    ),
24
    tracker: Annotated[
25
        bool, Option(help="Whether to save carbon emissions of calculation")
26
    ] = True,
27
    summary: Annotated[
28
        Path,
29
        Option(
30
            help=(
31
                "Path to save summary of inputs, start/end time, and carbon emissions."
32
            )
33
        ),
34
    ] = Path("preprocess-summary.yml"),
35
):
36
    """
37
    Convert training data to hdf5 by passing a configuration file to the MLIP's CLI.
38

39
    Parameters
40
    ----------
41
    mlip_config : Path
42
        Configuration file to pass to MLIP CLI.
43
    log : Optional[Path]
44
        Path to write logs to. Default is Path("preprocess-log.yml").
45
    tracker : bool
46
        Whether to save carbon emissions of calculation in log file and summary.
47
        Default is True.
48
    summary : Optional[Path]
49
        Path to save summary of inputs, start/end time, and carbon emissions. Default
50
        is Path("preprocess-summary.yml").
51
    """
52
    from janus_core.cli.utils import carbon_summary, end_summary, start_summary
×
53
    from janus_core.training.preprocess import preprocess as run_preprocess
×
54

55
    inputs = {"mlip_config": str(mlip_config)}
×
56

57
    # Save summary information before preprocessing begins
58
    start_summary(command="preprocess", summary=summary, inputs=inputs)
×
59

60
    log_kwargs = {"filemode": "w"}
×
61
    if log:
×
62
        log_kwargs["filename"] = log
×
63

64
    # Run preprocessing
65
    run_preprocess(
×
66
        mlip_config, attach_logger=True, log_kwargs=log_kwargs, track_carbon=tracker
67
    )
68

69
    # Save carbon summary
70
    if tracker:
×
71
        carbon_summary(summary=summary, log=log)
×
72

73
    # Save time after preprocessing has finished
74
    end_summary(summary)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc