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,
named_temporary_file,
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.package.base import PackageManager
from trains_agent.helper.package.conda_api import CondaAPI
@ -1161,11 +1161,12 @@ class Worker(ServiceCommandSection):
exit_code = -1
try:
if disable_monitoring:
use_execv = is_linux_platform() and not isinstance(self.package_api, (PoetryAPI, CondaAPI))
try:
sys.stdout.flush()
sys.stderr.flush()
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:])
else:
exit_code = command.check_call(cwd=script_dir)
@ -1173,10 +1174,10 @@ class Worker(ServiceCommandSection):
except subprocess.CalledProcessError as ex:
# non zero return code
exit_code = ex.returncode
if is_windows_platform():
if not use_execv:
exit(exit_code)
except Exception as ex:
if is_windows_platform():
if not use_execv:
exit(-1)
raise ex
else:

View File

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