Addon Manager: Getting the last update time
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Addon Manager: Getting the last update time
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...
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...
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Addon Manager: Getting the last update time
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>
Re: Addon Manager: Getting the last update time
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.
-
- Posts: 98
- Joined: Fri Oct 09, 2020 4:56 pm
- Location: Oregon, USA
Re: Addon Manager: Getting the last update time
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.
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.
Re: Addon Manager: Getting the last update time
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.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?
Re: Addon Manager: Getting the last update time
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 ?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>
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.
Re: Addon Manager: Getting the last update time
IMO better use ISO-8601 formatting : 2022-01-17TheMarkster 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>
Re: Addon Manager: Getting the last update time
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)
Re: Addon Manager: Getting the last update time
I've added Date to the standard, you can use either dashes or dots, as you prefer.
Re: Addon Manager: Getting the last update time
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):chennes wrote: ↑Mon Jan 17, 2022 1:41 pmCode: Select all
import FreeCAD xml_file = # Put the path to you package.xml file here metadata = FreeCAD.Metadata(xml_file)
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)