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

Allow packages to use ISO 8601 dates in their PackageInfo.g files (so YYYY-MM-DD instead of DD/MM/YYYY) #3355

Merged
merged 1 commit into from
Feb 20, 2021

Conversation

wucas
Copy link
Contributor

@wucas wucas commented Mar 19, 2019

If the date format is dd/mm/yyyy and InfoLevel InfoPackageLoading is set to at least 2 it prints a hint to change the format as was suggested in #2727. This pull request is intended to fix issue #2727.

@fingolfin fingolfin added gapdays2019-spring Issues and PRs that arose at https://www.gapdays.de/gapdays2019-spring and removed gapdays2019-spring Issues and PRs that arose at https://www.gapdays.de/gapdays2019-spring labels Mar 19, 2019
Copy link
Member

@olexandr-konovalov olexandr-konovalov left a comment

Choose a reason for hiding this comment

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

This looks like a good start, I've requested some changes.

First, note that this is not everything, otherwise it would be too simple. For example, .Date is used by the package updates system - see this line and below:

https://github.com/gap-system/gap-distribution/blob/bb3123c18ca916bccb01211110fb338655ca9d6a/DistributionUpdate/PackageUpdate/PackageInfoTools.g#L339

and as it stands now, it will reject ISO 8601 dates. Second, the linked code does some checks for the validity of the date, which may be transferred here.

lib/package.gi Outdated Show resolved Hide resolved
lib/package.gi Outdated Show resolved Hide resolved
@fingolfin
Copy link
Member

For some reason, there is a conflict in lib/package.gi -- which is a bit odd, that file was last changed in February... @wucas it seems you started your work from an old version of the GAP master branch (December 2018). I recommend that you first update the master branch of your GAP clone to the latest, then rebase you work. I'll be happy to assist with the latter, if desired.

@wucas wucas force-pushed the lw/allow-ISO8601-dates branch 2 times, most recently from 1597a99 to 4d47cfa Compare March 20, 2019 13:05
@wucas
Copy link
Contributor Author

wucas commented Mar 20, 2019

@alex-konovalov I submitted a pull request to change this in gap-distribution too. Also ValidatePackageInfo validates the date now.

@olexandr-konovalov
Copy link
Member

Thanks @wucas - I will look. A cross-reference to that PR from here would be useful though. Saves time when navigating and connects things belonging together.

@codecov
Copy link

codecov bot commented Mar 20, 2019

Codecov Report

Merging #3355 into master will decrease coverage by 7.59%.
The diff coverage is 61.36%.

@@            Coverage Diff             @@
##           master    #3355      +/-   ##
==========================================
- Coverage   84.63%   77.03%    -7.6%     
==========================================
  Files         698      690       -8     
  Lines      345553   341652    -3901     
==========================================
- Hits       292442   263176   -29266     
- Misses      53111    78476   +25365
Impacted Files Coverage Δ
lib/package.gi 74.58% <61.36%> (-0.83%) ⬇️
lib/teachm2.g 15.38% <0%> (-84.62%) ⬇️
lib/proto.gi 1.03% <0%> (-82.48%) ⬇️
lib/ctbllatt.gi 0.81% <0%> (-79.99%) ⬇️
lib/algliess.gi 0.99% <0%> (-74.54%) ⬇️
lib/attr.gi 27.27% <0%> (-72.73%) ⬇️
lib/ctblpope.gi 1.77% <0%> (-72.39%) ⬇️
lib/contfrac.gi 30% <0%> (-67.15%) ⬇️
src/saveload.c 3.26% <0%> (-64.95%) ⬇️
lib/teaching.g 19.66% <0%> (-63.6%) ⬇️
... and 246 more

@wucas
Copy link
Contributor Author

wucas commented Mar 20, 2019

The test in tst/testinstall/package.tst failed because the validity check of the date outputs something if the date is invalid and because the output of the format check also has a different output now. I changed this in the test file. The tests run on my computer now.

@coveralls
Copy link

coveralls commented Mar 20, 2019

Coverage Status

Coverage decreased (-0.002%) to 84.369% when pulling a58cab8 on wucas:lw/allow-ISO8601-dates into 9112e3e on gap-system:master.

@DominikBernhardt DominikBernhardt added the kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements label Mar 21, 2019
tst/testinstall/package.tst Outdated Show resolved Hide resolved
lib/package.gi Show resolved Hide resolved
@wucas
Copy link
Contributor Author

wucas commented Mar 22, 2019

@alex-konovalov you're right I overlooked the issue with the ambiguity of the dd/mm/yyyy format. I added a Mandat in the CheckDateValidity function. That way seemed most easy to me and I think with the comment it is clear what the code is supposed to do. I return true if that's the case so the "invalid Date" message is not printed.
To make sure that this is caught in the future I added a test for this.

@olexandr-konovalov
Copy link
Member

olexandr-konovalov commented Mar 22, 2019

It just occurred to me that this PR will not fully resolve the problem. In fact, it could even make it more difficult. If PackageInfo.g files with dates in both formats will pass validation, we will eventually have a mix of two different formats in GAPInfo.PackagesInfo, and any tool that accesses dates from these records for some purposes (report, generated content etc). will have to adapt to handle two formats (for example, the "healthcheck" report, see gap-system/gap-distribution#49).

So, I suggest that in addition to adjusting validation we should also change SetPackageInfo so that when loading package metadata it will convert all dates to ISO 8601, and will possibly accept dd/mm/yyyy dates forever for backwards compatibility.

@fingolfin
Copy link
Member

Yes, please make sure that after loading, dates are in a uniform format. I'd indeed prefer ISO 8601 for that in the long run, but for the time being, we must make sure no tooling is broken. Right now, that might affect AutoDoc, which parses the Date for package manuals (see here and also the code for AUTODOC_FormatDate).

So perhaps it'd be better to "normalize" everything to the dd/mm/yyyy format; it'll then be trivial to switch over to the ISO format at any time, and also buys us time to adapt AutoDoc and whatever else might need it. And in case there is a problem, it is trivial to roll back, too.

@olexandr-konovalov
Copy link
Member

@fingolfin wrote

So perhaps it'd be better to "normalize" everything to the dd/mm/yyyy format;

Ok, I thought initially about more radical change and switch to ISO 8601 now, but OK, let's do it gradually - that will allow to make a small adjustment and merge this PR then.

@wucas
Copy link
Contributor Author

wucas commented Aug 17, 2019

@fingolfin I looked at this again since I'd like to finish this up during the GAP Days next week.
So the date is stored in date which is a list of the form [dd, mm, yyyy] so isn't it "normalized"? Of course this is not the date as it is in the PackageInfo.g so should I normalize it there? And if so how can I change this file? Or am I totally misunderstanding the situation?

@olexandr-konovalov
Copy link
Member

@wucas unless I miss something, I see only

Permuted(date, (1,3)); #sort such that date=[dd,mm,yyyy]

but then date is discarded. If you will inspect GAPInfo.PackagesInfo, it will still have a mix of formats - it's there where we would like to use a single format.

@wucas wucas added the release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes label Aug 20, 2019
@wucas
Copy link
Contributor Author

wucas commented Aug 20, 2019

I have added a normalization routine. As far as I can't tell now GAPInfo.PackagesInfo.pkgname[1].Date has the format "dd/mm/yyyy" even if in the respective PackageInfo.g the date has the format "yyyy-mm-dd". @alex-konovalov does this address @fingolfin s request?

@olexandr-konovalov olexandr-konovalov added this to the GAP 4.11.0 milestone Sep 5, 2019
@olexandr-konovalov
Copy link
Member

This would be good to have in 4.11.0 - added it to the milestone to ensure that its stays on the radar.

@DominikBernhardt
Copy link
Contributor

This was added to the 4.11 Milestone and @alex-konovalov requested changes. From what I understand @wucas changed code according to @wilfwilson requests. What is the status of this?

@olexandr-konovalov
Copy link
Member

This waits for me to review in conjunction with gap-system/gap-distribution#78

@olexandr-konovalov
Copy link
Member

Unfortunately, moving this to GAP 4.12 milestone.

@fingolfin
Copy link
Member

It's rather frustrating that @wucas opened this comparatively simple change request (which is by no means to belittle the effort it took to get there) over a year ago and it is still not merged, and now has a conflict, so a rebase is necessary. I don't understand why we can't merge this right away (or could have done so in September) -- adding the ability to GAP to load packages with ISO dates before teaching the website and package distribution about ISO dates seems perfectly reasonable to me, esp. as long as we don't accept such packages for distribution.

I will attempt to rebase this now, and I really hope we can then merge it ASAP. And perhaps next week the website counterpart can be taken care of. But even if not, I think we should just merge this!

@fingolfin
Copy link
Member

Just realized the PR is not over a year, but exactly one year old. Happy birthday then ;-). And I managed to rebase it, too.

@fingolfin
Copy link
Member

@alex-konovalov can we merge this now?

Copy link
Member

@olexandr-konovalov olexandr-konovalov left a comment

Choose a reason for hiding this comment

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

I have one comment and one bug report.

lib/package.gi Show resolved Hide resolved
@@ -213,7 +213,7 @@ end );
#F AddPackageInfo( files )
##
BindGlobal( "AddPackageInfos", function( files, pkgdir, ignore )
local file, record, pkgname, version;
local file, record, pkgname, version, date, dd, mm;
Copy link
Member

Choose a reason for hiding this comment

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

So, we call ValidatePackageInfo from LoadPackage but not from AddPackageInfos. I wonder if we should do that in AddPackageInfos too...

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps, but that goes beyond the purpose of this PR, doesn't it?

lib/package.gi Outdated Show resolved Hide resolved
If the date format is dd/mm/yyyy and InfoLevel InfoPackageLoading
is set to at least 2 it prints a hint to change the format.

Add validity check for dates

Add normalisation of date format to AddPackageInfos

Update relevant testfile

Fixes gap-system#2727
@fingolfin
Copy link
Member

I fixed one minor whitespace typo and rebased this PR to see whether the tests pass. I also dismissed @alex-konovalov "request for changes" review, as I believe I refuted his "bug report" and consider his "concern" a feature request that goes beyond this PR.

If I hear no new concerns about this PR, I'll merge it next week.

@olexandr-konovalov
Copy link
Member

Well, to do this properly, one should check:

As there is no pressing needs for this (except that this is one year old, and it would be nice to merge it), I don't plan to look at these before the middle of the next week...

@olexandr-konovalov olexandr-konovalov merged commit 5a6ed73 into gap-system:master Feb 20, 2021
@olexandr-konovalov
Copy link
Member

@wucas @fingolfin thanks & let's do it.

@wucas wucas deleted the lw/allow-ISO8601-dates branch February 28, 2021 15:58
@fingolfin fingolfin added release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: packages issues or PRs related to package handling, or specific to a package (for packages w/o issue tracker) and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 17, 2022
@fingolfin fingolfin changed the title Allow packages to use ISO 8601 dates in their PackageInfo.g Allow packages to use ISO 8601 dates in their PackageInfo.g files (so YYYY-MM-DD instead of DD/MM/YYYY) Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2019-spring Issues and PRs that arose at https://www.gapdays.de/gapdays2019-spring gapsingular2019 Issues and PRs that arose at https://opendreamkit.org/meetings/2019-04-02-GAPSingularMeeting kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: packages issues or PRs related to package handling, or specific to a package (for packages w/o issue tracker)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants