Skip to content

Commit 1ef20c3

Browse files
committed
Ref #numpygh-182, fixes #numpygh-217 review comments addressed
1 parent ad435b4 commit 1ef20c3

7 files changed

+115
-171
lines changed

scripts/fetch-ehtim.sh

-78
This file was deleted.

scripts/numpy-ehtim-dep-graph.sh

-90
This file was deleted.

scripts/pkgdepchart/README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Scripts used for generating numpy dependency charts for numpy.org
2+
3+
**Overview**
4+
5+
Here is how these scripts are organized:
6+
7+
* Top level script: redraw-numpy-dep-charts.sh
8+
* Helper scripts that are used by redraw-numpy-dep-charts.sh and should be run in the suggested order below:
9+
10+
1. fetch-numpydeppkg.sh
11+
2. gen-numpy-dep-graph.sh
12+
3. cleanup-numpydeppkg.sh
13+
14+
If you run the helper scripts, make sure you run them in this order to generate graphs in specified output directory.
15+
16+
Usage details of each script are listed in the section below.
17+
18+
## Script: redraw-numpy-dep-charts.sh
19+
20+
### Use Case:
21+
22+
NumPy case studies refers to ehtim, gwpy and PyCBC packages. For each of these, we have created NumPy dependency graphs. You can redraw all these three graphs in one go (obtain 3 png files) in the specified output directory. If you wish to add a new package and also refresh existing charts, you can edit the script and update three arrays:
23+
24+
* pkgarray: List of packages for which numpy dependency chart is to be generated
25+
* pkgurl: List of github urls from where pkg sources can be git cloned
26+
* pkgsetup: Dirname (not path) of the top level dir in pkg source that contains
27+
requirements.txt file used to pip install the package in a virtualenv.
28+
The package is uninstalled as part of cleanup after graphs is generated.
29+
30+
31+
#### Usage
32+
33+
redraw-numpy-dep-charts.sh outputdir
34+
35+
The output directory is an optional parameter.
36+
If no output directory is specified, the graphs (.png files) of all the packages
37+
listed in pkgarray variable are generated in the current directory from where
38+
the script is run.
39+
40+
Pre-requisites: The following software packages must be installed on the system where you are running this bash script: git, python3, pip3, virtualenv.
41+
42+
----
43+
44+
## Script: fetch-numpydeppkg.sh
45+
46+
### Use Case:
47+
48+
This script is one of the helper scripts used by redraw-numpy-dep-charts.sh script. Its sole purpose is to download the package for which numpy dependency graph is to be generated and install it in a virtual environment, setup the directory structure which can be used by other helper script gen-numpy-dep-graph.sh to generate the graph. This script is paired with cleanup-numpydeppkg.sh script for uninstalling and removing scratch data.
49+
50+
#### Usage
51+
52+
fetch-numpydeppkg.sh package_name scratchdir git_url reqfile_parentdir
53+
54+
package_name: Name of the package (as in pip registry) that will be fetched
55+
scratchdir: local directory where the package contents will be fetched.
56+
git_url: Full git url required for git cloning.
57+
reqfile_parentdir: This is the name (not path) of the root directory of package that contains requirements.txt file
58+
59+
----
60+
61+
## Script: gen-numpy-dep-graph.sh
62+
63+
### Use Case:
64+
65+
This is a helper script used by redraw-numpy-dep-charts.sh script. Its sole
66+
purpose is to use the pre-installed pkg in a local virtual environment by
67+
the script fetch-numpydeppkg.sh (or manually installed locally) and use them
68+
to run graphviz, dot and other utilities for creating NumPy dependency chart
69+
as png files for the pkg. It assumes that packages is pre-installed and does
70+
not clean up any pre-installed packages. In case a user has the package pre-installed and would like to simply generate NumPy dependency chart, this script can be used.
71+
72+
#### Usage:
73+
74+
gen-numpy-dep-graph.sh package_name scratchdir output_graphdir highlight_color (optional)
75+
76+
package_name: Name of the package (as in pip registry) for which NumPy dependency
77+
graph is to be generated.
78+
scratchdir: local directory where the package contents reside, the same directory as input to the fetch-numpydeppkg.sh where package_name was fetched by that script.
79+
output_graphdir: directory pathname where generated graphs in png format will be
80+
stored.
81+
highlight_color: color understood by dot language. Default is cyan. Other acceptable colors are red, blue. For a complete list see https://www.graphviz.org/doc/info/lang.html and https://www.graphviz.org/doc/info/colors.html
82+
83+
Pre-requisite: Please note, gen-numpy-dep-graph needs the virtualenv directory that was activated and used for package deployment a priori say by fetch-numpydeppkg.sh script or manually by user. It is assumed that the scratchdir comprises of two top level directories - virtualenv dir and another dir with package_name sources that are git cloned or a local copy of the same.
84+
85+
----
86+
87+
##Script: cleanup-numpydeppkg.sh
88+
89+
### Use Case:
90+
91+
This is a helper script used by redraw-numpy-dep-charts.sh script. Its sole
92+
purpose is to cleanup all the packages that were installed by fetch-numpydeppkg.sh script executed prior to running cleanup script. It also removes the scratch
93+
directory contents related to virtualenv setup and package sources that were
94+
installed by fetch-numpydeppkg.sh script. If you have not used fetch-numpydeppkg
95+
script then you do not need to run the cleanup script.
96+
97+
#### Usage:
98+
99+
*package_name:* Name of the package (as in pip registry) that will be uninstalled.
100+
*scratchdir:* local directory where the package contents were earlier fetched by
101+
fetch-numpydeppkg.sh script.
102+
*reqfile_parentdir:* This is the name (not path) of the root directory of package that contains requirements.txt file. This is needed to uninstall all package
103+
dependencies that were installed as part of fetching and setting up of pacakge
104+
by fetch-numpydeppkg.sh script.
105+
106+

scripts/cleanup-numpydeppkg.sh renamed to scripts/pkgdepchart/cleanup-numpydeppkg.sh

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ cleanup_pkg() {
3030

3131
$workingdir/env-${pkgname}/bin/pip3 uninstall -y -r $workingdir/numpy_${pkgname}_dep/$setupdir/requirements.txt
3232

33+
\rm -rf $workingdir/env-${pkgname}
34+
\rm -rf $workingdir/numpy_${pkgname}_dep
35+
3336
return 0
3437
}
3538

scripts/redraw-numpy-dep-charts.sh renamed to scripts/pkgdepchart/redraw-numpy-dep-charts.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
set -ue
77

8+
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9+
810
curdir=`pwd`
911
outputdir=$curdir
1012

@@ -40,6 +42,7 @@ declare -a pkgurl=("https://github.com/achael/eht-imaging.git"
4042
"https://github.com/gwpy/gwpy.git"
4143
"https://github.com/gwastro/pycbc.git")
4244
declare -a pkgsetup=("eht-imaging" "gwpy" "pycbc")
45+
4346
highlightcolor="cyan"
4447

4548
#numpkg=${#pkgarray[@]}
@@ -52,8 +55,8 @@ do
5255
echo "and using $workingdir as scratch"
5356

5457
mkdir $workingdir/${pkgarray[$index]} $workingdir/${pkgarray[$index]}/graphdir
55-
./scripts/fetch-numpydeppkg.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} ${pkgurl[$index]} ${pkgsetup[$index]}
56-
./scripts/gen-numpy-dep-graph.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} $workingdir/${pkgarray[$index]}/numpy_${pkgarray[$index]}_dep/${pkgsetup[$index]} $workingdir/${pkgarray[$index]}/graphdir/ $highlightcolor
58+
${scriptdir}/fetch-numpydeppkg.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} ${pkgurl[$index]} ${pkgsetup[$index]}
59+
${scriptdir}/gen-numpy-dep-graph.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} $workingdir/${pkgarray[$index]}/numpy_${pkgarray[$index]}_dep/${pkgsetup[$index]} $workingdir/${pkgarray[$index]}/graphdir/ $highlightcolor
5760
if ! [ -f $workingdir/${pkgarray[$index]}/graphdir/numpy-clean-color.png ]
5861
then
5962
echo "Error: Graph for ${pkgarray[$index]} failed! Exiting."
@@ -66,7 +69,7 @@ done
6669
for index in "${!pkgarray[@]}" ;
6770
do
6871
echo "Uninstalling ${pkgarray[$index]}....."
69-
./scripts/cleanup-numpydeppkg.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} ${pkgsetup[$index]}
72+
${scriptdir}/cleanup-numpydeppkg.sh ${pkgarray[$index]} $workingdir/${pkgarray[$index]} ${pkgsetup[$index]}
7073
done
7174

7275
echo "Cleaning up scratch dir: $workingdir..........."

0 commit comments

Comments
 (0)