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

io: allow setting progress=False in solver to disable stdout even for larger models #375

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

maurerle
Copy link
Contributor

@maurerle maurerle commented Nov 7, 2024

This was unnecessary when solving a lot of problems programatically.

The log param of the solve function does have three states:

  • None: log tqdm to stdout if model is > 10k constraints
  • True: always creates tqdm for model
  • False: never creates tqdm for model

For better usage, the log param is renamed to progress on all occurrences

Copy link
Member

@lkstrp lkstrp left a comment

Choose a reason for hiding this comment

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

Looks good, thank you @maurerle
A few minor things left on types and docstrings.

linopy/io.py Outdated Show resolved Hide resolved
linopy/io.py Outdated Show resolved Hide resolved
linopy/io.py Outdated Show resolved Hide resolved
linopy/model.py Outdated Show resolved Hide resolved
@maurerle maurerle force-pushed the allow_suppress_stdout branch 3 times, most recently from b1e17cf to 303585a Compare November 7, 2024 13:27
@maurerle maurerle requested a review from lkstrp November 7, 2024 13:28
@maurerle maurerle force-pushed the allow_suppress_stdout branch from 303585a to 2cfdba1 Compare November 11, 2024 08:21
@maurerle maurerle changed the title allow setting stdout=False in solver to disable stdout even for larger models allow setting progress=False in solver to disable stdout even for larger models Nov 11, 2024
@maurerle maurerle force-pushed the allow_suppress_stdout branch from 79de0e5 to 4e0b2b3 Compare November 11, 2024 08:25
@maurerle maurerle force-pushed the allow_suppress_stdout branch from 7a21b43 to 4dee914 Compare November 11, 2024 08:27
@maurerle
Copy link
Contributor Author

Looks good from my side now, @lkstrp can you take another look please? :)

@maurerle maurerle changed the title allow setting progress=False in solver to disable stdout even for larger models io: allow setting progress=False in solver to disable stdout even for larger models Nov 11, 2024
Copy link
Member

@lkstrp lkstrp left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!
Two last things:

  • Release note is missing
  • We can deprecate log instead of removing it. So accept both log and progress, and throw a DeprecationWarning when log is passed. There is a decorator for this somewhere, I can add it if you don't mind. It may be unnecessary, but I think it's better practice.

@maurerle
Copy link
Contributor Author

If you add the remarks yourself, that would be great!
You should be able to push to my branch

From my point of view, the deprecation is not really necessary as there did not exist a public api to set log before anyway.

@lkstrp
Copy link
Member

lkstrp commented Nov 21, 2024

Agreed, thank you @maurerle !

@lkstrp lkstrp merged commit f4b48f5 into PyPSA:master Nov 21, 2024
17 of 19 checks passed
@maurerle maurerle deleted the allow_suppress_stdout branch November 21, 2024 13:21
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