Skip to content

Commit f48e48c

Browse files
committed
add get_batch_runs.py
1 parent 5e1f500 commit f48e48c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

micall/utils/analyze_kive_batches/analyze_kive_batches.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from .download import download
1414
from .make_stats_1 import make_stats_1
15+
from .get_batch_runs import get_batch_runs
1516

1617

1718
def dir_path(string: str) -> DirPath:
@@ -37,6 +38,12 @@ def cli_parser() -> argparse.ArgumentParser:
3738
all.add_argument("--properties", type=Path, required=True,
3839
help="Additional properties associated with particular images.")
3940

41+
get_batch_runs = mode_parsers.add_parser("get_batch_runs", help="The main entry to this script. Runs get_batch_runs other subentries.")
42+
get_batch_runs.add_argument("--batch", type=str, required=True,
43+
help="The name of the batch to download the runs info for.")
44+
get_batch_runs.add_argument("--target", type=dir_path, required=True,
45+
help="Target file where to put the runs info to.")
46+
4047
download = mode_parsers.add_parser("download")
4148
download.add_argument("--json-file", type=Path, required=True,
4249
help="The big json file with all the run infos.")
@@ -64,8 +71,10 @@ def parse_args(argv: Sequence[str]) -> argparse.Namespace:
6471

6572

6673
def main_typed(subcommand: str, args: argparse.Namespace) -> None:
67-
if args.subcommand == 'download':
68-
download(json_file=args.json_file, root=args.root)
74+
if args.subcommand == 'all':
75+
raise NotImplementedError()
76+
elif args.subcommand == 'get-batch-runs':
77+
get_batch_runs(batch=args.batch, target=args.target)
6978
elif args.subcommand == 'make-stats-1':
7079
make_stats_1(input=args.input, output=args.output)
7180
else:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
from typing import NewType
3+
4+
BatchName = NewType("BatchName", str)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
from typing import Iterable
3+
from pathlib import Path
4+
import subprocess
5+
import json
6+
7+
from .batch import BatchName
8+
9+
10+
def get_batch_runs(batch: BatchName, target: Path) -> None:
11+
with target.open("wt") as writer:
12+
output = subprocess.check_call(
13+
["kivecli", "findbatches", "--debug", "--json", "--name", str(batch)],
14+
stdout=writer,
15+
)

0 commit comments

Comments
 (0)