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

Make yarn.py and launcher.py compatible with Python 3 #564

Merged
merged 2 commits into from
Oct 24, 2019

Conversation

hcho3
Copy link
Contributor

@hcho3 hcho3 commented Sep 24, 2019

Closes #538

@ericangelokim @thvasilo @chenqin @trivialfis Can you review?

For now, I added a compatibility shim to support both Python 2 and 3. See #565

@ericangelokim
Copy link

Does this need to be done in any other files?

What would be the repurcussions of just moving this to be only python3 compaible? Py2 is deprecated; it feels backwards to have to support this. Current users can continue to use an older git commit if necessary.

@hcho3
Copy link
Contributor Author

hcho3 commented Sep 24, 2019

@ericangelokim So you are okay with dropping Python 2.x?

@ericangelokim
Copy link

The versioning of this code is dependent on xgb version?

@hcho3
Copy link
Contributor Author

hcho3 commented Sep 24, 2019

@ericangelokim It's other way around. Each XGBoost version has reference to exact commit hash of dmlc-core.

@ericangelokim
Copy link

Right so existing customers of xgboost (locked to a previous version) will not be affected by this.

In that case I think it makes sense to deprecate python 2 support.

@ericangelokim
Copy link

You may want to run an example training with python3 when changes are done to ensure that this is the only place that is affected.

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we can test this? Maybe a with mock? Not necessary for this PR, but tests generally makes life easier ...

@thvasilo
Copy link

I encountered the same error in the MPI tracker today, assume it's the same cause.

@hcho3
Copy link
Contributor Author

hcho3 commented Sep 26, 2019

@thvasilo I'm not sure why that line would cause issue. b'mpich' in out seems quite valid.

@thvasilo
Copy link

thvasilo commented Sep 26, 2019 via email

@thvasilo
Copy link

I encountered the same error in the MPI tracker today, assume it's the same cause.

Yup never mind, this was back in 0.72

@thvasilo
Copy link

I launched an EMR cluster today to test this out.

I got this error in one of the containers:

Traceback (most recent call last):
  File "./launcher.py", line 81, in <module>
    main()
  File "./launcher.py", line 55, in main
    for f in classpath.split(':'):
TypeError: a bytes-like object is required, not 'str'

Adding the argument encoding='utf-8' to the call to Popen in launcher.py fixed the issue.

I think the reason is explained in the docs for Popen:

If encoding or errors are specified, the file objects stdin, stdout and stderr are opened in text mode with the specified encoding and errors, as described above in Frequently Used Arguments. If universal_newlines is True, they are opened in text mode with default encoding. Otherwise, they are opened as binary streams.

@hcho3
Copy link
Contributor Author

hcho3 commented Sep 28, 2019

@thvasilo Can you try my latest fix? I did not use encoding='utf-8' because it's only supported in Python 3. In this PR, I aim to support both Python 2 and 3, since #565 has not been decided yet.
@trivialfis See #568.

This was referenced Oct 24, 2019
@hcho3 hcho3 changed the title Make yarn.py compatible with Python 3 Make yarn.py and launcher.py compatible with Python 3 Oct 24, 2019
@hcho3 hcho3 merged commit 05fb5ad into dmlc:master Oct 24, 2019
@hcho3 hcho3 deleted the py3_yarn branch October 24, 2019 18:08
@jozsi
Copy link

jozsi commented May 5, 2020

I am getting the following error when trying to run dmlc-submit for yarn via ./xgboost/demo/distributed-training/run-aws:

Traceback (most recent call last):
  File "./launcher.py", line 10, in <module>
    from .util import py_str
ModuleNotFoundError: No module named '__main__.util'; '__main__' is not a package

There's also a bug on line 58, if I'm not mistaken:
classpath = py_str(class_path)
should be
classpath = py_str(classpath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yarn-submit.py not runnable using python3
6 participants