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

MPIBackend platform logic #875

Closed
gtdang opened this issue Aug 30, 2024 · 4 comments · Fixed by #876
Closed

MPIBackend platform logic #875

gtdang opened this issue Aug 30, 2024 · 4 comments · Fixed by #876
Labels
bug Something isn't working

Comments

@gtdang
Copy link
Collaborator

gtdang commented Aug 30, 2024

Was inspecting the MPIBackend class and found this logic below.

# Split the command into shell arguments for passing to Popen
if 'win' in sys.platform:
use_posix = True
else:
use_posix = False
self.mpi_cmd = shlex.split(self.mpi_cmd, posix=use_posix)

Isn't this setting posix=True for Windows and Mac (Darwin), and False for Linux? sys.platform docs

Although somehow MPI seems to be working OK on Linux despite the incorrect flag here?

@gtdang gtdang added the bug Something isn't working label Aug 30, 2024
@gtdang
Copy link
Collaborator Author

gtdang commented Aug 30, 2024

Tested this shlex.split function with paths with forward and back slashes. The flag doesn't impact posix path parsing, which explains why linux is still functioning with this error. Windows paths would be broken though.

shlex.split('/test/path/posix', posix=True)
Out[13]: ['/test/path/posix']

shlex.split('/test/path/posix', posix=False)
Out[14]: ['/test/path/posix']

shlex.split(r'\test\path\non_posix', posix=True)
Out[15]: ['testpathnon_posix']

shlex.split(r'\test\path\non_posix', posix=False)
Out[16]: ['\\test\\path\\non_posix']

@gtdang gtdang linked a pull request Aug 30, 2024 that will close this issue
@rythorpe
Copy link
Contributor

rythorpe commented Sep 3, 2024

Maybe I'm missing something here, but don't we want posix=True only for Windows? If so, the Linux flag is correct as-is.

@gtdang
Copy link
Collaborator Author

gtdang commented Sep 3, 2024

posix path is Unix style, you’d want it True for Mac and Linux. The shlex.split function defaults with True, you only want to pass it posix=False for Windows so it can parse backslashes correctly. See the test examples above.

@rythorpe
Copy link
Contributor

rythorpe commented Sep 4, 2024

Oh I get it now. It's a good thing I asked because I had that all mixed up in my head 🙃 Thanks @gtdang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants