pack_dnloads.pl

 pack_dnloads(Opts)
Plot and track the number of downloads of a bunch of packs.

The script has three main functionalities with regard to a number of target packs: (a) barplot the current number of downloads, (b) add the number of current downloads to a dated tracker file, and (c) plot the information in tracker files.

Opts

append_profile(AppP=true)
set to false if you do not want user_profile(stoics/options/pack_dnloads.pl) to provide extra options (see options_append/4)
debug(Dbg=true)
see options_append/4
mode(Mode=current)
one of current, update and tracked. See section Modes below.
pack(Pack)
multiple can be given
plot_all(Pall=true)
in Mode=tracked, plots all packs in tracker. When Pall=false, only plot those in pack/1 options (and profile depending on AppP).
stem_tracked(StemTrc=false)
stem for when Mode=tracked, by default (StemTrc=false), stem is taken by basename of TrackerF
stem(Stem=pack_dnloads)
stem to use for output file when Mode=current
tracker(TrackerF=user_app_data(stoics/pack_dnloads/pack_dnloads_tracker.sv))
Tracking file- passed through absolute_file_name/2

Modes

_current_
plots static bars for each provided pack
_update_
adds a new line to TrackerF which for current date gives frequencies of tracked packs
_tracked_
plots contents of TrackerF
% Plot the current number of downloads for packs: bims, prosqlite and real

?- [pack('b_real/scripts/pack_dnloads')].
?- pack_dnloads([pack(bims),pack(prosqlite),pack(real)]).
% produces file: 21.09.01-pack_downloads.pdf

% The line below is equivalent to the call above, but ran from linux command line via pack(upsh)
> upsh pack_dnloads pack=bims pack=prosqlite pack=real

% You can put your packs of interest (and other options) to file user_profile(stoics/options/pack_dnloads.pl)
%  - see options_append/4
% eg file:
pack(bims).
pack(prosqlite).
pack(real).

% then the first example can be reduced to:
?- pack_dnloads([]).

% The following ignores any info in user_profile(stoics/options/pack_dnloads.pl)
?-  pack_dnloads([pack(bims),pack(prosqlite),pack(stoics_lib),append_profile(false)]).

Update mode

?- pack_dnloads(mode(update)).
% Using tracker file: '/home/nicos/.local/share/swi-prolog/stoics/pack_dnloads/pack_dnloads_tracker.csv'
% Frequencies: [b_real-35,bims-63,bio_analytics-17,bio_db-77,bio_db_repo-48,by_unix-69,chess_db-34,db_facts-192,debug_call-49,disp_bn-2,gbn-3,lib-33,mlu-61,mtx-41,options-86,os_lib-78,pack_errors-80,pepl-25,pfd_meta-11,prosqlite-655,pub_graph-12,pubmed-35,r_session-16,real-527,spuds-32,stoics_lib-69,svg-3,upsh-21,wgraph-64]
true.

?- pack_dnloads(mode(update)).
% Using tracker file: '/home/nicos/.local/share/swi-prolog/stoics/pack_dnloads/pack_dnloads_tracker.csv'
% Frequencies: [b_real-35,bims-63,bio_analytics-17,bio_db-77,bio_db_repo-48,by_unix-69,chess_db-34,db_facts-192,debug_call-49,disp_bn-2,gbn-3,lib-33,mlu-61,mtx-41,options-86,os_lib-78,pack_errors-80,pepl-25,pfd_meta-11,prosqlite-655,pub_graph-12,pubmed-35,r_session-16,real-527,spuds-32,stoics_lib-69,svg-3,upsh-21,wgraph-64]
% Current date existed: 21.09.01, so replacing it.
true.

> cat /home/nicos/.local/share/swi-prolog/stoics/pack_dnloads/pack_dnloads_tracker.csv
,b_real,bims,bio_analytics,bio_db,bio_db_repo,by_unix,chess_db,db_facts,debug_call,disp_bn,gbn,lib,mlu,mtx,options,os_lib,pack_errors,pepl,pfd_meta,prosqlite,pub_graph,pubmed,r_session,real,spuds,stoics_lib,svg,upsh,wgraph
21.09.01,35,63,17,77,48,69,34,192,49,2,3,33,61,41,86,78,80,25,11,655,12,35,16,527,32,69,3,21,64

You can keep a number of tracker files

> upsh pack_dnloads.pl mode=update tracker=user_app_data=stoics/pack_dnloads/pack_dnloads_daily.csv

These can be kept updated via cron jobs. An example bash script can be found at b_real/scripts/pack_dnloads/pack_dnloads.sh

Finally, tracked mode produces a plot (on screen and saved on file), from a tracker file. Assuming your tracker file has more than one tracking line, eg:


> cat .local/share/swi-prolog/stoics/pack_dnloads/pack_dnloads_tracker.csv
date,b_real,bims,bio_analytics,bio_db,bio_db_repo,by_unix,chess_db,db_facts,debug_call,disp_bn,gbn,lib,mlu,mtx,options,os_lib,pack_errors,pepl,pfd_meta,prosqlite,pub_graph,pubmed,r_session,real,spuds,stoics_lib,svg,upsh,wgraph
,b_real,bims,bio_analytics,bio_db,bio_db_repo,by_unix,chess_db,db_facts,debug_call,disp_bn,gbn,lib,mlu,mtx,options,os_lib,pack_errors,pepl,pfd_meta,prosqlite,pub_graph,pubmed,r_session,real,spuds,stoics_lib,svg,upsh,wgraph
21.09.01,35,63,17,77,48,69,34,192,49,2,3,33,61,41,86,78,80,25,11,655,12,35,16,527,32,69,3,21,64
21.09.02,37,64,20,87,50,70,44,210,69,8,6,43,69,43,96,92,83,28,18,755,15,45,19,547,38,77,8,27,69

?-  pack_dnloads(mode(tracked)).
?-  pack_dnloads([mode(tracked),pack(bims),pack(prosqlite),pack(real),append_profile(false)]).

To plot only specific packs from a tracker file, while ignoring any packs defined in profile file (user_profile(stoics/options/pack_dnloads.pl)), use:

?- pack_dnloads( [mode(tracked),pack(bims),pack(prosqlite),pack(real),append_profile(false),plot_all(false)] ).

Dependencies, stoics packs:

You only need to install pack(b_real), with

?- pack_install(b_real).

This will also install pack(lib) which is a registered dependency. The remaining packs will be installed interactively on first loading of library(b_real).

author
- nicos angelopoulos
version
- 0:1 2021/9/2
To be done
- date constraining and name altering goals
- per month/per week, yearly pre-canned plots