summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--topics/profiling_python_code.gmi22
-rw-r--r--topics/running_pudb_from_external_environment.gmi22
2 files changed, 44 insertions, 0 deletions
diff --git a/topics/profiling_python_code.gmi b/topics/profiling_python_code.gmi
new file mode 100644
index 0000000..d7f9ea0
--- /dev/null
+++ b/topics/profiling_python_code.gmi
@@ -0,0 +1,22 @@
+# Profiling Python code
+
+As part of improving the system, there is need to identify and fix/improve the performance bottlenecks in the code. This document details examples of how one would run various profilers, for both GeneNetwork2 and GeneNetwork3
+
+## GeneNetwork3
+
+### cProfile
+
+Syntax:
+
+* env [various-env-vars] python3 -m cProfile the-script.py
+
+where
+
+* `[various-env-vars]` is a number of environment variables that might be needed for the running of the script, e.g. `SQL_URI` which is used to define how to connect to the database.
+* `the-script.py` is the name of the python script to be run under the profiler
+
+The output can be redirected, e.g.
+
+* env [various-env-vars] python3 -m cProfile the-script.py 2>error.log 1>performance.log
+
+which should help will separating errors from the performance data, for easier analysis
diff --git a/topics/running_pudb_from_external_environment.gmi b/topics/running_pudb_from_external_environment.gmi
new file mode 100644
index 0000000..be9bf14
--- /dev/null
+++ b/topics/running_pudb_from_external_environment.gmi
@@ -0,0 +1,22 @@
+# Running pudb From an External Environment
+
+Currently (22nd December 2021), it is a tad difficult to get pudb running under the various guix environments without having to update a lot of stuff. This documents a workaround that seems to work for me (@fredm).
+
+## GeneNetwork3
+
+1) Install pudb in a virtual environment:
+
+* $ python -m venv pudb_env
+
+2) Activate the environment and install pudb:
+
+* $ source pudb_env/bin/activate
+* $ pip install pudb
+
+3) Run the GN3 container, exposing the new virtual environment with something like:
+
+* env GUIX_PACKAGE_PATH=~/genenetwork/guix-bioinformatics/ ~/.config/guix/current/bin/guix environment -C --network --expose="$HOME/genotype_files/"="${HOME}/genotype_files" --expose="${HOME}/genenetwork/pudb_env/"="${HOME}/pudb_env" --load=guix.scm
+
+4) Inside the container, run the debugger with something like:
+
+* env PYTHONPATH="${PYTHONPATH}:${HOME}/pudb_env/lib/python3.8/site-packages" ... python3 -m pudb script.py