Skip to content

Local Python env Cluster (rebased)#9332

Open
dometto wants to merge 28 commits into
dask:mainfrom
dometto:venv_cluster
Open

Local Python env Cluster (rebased)#9332
dometto wants to merge 28 commits into
dask:mainfrom
dometto:venv_cluster

Conversation

@dometto

@dometto dometto commented Jul 20, 2026

Copy link
Copy Markdown

Rebase of #5013

I refer to explanation and discussion in that PR.

#5013 was never finished because merge conflicts appear. That seems a shame: the conflicts were relatively easy to solve. Opening this PR to see if the tests still pass.

I take no credit for @DPeterK's amazing work -- git adds me as a co-author for their commits because of the rebase, I hope that's ok.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    40 files  ± 0      40 suites  ±0   14h 46m 47s ⏱️ + 11m 43s
 4 164 tests + 5   3 984 ✅ + 6    178 💤  -  1  2 ❌ ±0 
81 038 runs  +96  76 775 ✅ +74  4 261 💤 +22  2 ❌ ±0 

For more details on these failures, see this check.

Results for commit 53dc38b. ± Comparison against base commit 40fcd99.

♻️ This comment has been updated with latest results.

@dometto dometto mentioned this pull request Jul 20, 2026
3 tasks
Comment thread pyproject.toml
'''ignore:unclosed transport <_SelectorSocketTransport.*:ResourceWarning''',
'''ignore:unclosed transport <asyncio\.sslproto\..*:ResourceWarning''',
'''ignore:unclosed cluster SSHCluster.*:ResourceWarning''',
'''ignore:unclosed transport <_UnixReadPipeTransport.*:ResourceWarning''',

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These warnings were being thrown by test_job_submission. I'm assuming it's safe to ignore them.

@dometto

dometto commented Jul 21, 2026

Copy link
Copy Markdown
Author

Tests mostly passing:

  • Seeing failures on macos and ubuntu, but in the ci1 segment -- the tests for this PR are in not ci1. These are presumbly unrelated, or flukes.
  • Seeings failures on windows; it may be that we need to add different ignore rules to pyproject.toml, or that LocalEnvCluster doesn't work on Windows at all.

The remaining linting (mypy) errors are not related to this PR.

Comment thread pyproject.toml
@dometto

dometto commented Jul 21, 2026

Copy link
Copy Markdown
Author

It looks like subprocess support in Windows is only available using the ProactorEventLoop, and distributed appears to need the SelectorEventLoop on Windows.

I'll raise a NotImplementedError in LocalEnvCluster on Windows, and skip the CI tests for now. However, I see that @crusaderky is currently working on ProactorEventLoop support on Windows, which would mean this PR could support Windows as well.

@dometto

dometto commented Jul 21, 2026

Copy link
Copy Markdown
Author

Looking into subprocess support in Windows I saw that distributed now has a SubprocessCluster, which wasn't there when #5013 was opened.

I think the only differences with Subprocess are that:

  • LocalEnv allows setting python interpreter
  • LocalEnv copies global config into the spawned processes -- I am not sure why this was deemed necessary

So perhaps a more lightweight change would be to simply make the python interpreter configurable in SubprocessCluster. Would that be acceptable?

Pinging @crusaderky as I noticed you are currently working on SubprocessCluster. TL;DR: this feature is desirable for dask-labextension: dask/dask-labextension#207.

def __repr__(self):
return f"<LocalEnv {type(self).__name__}: status={self.status}>"

async def _set_env_helper(self):

@dometto dometto Jul 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This logic to forward config is taken from the SSHCluster. I'm not sure why it is necessary: if I see correctly, LocalEnv is meant to start workers/scheduler in a different venv on the same host. Assuming the processes using python in the second venv always run as the same user as the python interpreter that runs this code, why do we need to forward config? Won't the spawned workers get the same config anyway when they start up?

@crusaderky

Copy link
Copy Markdown
Collaborator

@crusaderky is currently working on ProactorEventLoop support on Windows, which would mean this PR could support Windows as well.

I'm not actively working on it. I tried, realised it was not a quick win, and abandoned the effort.

@dometto

dometto commented Jul 26, 2026

Copy link
Copy Markdown
Author

Understood. Could someone let me know if this PR, or a more simple version that makes the command in Subprocess workers and schedulers overridable, can be considered for merging?

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.

2 participants