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

calculated chunksizes greater than zero #762

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

emanuel-schmid
Copy link
Collaborator

@emanuel-schmid emanuel-schmid commented Aug 2, 2023

Changes proposed in this PR:

  • When chunksizes for pool.map are calculated, make sure they are at least 1.

This PR fixes #761

PR Author Checklist

PR Reviewer Checklist

@emanuel-schmid emanuel-schmid requested a review from chahank August 2, 2023 14:35
@@ -198,7 +198,7 @@ def uncertainty(self, unc_data, pool=None, **cost_benefit_kwargs):
with log_level(level='ERROR', name_prefix='climada'):
if pool:
LOGGER.info('Using %s CPUs.', pool.ncpus)
chunksize = min(unc_data.n_samples // pool.ncpus, 100)
chunksize = max(min(unc_data.n_samples // pool.ncpus, 100), 1)
Copy link
Member

Choose a reason for hiding this comment

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

I am currently rewriting the parallel computing for the unsequa module as it was not working properly. So these changes are probably not needed. I will update at the end of today.

Copy link
Member

Choose a reason for hiding this comment

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

Is being done in #763. I propose to merge #763 first.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, since #763 might take some time to review, we can also merge this pull request first.

@chahank chahank mentioned this pull request Aug 3, 2023
13 tasks
@@ -205,7 +205,7 @@ def uncertainty(self,
with log_level(level='ERROR', name_prefix='climada'):
if pool:
LOGGER.info('Using %s CPUs.', pool.ncpus)
chunksize = min(unc_sample.n_samples // pool.ncpus, 100)
chunksize = max(min(unc_sample.n_samples // pool.ncpus, 100), 1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
chunksize = max(min(unc_sample.n_samples // pool.ncpus, 100), 1)
chunksize = min(unc_sample.n_samples // pool.ncpus + 1, 100)

I think this is more elegant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm. Maybe. But when you have 6 samples and 3 cpus the chunksize is 3 where 2 would fit better- right?
Doesn't matter I guess, but the elegance comes at a price of reduced readability imho.

Copy link
Member

Choose a reason for hiding this comment

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

Right. I am fine either way :D

@emanuel-schmid emanuel-schmid merged commit da8d861 into develop Aug 4, 2023
@emanuel-schmid emanuel-schmid deleted the feature/chunksize_gt0 branch August 4, 2023 14:19
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