Diff of /chexbert/run_chexbert.py [000000] .. [4abb48]

Switch to unified view

a b/chexbert/run_chexbert.py
1
import subprocess
2
from local_config import CHEXBERT_ENV_PATH, CHEXBERT_PATH
3
4
5
def run_chexbert_labeler(reports_path, output_path):
6
    # Path to a Python interpreter that runs any Python script
7
    # under the virtualenv /path/to/virtualenv/
8
    python_bin = CHEXBERT_ENV_PATH
9
10
    # Path to the script that must run under the virtualenv
11
    script_file = "label"
12
13
    print("Starting to extract Chexbert labels...")
14
15
    process = subprocess.run([python_bin, "-m", script_file, "-c", "checkpoint/chexbert.pth", "-d", reports_path, "-o", output_path],
16
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=CHEXBERT_PATH)
17
18
    # Print the output
19
    print(process.stdout.decode())
20
21
    # Print the errors if there are any
22
    if process.stderr:
23
        print("Errors:")
24
        print(process.stderr.decode())
25
26
    print("Finished extracting Chexbert labels.")