Skip to content

Commit 140823a

Browse files
committed
Ref #numpygh-182, fixes #numpygh-217 review comments addressed
Cleanup of README, 80char line Cleanup of README, 80char line
1 parent ba28327 commit 140823a

7 files changed

+147
-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

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

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)