Passed
Branch dev-release (a75e90)
by Konstantinos
02:13
created

report_kl.main()   A

Complexity

Conditions 4

Size

Total Lines 26
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 21
nop 2
dl 0
loc 26
rs 9.376
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
import os
4
import click
5
from .reporting import PsiReporter
6
7
8
import logging
9
logger = logging.getLogger(__name__)
10
11
12
@click.command()
13
@click.argument('dataset')
14
@click.option('-m', '--model')
15
def main(dataset, model):
16
    collections_dir = os.getenv('COLLECTIONS_DIR')
17
    if not collections_dir:
18
        raise RuntimeError(
19
            "Please set the COLLECTIONS_DIR environment variable with the path to a directory containing collections/datasets")
20
    reporter = PsiReporter()
21
    dataset_path = os.path.join(collections_dir, dataset)
22
    reporter.dataset = dataset_path
23
24
    print("Classes: [{}]".format(', '.join("'{}'".format(x) for x in reporter.dataset.class_names)))
25
26
    models_dir = os.path.join(dataset_path, 'models')
27
    if not os.path.isdir(models_dir):
28
        print("No models found")
29
        sys.exit(0)
30
    if model:
31
        phi_file_names = [model]
32
    else:
33
        phi_file_names = os.listdir(models_dir)
34
35
    # b = pr.pformat(glob('{}/*.phi'.format(models_dir)), topics_set='domain', show_class_names=True)
36
    b = reporter.pformat(phi_file_names, topics_set='domain', show_model_name=True, show_class_names=True)
37
    print(b)
38
39
40
if __name__ == '__main__':
41
    main()