Addon Manager: Getting the last update time

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3909
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Addon Manager: Getting the last update time

Post by chennes »

A feature I am hoping to add to the Addon Manager is the display of the last time an Addon was updated by its author. This is already implemented for macros (which usually contain embedded metadata in their source code so it was simple), but it would be really nice to show for workbenches as well. Then I can add a filter that only shows addons updated in the last N years, and that sort of thing. But of course there's a sticking point: how to get that information.

The two main options I was looking at were either to use the REST API of GitHub and GitLab to access the git log data for the last commit, or to use git log itself, directly: neither option actually works as well as I'd like, however, and I wonder if anyone can help me see an alternate path, either via another git function, other git options, or another way of getting the data entirely.

Option A: REST API. This is probably the cleanest option, and since all Addons are hosted on systems that use one of just two APIs (either the GitHub or the GitLab REST API), I'd only need two wrappers, and they are both pretty simple. The big problem here is rate limiting. For example, GitHub allows 60 unauthenticated requests per hour: a single refresh of the current Addon cache will basically use up this entire amount. For developers it's easy enough to allow you to log into GitHub and make an authenticated request, but that doesn't help those without GitHub accounts, and doesn't do anything at all for GitLab, which would need a separate login. Again, for devs this is work-aroundable, but for non-devs, I feel like the rate limiter is a significant problem.

Option B: git log. This seems like a great option, except it requires a clone of the repo to work, you can't do a "git log" on a remote unless you have a local clone. For most Addons this is probably not an issue, a sparse, shallow, bare checkout is quite small and fast. But then there is FreeCAD-library... which is ridiculously large. And I probably shouldn't count absolutely on other addons remaining small. I could add something like a timer that kills the download after ten seconds or something (I actually do that with the macro scanning code), but that's a little sketchy.

What other options can you think of? What do you think of these options? I'm open to any ideas you've got...
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Addon Manager: Getting the last update time

Post by TheMarkster »

Package.xml has to be updated with each new version anyway. Why not just add a date property? Should be of format 2022.01.07, I would think, but I suppose it could be parsed to find the 4-digit value is the year, and if the year is last then probably it's month.day.year format.

Code: Select all

<version>1.8918</version>
<date>2022.01.07</date>
User avatar
chennes
Veteran
Posts: 3909
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager: Getting the last update time

Post by chennes »

That's a workable option going forward, for Addons that are being actively maintained, but I think one purpose for this feature is to identify whether an unmaintained Addon has been inactive for a particularly long time, e.g.
Screenshot 2022-01-07 194045.png
Screenshot 2022-01-07 194045.png (89.75 KiB) Viewed 2841 times
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
LarryWoestman
Posts: 98
Joined: Fri Oct 09, 2020 4:56 pm
Location: Oregon, USA

Re: Addon Manager: Getting the last update time

Post by LarryWoestman »

Could you or another developer run a simple program that figures out the date of the last commit and records the date and commit id in a file at the root of each addon? Then the file can be downloaded instead of needing a REST call.

If that program could be re-run weekly or bi-weekly, it would probably be close enough to tell if any changes have been happening in the last month or so. It doesn't have to be more accurate than that.
User avatar
chennes
Veteran
Posts: 3909
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager: Getting the last update time

Post by chennes »

LarryWoestman wrote: Sat Jan 08, 2022 2:34 am Could you or another developer run a simple program that figures out the date of the last commit and records the date and commit id in a file at the root of each addon?
We can get halfway there: it would probably be feasible for us to have an automated process on our server that runs once per day, does the update time determinations, and caches that information in a file either on our server itself, or pushes it to GitHub (maybe in the Addons repo). I can talk to the folks who run the server about it. We can't really put those files in the root of each individual addon, since we don't control those.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Addon Manager: Getting the last update time

Post by Zolko »

TheMarkster wrote: Sat Jan 08, 2022 1:31 am Package.xml has to be updated with each new version anyway. Why not just add a date property?

Code: Select all

<version>1.8918</version>
<date>2022.01.07</date>
yes, I think that's a good way to go. Automagic things have a tendency to break in unsuspecting ways. Older packages won't have the data, but we're preparing for v0.20 anyway, aren't we ?

Now ... what is the good way to retrieve those infos (version and date) from Python ? I'd like to display them in the Help field of the WB.
try the Assembly4 workbench for FreCAD — tutorials here and here
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Addon Manager: Getting the last update time

Post by openBrain »

TheMarkster wrote: Sat Jan 08, 2022 1:31 am Package.xml has to be updated with each new version anyway. Why not just add a date property? Should be of format 2022.01.07, I would think, but I suppose it could be parsed to find the 4-digit value is the year, and if the year is last then probably it's month.day.year format.

Code: Select all

<version>1.8918</version>
<date>2022.01.07</date>
IMO better use ISO-8601 formatting : 2022-01-17 ;)
User avatar
chennes
Veteran
Posts: 3909
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager: Getting the last update time

Post by chennes »

Zolko wrote: Mon Jan 17, 2022 9:45 am Now ... what is the good way to retrieve those infos (version and date) from Python ? I'd like to display them in the Help field of the WB.

Code: Select all

import FreeCAD
xml_file = # Put the path to you package.xml file here
metadata = FreeCAD.Metadata(xml_file)
print (metadata.Date)
print (metadata.Version)
etc.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3909
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager: Getting the last update time

Post by chennes »

openBrain wrote: Mon Jan 17, 2022 1:39 pm IMO better use ISO-8601 formatting : 2022-01-17 ;)
I've added Date to the standard, you can use either dashes or dots, as you prefer.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Addon Manager: Getting the last update time

Post by Zolko »

chennes wrote: Mon Jan 17, 2022 1:41 pm
Zolko wrote: Mon Jan 17, 2022 9:45 am Now ... what is the good way to retrieve those infos (version and date) from Python ? I'd like to display them in the Help field of the WB.

Code: Select all

import FreeCAD
xml_file = # Put the path to you package.xml file here
metadata = FreeCAD.Metadata(xml_file)
unfortunately, the metadata only contains the fields Name, Description, Maintainer. No date (or Date), version, license ... This with latest GitHub compiled from source, and I checked that it's reading the correct file (by changing the description field):


OS: Debian GNU/Linux 10 (buster) (KDE//usr/share/xsessions/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.27049 (Git)
Build type: Unknown
Branch: master
Hash: 74fe1fa4db96ce9ba63a156515ddf816117c7a6e
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
try the Assembly4 workbench for FreCAD — tutorials here and here
Post Reply