Skip to content

Commit

Permalink
Fix/python output to log window (#19)
Browse files Browse the repository at this point in the history
* Shows python outputs in log window

* Remove the copied line
  • Loading branch information
RHRolun authored Jun 21, 2024
1 parent eb3a8a9 commit 7bbf790
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions elyra/kfp/bootstrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
#
# Copyright 2018-2023 Elyra Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -482,10 +483,19 @@ def execute(self) -> None:
run_args = ["python3", python_script]
if self.parameter_pass_method == "env":
self.set_parameters_in_env()


logger.info("----------------------Python logs start----------------------")
with open(python_script_output, "w") as log_file:
subprocess.run(run_args, stdout=log_file, stderr=subprocess.STDOUT, check=True)

process = subprocess.Popen(run_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(process.stdout.readline, b''):
sys.stdout.write(line.decode())
log_file.write(line.decode())

process.stdout.close()
return_code = process.wait()
logger.info("----------------------Python logs ends----------------------")
if return_code:
raise subprocess.CalledProcessError(return_code, run_args)
duration = time.time() - t0
OpUtil.log_operation_info("python script execution completed", duration)

Expand Down

0 comments on commit 7bbf790

Please sign in to comment.