fix: use math.ceil() instead of int() for n_local_cores to prevent ZeroDivisionError on single-core machines#91
Open
Mani212005 wants to merge 2 commits into
Open
fix: use math.ceil() instead of int() for n_local_cores to prevent ZeroDivisionError on single-core machines#91Mani212005 wants to merge 2 commits into
Mani212005 wants to merge 2 commits into
Conversation
Contributor
|
Hi! Could you reformat this PR using our existing PR template: https://github.com/mllam/mllam-data-prep/blob/main/.github/pull_request_template.md ? This guarantees that we follow the development workflows that we have in place. If you have questions about some parts of it feel free to ask! |
Author
|
@joeloskarsson |
Contributor
|
This all looks good to me. Can you also add a changelog entry? And double-check that the linting passes. Will assign @leifdenby for a final ok and merging. |
joeloskarsson
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
When using
--dask-distributed-local-core-fractionwith a value between0and1on asingle-core machine (e.g. standard GitHub CI), the following line:
truncates towards zero. For example:
This causes a
ZeroDivisionErrorwhen computingmemory_per_worker:The fix replaces
int()withmath.ceil()to always round up to at least 1 worker:This ensures
n_local_cores >= 1regardless of the fraction or number of system cores.Changes:
cli.py— Addedimport mathand replacedint()withmath.ceil()for then_local_corescalculation.test_distributed.py— Added"0.5"as a parametrized test case to cover the fractional value scenario that triggered the bug.Testing — all 4 distributed tests pass:
Issue Link
Closes #32
Type of change
Checklist before requesting a review
pullwith--rebaseoption if possible).Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
added— when you have added new functionalitychanged— when default behaviour of the code has been changedfixes— when your contribution fixes a bugChecklist for assignee
added,changedorfixed)