-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRLCInferenceRunner.py
More file actions
42 lines (39 loc) · 1.5 KB
/
RLCInferenceRunner.py
File metadata and controls
42 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import subprocess
import shlex
import logging
import Constants
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S"
)
class RLCInferenceRunner:
@staticmethod
def run_rlc_inference(source_project_name, source_project_path, results_folder, is_rerun=False):
logging.info(f"Running RLC inference on {source_project_name}.")
logging.info(f"Rerun: {is_rerun}")
with open(
f"{source_project_path}/{Constants.RLC_INFERENCE_LOG_FILENAME}",
"w" if not is_rerun else "a",
) as file:
process = subprocess.Popen(
shlex.split(
f"{Constants.RLC_INFERENCE_SCRIPT_PATH} {source_project_path} {Constants.CF_ROOT}"
),
stdout=file,
stderr=subprocess.STDOUT,
)
try:
process.communicate(timeout=Constants.TIMEOUT)
logging.info(
f"Running RLC inference finished successfully on {source_project_name}.")
except subprocess.TimeoutExpired:
logging.error(
f"Command timed out after {Constants.TIMEOUT} seconds while running RLC inference on {source_project_name}."
)
process.kill()
process.wait()
os.system("sudo killall -9 javac")
except Exception as e:
logging.error(f"Error occurred: {e}")