Skip to content

Commit

Permalink
Impove code style
Browse files Browse the repository at this point in the history
  • Loading branch information
vmordan committed Sep 22, 2023
1 parent 57dc2c2 commit 96e946d
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=line-too-long

"""
Klever runner - creates a build base, launches Klever and converts results to CVV format.
Expand Down Expand Up @@ -78,6 +79,12 @@


class Runner(Component):
"""
Component for performing full Klever run, which consist of:
1. Creating of a build base;
2. Launching klever;
3. Converting results to CVV.
"""
def __init__(self, general_config: dict):

super().__init__(COMPONENT_RUNNER, general_config)
Expand Down Expand Up @@ -157,9 +164,9 @@ def __update_job_config(self, build_base_dir: str):
os.path.join(self.klever_deploy_dir, KLEVER_TASKS_DIR)
bridge_config[COMPONENT_BENCHMARK_LAUNCHER][TAG_TASKS_DIR] = \
os.path.join(dst_build_base_dir, BUILD_BASE_STORAGE_DIR)
with open(self.job_config, 'w') as f_jconfig:
with open(self.job_config, 'w', encoding='ascii') as f_jconfig:
json.dump(job_config, f_jconfig, sort_keys=True, indent=4)
with open(self.bridge_config, 'w') as f_bconfig:
with open(self.bridge_config, 'w', encoding='ascii') as f_bconfig:
json.dump(bridge_config, f_bconfig, sort_keys=True, indent=4)

def klever(self, build_base_dir: str) -> str:
Expand All @@ -183,13 +190,13 @@ def clear_klever_resources():
sys.exit("Cannot use python venv")
sys.path.insert(1, os.path.abspath(DEFAULT_VENV_PATH))
os.environ["PATH"] += os.pathsep + os.path.abspath(DEFAULT_VENV_PATH)
result = self.command_caller_with_output(cmd)
if not result:
launcher_output = self.command_caller_with_output(cmd)
if not launcher_output:
sys.exit("Cannot launch Klever")
m = re.search(r': (.+)', result)
if not m:
sys.exit(f"Cannot obtain new job id from output '{result}'")
new_job_id = m.group(1)
res = re.search(r': (.+)', launcher_output)
if not res:
sys.exit(f"Cannot obtain new job id from output '{launcher_output}'")
new_job_id = res.group(1)

# Wait until job is finished
time.sleep(BIG_WAIT_INTERVAL)
Expand Down Expand Up @@ -223,6 +230,9 @@ def bridge(self, new_job_id: str):
shutil.rmtree(os.path.join(self.jobs_dir, new_job_id))

def run(self):
"""
Performs full run.
"""
build_base_dir = self.builder()
new_job_id = self.klever(build_base_dir)
self.bridge(new_job_id)
Expand Down

0 comments on commit 96e946d

Please sign in to comment.