BUG: fix generate_ref_ast.py helper script and add installation instructions for it#16976
Conversation
|
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.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
83ae082 to
39bd278
Compare
| " the reference values were computed using AST\n" | ||
| ) | ||
| t.write(f, format="ascii", delimiter=",") | ||
| with open(DATA_DIR / fnout, "w") as fh: |
There was a problem hiding this comment.
the true bug was that the file was open in binary mode, when the following write functions both assume text mode. Everything else (using a context manager and an absolute path) is just for convenience.
There was a problem hiding this comment.
Does this mean that the script that claims to have produced reference data for our tests cannot possibly have done that?
There was a problem hiding this comment.
I'm not quite sure, it may have been able to run as is in Python 2, where strings and bytes objects behaved differently. Unfortunately I cannot test this (Python 2 doesn't compile on mac ARM).
There was a problem hiding this comment.
I'm not familiar with Python 2 either. I suppose it's plausible enough that this was Python 2 script that has not been properly ported to Python 3.
generate_ref_ast.py helper script and add installation instructions for it
39bd278 to
1f4631b
Compare
|
Note that there's a PR upstream to overcome the current limitations with Python 3.13 and numpy 2 Starlink/starlink-pyast#45 |
Very hard to say without seeing the changes.
It would be great if an upstream release could make the script work with a broader set of dependencies, but looking at the frequency of updates in |
@eerovaher Please see #16980
agreed. I opened a reminder issue for this #16981 |
255b27e to
bed6c46
Compare
|
Thanks to @eerovaher's suggestions in #16980, this is now completely consistent: I regenerated the datafiles using the fixed script and committed the diff, which is only in the headers |
| # /// script | ||
| # requires-python = ">=3.10, <3.13" | ||
| # dependencies = [ | ||
| # "starlink-pyast==3.15.4", | ||
| # "numpy==1.26.4", | ||
| # "astropy", | ||
| # ] | ||
| # /// | ||
| # above are PEP 723 script metadata for later reference, but they are | ||
| # insufficient to run the script: starlink-pyast doesn't have wheels or proper | ||
| # build time requirements specifications. | ||
| # It must be build from source and without isolation, for instance, as follows | ||
| # pip install 'numpy==1.26.4' 'setuptools==74.1.2' | ||
| # pip install 'starlink-pyast==3.15.4' --no-build-isolation | ||
| # pip install astropy |
There was a problem hiding this comment.
I'll try to find time tomorrow to follow these instructions.
There was a problem hiding this comment.
I was able to successfully generate the data files by following these instructions with Python 3.10 (which installed astropy 6.1.3).
There was a problem hiding this comment.
awesome. Anything else or is this good to go ?
bed6c46 to
2c9d92c
Compare
2c9d92c to
f1c58a1
Compare
eerovaher
left a comment
There was a problem hiding this comment.
My understanding is that there were three problems with this script:
- Apparently the script was originally written for Python 2, but was not ported to Python 3 properly.
- It was not immediately obvious how the floating point numbers were formatted and apparently the default values used for formatting have changed.
- Installing
starlink-pyastis not trivial.
The first two problems are fixed here. The third one is an upstream problem, but this pull request adds adequate documentation to our script.
It might be a good idea to check if the other scripts we have for replicating test data work or not.
|
Nicely summarized, thanks !
Agreed, I can try and audit the codebase. If you have ideas of how to systematically discover such script, don't hesitate to share them ! |
|
One option would be to search for |
|
ok, I guess it's still good if we can check some of them rather than none. Thanks ! |
Description
In #16932 we discovered that this script wasn't trivial to run, and was in fact broken. Here's a fix together with some installation instructions for future reference.
Independently, it looks like running the script now changes a couple data files, should I also commit those changes here @eerovaher ?
ref #16932 (comment)