Skip to content

DEPR: deprecate astropy.utils.console.terminal_size and stop using it internally - #16045

Merged
pllim merged 1 commit into
astropy:mainfrom
neutrinoceros:utils/console/depr/terminal_size
Feb 16, 2024
Merged

pllim merged 1 commit into
astropy:mainfrom
neutrinoceros:utils/console/depr/terminal_size

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

Description

Since this doesn't seem controversial
Fixes #16042
Currently based onto #16040 to avoid an implicit merge conflict.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

github-actions Bot commented Feb 15, 2024 •

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 9779fd7 to 50faa93 Compare February 15, 2024 07:37
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

failures are real. Let me check if I can fix that easily.

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 50faa93 to 7d2afe1 Compare February 15, 2024 09:25
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

I fixed the worst ones but there are still a lot and I'm not sure they're actually fixable. Maybe the solution is simply not to deprecate this function.

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 7d2afe1 to 81ba536 Compare February 15, 2024 11:20
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

whoops, I missed that get_terminal_size gave (columns, lines), and terminal_size does the reversed. Should be good now ? 🤞🏻

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch 2 times, most recently from aa3811d to 2284446 Compare February 15, 2024 11:28
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

2 remaining failures in Table.pprint tests, that I think are due to slight differences in what the replacement function returns. Without looking too deeply into it, I would assume the function from the standard lib is more reliable so the change could be considered a bug fix. Otherwise it's likely possible to force bug-for-bug compatibility.

@pllim pllim added this to the v6.1.0 milestone Feb 15, 2024
@pllim pllim added the API change PRs and issues that change an existing API, possibly requiring a deprecation period label Feb 15, 2024
@mhvk

mhvk commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

I think it is OK to adjust the doctests. To be honest, showing 1 line before the ... and 2 after seems better than 1 and 3 (2 and 2 would perhaps be more logical, but, really, no big deal...

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks all good to me! I don't know if you'd want further feedback (maybe @taldcroft, since it is used in table?), but it looks all good to me.

Comment thread docs/timeseries/index.rst
2009-05-02T00:48:32.291 6.632337e-04 ... 1.5272264e-03 -1.4998110e-03
2009-05-02T00:49:31.149 6.632584e-04 ... 1.5193661e-03 -1.5074468e-03
... ... ... ... ...
2009-05-11T17:58:22.526 1.014493e-03 ... 3.6121816e-03 3.1950327e-03

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, the usual annoyance that, sadly, doctests just stop when an error is encountered, so you don't necessarily get all of them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah that's why I needed two iterations ! thanks for clarifying this !

@mhvk mhvk added the Bug label Feb 15, 2024
@mhvk
mhvk marked this pull request as ready for review February 15, 2024 18:55
@mhvk
mhvk requested a review from taldcroft as a code owner February 15, 2024 18:55

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cannot merge this until the diff from #16040 is taken back out.

@pllim

pllim commented Feb 15, 2024

Copy link
Copy Markdown
Member

#16040 is merged. Please rebase. Thanks!

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 7dcb336 to abbe530 Compare February 16, 2024 06:51
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

rebased !

@saimn

saimn commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

whoops, I missed that get_terminal_size gave (columns, lines), and terminal_size does the reversed. Should be good now ?

Also they disagree by 1:

In [3]: shutil.get_terminal_size()
Out[3]: os.terminal_size(columns=96, lines=46)

In [4]: from astropy.utils import console

In [5]: console.terminal_size()
Out[5]: (40, 95)

It seems shutil.get_terminal_size is right, here I can print 96 characters on one line.

@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 0eca5c9 to 2bb54bc Compare February 16, 2024 07:49
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

yes this is what I hinted to in #16045 (comment) (I could have been more explicit). I think this is also why some doctests adjustments are required.
Actually one of them is still failing, let me switch to draft until I get it back to green.

@neutrinoceros
neutrinoceros marked this pull request as draft February 16, 2024 08:06
@neutrinoceros
neutrinoceros force-pushed the utils/console/depr/terminal_size branch from 2bb54bc to ceb5c31 Compare February 16, 2024 08:07
Comment thread docs/timeseries/index.rst
>>> ts_binned = aggregate_downsample(ts_folded, time_bin_size=0.03 * u.day) # doctest: +REMOTE_DATA +IGNORE_WARNINGS
>>> ts_binned # doctest: +FLOAT_CMP +REMOTE_DATA
<BinnedTimeSeries length=74>
time_bin_start time_bin_size ... pos_corr2 sap_flux_norm

@neutrinoceros neutrinoceros Feb 16, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If you're seeing this in split diff, you might be wondering what the actual difference is (it certainly wasn't obvious to me).
What's changed is that some horizontal whitespace was removed on the "pix" column because the row that got removed happened to be have most demanding value in terms of horizontal space (namely, -2.2798192730988376e-05). This is slightly easier to see in unified diff view.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

ready at last !

@neutrinoceros
neutrinoceros marked this pull request as ready for review February 16, 2024 08:36
@neutrinoceros neutrinoceros changed the title DEPR: deprecate astropy.utils.console.terminal_size DEPR: deprecate astropy.utils.console.terminal_size and stop using it internally Feb 16, 2024

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fine to me.

@taldcroft

Copy link
Copy Markdown
Member

@mhvk - just curious why you labeled this as a bug?

@mhvk mhvk removed the Bug label Feb 16, 2024
@mhvk

mhvk commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

Oops, my mistake - I saw a fixes ... and assumed there was also a bug involved. Now removed.

@mhvk

mhvk commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

@pllim - I think this one is ready (it was rebased following your request); could you check? (And go ahead and merge if it is all OK!)

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM now. Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ehem... US English spells as "favor" but I'll let this slide. 😉

(This is not a serious comment. We traditionally have unresolved debates on US vs UK English.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sure I mix US and UK flavours all the time, so I'm neutral ! (or maybe just inconsistent ?)

@pllim
pllim merged commit 89d99f3 into astropy:main Feb 16, 2024
@neutrinoceros
neutrinoceros deleted the utils/console/depr/terminal_size branch February 17, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API change PRs and issues that change an existing API, possibly requiring a deprecation period table utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEPR: should we deprecate astropy.utils.console.terminal_size ?

5 participants