Repository navigation
Conversation
It works, but the tests are not extensive and the code could probably be more concise
Will be re-usable for "map" notes. Current function stores metadata as list of lines instead of strings or structured data.
First parse all metadata to lists of strings, then handle mapped notes -> odict, then concatenate all other metadata to strings, then split author list into Python list
|
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 |
The test uses a CDS table but not MRT-compatible
"Mapping notes" are wrapped individually and then all indented. Continuation always uses indentation of 4 spaces Code neads to be cleaned up. This is first working version. Still needs proper testing
|
I just finished a first attempt at writing the metadata.
I still need to add proper tests. Once that is done, I'll mark this as ready for review! |
|
Thanks a lot for working on this @vandalt ! |
|
Thanks for the feedback @neutrinoceros ! The only reason I went for |
|
Oh, if that's how we document it, we should keep an |
"An operation receives an argument with the right type but an inappropriate value" (https://docs.python.org/3/library/exceptions.html#ValueError) seems to match the description. KeyError would be if key not found, which is not the case here.
Create new `test_mrt.py`, because this is not applicable to CDS tables
|
I am encountering issues due to the various ways metadata other than byte-by-byte description can be specified in the header, namely article title, author names, and table titles
My current implementation supports only the latter case, as I was focusing on MRT tables. However, this means that now there are some tests failing when trying to read metadata from What would be the best path forward:
I feel like option 1 above separates the two formats nicely, but I might be missing some context about what is expected from the two standards. @taldcroft your suggestions would be welcome, since I think it was you who initially separated MRT and CDS in two classes. Thanks! |
|
It's things like this where @taldcroft and I always felt that the CDS and the MRT format are different. But then we recently talked to the AAS journal data editors and my understanding is that Gus Muench (who works as data editor for the AAS journal and makes the MRT tables they publish - @augustfly ) implied that they are not intended to be different. |
…or tests Now that metadata is not read in the same way, byte-by-byte tests need separate files
|
I realize I may have mis-communicated here, and maybe we are in a deadlock because of it. So, just in case you guys are waiting for my review, I should explicitly state that I don't normally review PRs marked as draft unless explicitly requested (by someone else). In effect, I'm waiting for either the PR to be undrafted or that someone else asks me to review. |
|
Hi! Sorry, the issue is not miscommunication on your side, but lack of time on my end (I'm teaching this semester). I hope I can get back to this around May. However, if someone wants to take over the PR before that, please feel free to do so :) |
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary. If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock. If you believe I commented on this pull request incorrectly, please report this here. |
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 1 year, 11 months. I plan to close this in a month if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary. If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock. If you believe I commented on this pull request incorrectly, please report this here. |
|
It's been a while, and maybe @vandalt still doesn't have time for this, but now I do. Thomas, please let me know if you'd like me to pick it up for you. I could just keep your branch alive by resolving merge conflicts or take over if you want. |
|
I indeed don't have time for this right now sorry. But @neutrinoceros please do take over if you have time for it :) I would love to see this feature implemented. Thanks! |
|
Thanks ! |
|
Rebasing is probably a waste of time because so much has changed since and some of the changes are invasive. By that I mean that they rename files for tests which makes is hard for git to match up any more recent changes in the old files to the changes here. The work could be split in two: Metadata in MRT and metadata in CDS. While they are very similar, the AAS journals (MRT) can be slightly different, so this could be developed for MRT first and applied to CDS later as a separate PR (that should be simple, since astropy only read CDS, while is reads and writes MRT). @vandalt reported problems with the CDS tests in this PR due to the slightly different format. I suggest to punt on that for now and get one format working first. We can contact the AAS journal data editor for clarification of the MRT format if we need to and we'll leave CDS for a separate PR. I do think reading and writing this metadata is important, and I also hope it's not too complicated if we stick to MRT for now. Better to get one format done, than waiting for the perfect solution to both of them. The low-hanging fruit is to map notes and title/author/etc on the top to long strings in the This PR goes further (e.g. split author names into a list of names rather than one long string) but I'm not sure that has a lot of use cases so it's definitely not high priority and I suggest a later add-on PR. |
|
@hamogu Yes, all of this sounds good to me! I agree that copy-pasting the relevant parts in a new PR is likely the easiest way forward for @neutrinoceros and I'm really not fussed about credit/co-authorship, so whatever works best :) Thanks! |
Description
This pull request aims to address reading and writing metadata in MRT tables with the
io.asciisub-package. It is still a draft, but I had some questions regarding the implementation (see "Questions" below)Currently, only reading is implemented. It is done via the
update_meta()method forMrtHeader. The method parses all metadata fields (Title,Authors,Table, and allNotes ({n})and store their content as list of lines before converting it to its final format (see "What format should be used for metadata?" below).Questions
Feedback welcome from everyone, but CC-ing @hamogu and @dhomeier who participated in the discussion on #16787.
What format should be used for metadata?
Currently, I'm using
Table.metato store the metadataTable.meta["top"]to store the "top" metadata (Title, Authors, Table), as anOrderedDictTable.meta["notes"]to store notes, as a list.The structure of the metadata values are either:
OrderedDictfor notes that map string flags to their descriptions (e.g. note 2 in cds2.dat)list, for AuthorsLet me know if you have comments or suggestions about this.
How should continuation be handled?
When a given metadata field is split over multiple lines in the input file, should it be kept this way in the metadata? Currently it is not: lines are concatenated and will be split at the maximum length when writing back. This means that the format is not 1-to-1 when round-tripping, but the content is not altered, only the position of line splits. If we want to preserve the exact position of line splits, we could 1) store metadata as a list of lines or 2) concatenate lines with
\ninstead of a space. In both cases, this would not blend well with "structured" metadata (author list and "mapping" notes, see 2 and 3 in the description above). Another option would be to keep track of the split locations as "extra" metadata and then apply that when writing the table back. If feel like the complexity might not be worth the small consistency improvement, especially that currently long byte-by-byte descriptions can have different split positions, and the format is not exactly 1-to-1 already (e.g. limits information is added even when not present in the input).TODO
Things that should be done before this is ready for review:
Additional context
It is related to #12039, which started to implement writing MRT metadata. However, that PR was written before MRT and CDS were split in separate modules. I started with reading as I felt this was easier to implement and would help decide which data format to use. There also seems to be some overlap with #14883.
Fixes #16787.