|
| 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. |
0 commit comments