Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and support python2.x or python3.9 on yarn. #652

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tracker/dmlc_tracker/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import sys
import uuid
import logging
from kubernetes import client, config
if "kubernetes" in sys.modules:
from kubernetes import client, config
from . import tracker
import yaml
if "yaml" in sys.modules:
import yaml

template_volume = {
"name":""
Expand Down
9 changes: 5 additions & 4 deletions tracker/dmlc_tracker/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import os
import subprocess
from .util import py_str
from util import py_str

def unzip_archives(ar_list, env):
for fname in ar_list:
Expand Down Expand Up @@ -55,7 +55,7 @@ def main():
(classpath, _) = subprocess.Popen('%s/bin/hadoop classpath' % hadoop_home,
stdout=subprocess.PIPE, shell=True,
env=os.environ).communicate()
classpath = py_str(class_path)
classpath = py_str(classpath)
for f in classpath.split(':'):
class_path += glob.glob(f)

Expand All @@ -77,8 +77,9 @@ def main():
if 'DMLC_JOB_ARCHIVES' in env:
unzip_archives(env['DMLC_JOB_ARCHIVES'].split(':'), env)

ret = subprocess.call(args=sys.argv[1:], env=env)
sys.exit(ret)
fp = subprocess.Popen(args=sys.argv[1:], stdout=subprocess.PIPE, shell=True, env=env)
fp.communicate()
sys.exit(fp.returncode)


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions tracker/dmlc_tracker/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ def run():
self.thread.start()

def join(self):
while self.thread.isAlive():
while self.thread.is_alive():
self.thread.join(100)

def alive(self):
return self.thread.isAlive()
return self.thread.is_alive()

class PSTracker(object):
"""
Expand Down Expand Up @@ -369,7 +369,7 @@ def __init__(self, hostIP, cmd, port=9091, port_end=9999, envs=None):

def join(self):
if self.cmd is not None:
while self.thread.isAlive():
while self.thread.is_alive():
self.thread.join(100)

def slave_envs(self):
Expand All @@ -381,7 +381,7 @@ def slave_envs(self):

def alive(self):
if self.cmd is not None:
return self.thread.isAlive()
return self.thread.is_alive()
else:
return False

Expand Down
4 changes: 3 additions & 1 deletion tracker/dmlc_tracker/yarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def yarn_submit(args, nworker, nserver, pass_env):
YARN_JAR_PATH = os.path.join(args.yarn_app_dir, 'dmlc-yarn.jar')
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
YARN_BOOT_PY = os.path.join(curr_path, 'launcher.py')
YARN_UTIL_PY = os.path.join(curr_path, 'util.py')

if not os.path.exists(YARN_JAR_PATH):
warnings.warn("cannot find \"%s\", I will try to run build" % YARN_JAR_PATH)
Expand All @@ -60,6 +61,7 @@ def yarn_submit(args, nworker, nserver, pass_env):
fset, new_command = opts.get_cache_file_set(args)
fset.add(YARN_JAR_PATH)
fset.add(YARN_BOOT_PY)
fset.add(YARN_UTIL_PY)
ar_list = []

for fname in args.archives:
Expand Down Expand Up @@ -112,7 +114,7 @@ def yarn_submit(args, nworker, nserver, pass_env):
def run():
"""internal running function."""
logging.debug(cmd)
subprocess.check_call(cmd, shell=True, env=env)
subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, env=env).communicate()

thread = Thread(target=run, args=())
thread.setDaemon(True)
Expand Down