Daemon support for conda and poetry

This commit is contained in:
allegroai 2020-01-26 15:05:20 +02:00
parent 97f446d523
commit a57a5b151c
2 changed files with 9 additions and 4 deletions

View File

@ -59,7 +59,7 @@ from trains_agent.helper.base import (
is_conda, is_conda,
named_temporary_file, named_temporary_file,
ExecutionInfo, ExecutionInfo,
HOCONEncoder, error, get_python_path) HOCONEncoder, error, get_python_path, is_linux_platform)
from trains_agent.helper.console import ensure_text from trains_agent.helper.console import ensure_text
from trains_agent.helper.package.base import PackageManager from trains_agent.helper.package.base import PackageManager
from trains_agent.helper.package.conda_api import CondaAPI from trains_agent.helper.package.conda_api import CondaAPI
@ -1161,11 +1161,12 @@ class Worker(ServiceCommandSection):
exit_code = -1 exit_code = -1
try: try:
if disable_monitoring: if disable_monitoring:
use_execv = is_linux_platform() and not isinstance(self.package_api, (PoetryAPI, CondaAPI))
try: try:
sys.stdout.flush() sys.stdout.flush()
sys.stderr.flush() sys.stderr.flush()
os.chdir(script_dir) os.chdir(script_dir)
if not is_windows_platform() and not isinstance(self.package_api, PoetryAPI): if use_execv:
os.execv(command.argv[0].as_posix(), tuple([command.argv[0].as_posix()])+command.argv[1:]) os.execv(command.argv[0].as_posix(), tuple([command.argv[0].as_posix()])+command.argv[1:])
else: else:
exit_code = command.check_call(cwd=script_dir) exit_code = command.check_call(cwd=script_dir)
@ -1173,10 +1174,10 @@ class Worker(ServiceCommandSection):
except subprocess.CalledProcessError as ex: except subprocess.CalledProcessError as ex:
# non zero return code # non zero return code
exit_code = ex.returncode exit_code = ex.returncode
if is_windows_platform(): if not use_execv:
exit(exit_code) exit(exit_code)
except Exception as ex: except Exception as ex:
if is_windows_platform(): if not use_execv:
exit(-1) exit(-1)
raise ex raise ex
else: else:

View File

@ -157,6 +157,10 @@ def is_windows_platform():
return any(platform.win32_ver()) return any(platform.win32_ver())
def is_linux_platform():
return 'linux' in platform.system().lower()
def normalize_path(*paths): def normalize_path(*paths):
""" """
normalize_path normalize_path