Commit 8b36691f authored by Vaclav Hanzl's avatar Vaclav Hanzl
Browse files

Improve notebook: Automate tracking of the python version in Colab

parent feb99932
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
"#@markdown **Note**: This installs the software on the Colab \n", "#@markdown **Note**: This installs the software on the Colab \n",
"#@markdown notebook in the cloud and not on your computer.\n", "#@markdown notebook in the cloud and not on your computer.\n",
"\n", "\n",
"import sys\n",
"from IPython.utils import io\n", "from IPython.utils import io\n",
"import os\n", "import os\n",
"import subprocess\n", "import subprocess\n",
...@@ -104,6 +105,8 @@ ...@@ -104,6 +105,8 @@
"\n", "\n",
"TQDM_BAR_FORMAT = '{l_bar}{bar}| {n_fmt}/{total_fmt} [elapsed: {elapsed} remaining: {remaining}]'\n", "TQDM_BAR_FORMAT = '{l_bar}{bar}| {n_fmt}/{total_fmt} [elapsed: {elapsed} remaining: {remaining}]'\n",
"\n", "\n",
"python_version = '.'.join(sys.version.split('.')[:2]) # get string like \"3.9\"\n",
"\n",
"try:\n", "try:\n",
" with io.capture_output() as captured:\n", " with io.capture_output() as captured:\n",
" %shell sudo apt install --quiet --yes hmmer\n", " %shell sudo apt install --quiet --yes hmmer\n",
...@@ -125,7 +128,7 @@ ...@@ -125,7 +128,7 @@
" %shell conda install -y -q -c conda-forge -c bioconda \\\n", " %shell conda install -y -q -c conda-forge -c bioconda \\\n",
" kalign2=2.04 \\\n", " kalign2=2.04 \\\n",
" hhsuite=3.3.0 \\\n", " hhsuite=3.3.0 \\\n",
" python=3.9 \\\n", " python={python_version} \\\n",
" 2>&1 1>/dev/null\n", " 2>&1 1>/dev/null\n",
" %shell pip install -q \\\n", " %shell pip install -q \\\n",
" ml-collections==0.1.0 \\\n", " ml-collections==0.1.0 \\\n",
...@@ -184,7 +187,7 @@ ...@@ -184,7 +187,7 @@
"\n", "\n",
" %shell conda install -y -q -c conda-forge openmm=7.5.1\n", " %shell conda install -y -q -c conda-forge openmm=7.5.1\n",
" # Apply OpenMM patch.\n", " # Apply OpenMM patch.\n",
" %shell pushd /opt/conda/lib/python3.9/site-packages/ && \\\n", " %shell pushd /opt/conda/lib/python{python_version}/site-packages/ && \\\n",
" patch -p0 < /content/openfold/lib/openmm.patch && \\\n", " patch -p0 < /content/openfold/lib/openmm.patch && \\\n",
" popd\n", " popd\n",
" %shell conda install -y -q -c conda-forge pdbfixer=1.7\n", " %shell conda install -y -q -c conda-forge pdbfixer=1.7\n",
...@@ -221,8 +224,8 @@ ...@@ -221,8 +224,8 @@
"import unittest.mock\n", "import unittest.mock\n",
"import sys\n", "import sys\n",
"\n", "\n",
"sys.path.insert(0, '/usr/local/lib/python3.9/site-packages/')\n", "sys.path.insert(0, f'/usr/local/lib/python{python_version}/site-packages/')\n",
"sys.path.append('/opt/conda/lib/python3.9/site-packages')\n", "sys.path.append(f'/opt/conda/lib/python{python_version}/site-packages')\n",
"\n", "\n",
"# Allows us to skip installing these packages\n", "# Allows us to skip installing these packages\n",
"unnecessary_modules = [\n", "unnecessary_modules = [\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment