diff --git a/.github/workflows/test-colab.yml b/.github/workflows/test-colab.yml index 32b36dce4..c7d27feae 100644 --- a/.github/workflows/test-colab.yml +++ b/.github/workflows/test-colab.yml @@ -24,7 +24,6 @@ jobs: source activate conda init conda install google-colab -c conda-forge - pip install pandas jupyter --version - name: Test Google Colab Notebook with CLI shell commands diff --git a/notebooks/output-python-api.ipynb b/notebooks/output-python-api.ipynb new file mode 100644 index 000000000..8ab48687b --- /dev/null +++ b/notebooks/output-python-api.ipynb @@ -0,0 +1,226 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "execution": { + "iopub.execute_input": "2023-12-19T10:09:00.078522Z", + "iopub.status.busy": "2023-12-19T10:09:00.078256Z", + "iopub.status.idle": "2023-12-19T10:09:18.851451Z", + "shell.execute_reply": "2023-12-19T10:09:18.849379Z" + }, + "id": "tK-9NmDan9_r" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "env: MINICONDA_INSTALLER_SCRIPT=Miniconda3-py37_4.12.0-Linux-x86_64.sh\n", + "env: MINICONDA_PREFIX=/usr/local\n", + "env: PYTHONPATH=\"$PYTHONPATH:/usr/local/lib/python3.7/site-packages\"\n", + "env: PIP_ROOT_USER_ACTION=ignore\n", + "--2023-12-19 11:09:00-- https://repo.anaconda.com/miniconda/Miniconda3-py37_4.12.0-Linux-x86_64.sh\r\n", + "Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.131.3, 104.16.130.3, 2606:4700::6810:8303, ...\r\n", + "Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.\r\n", + "HTTP request sent, awaiting response... 200 OK\r\n", + "Length: 104996770 (100M) [application/x-sh]\r\n", + "Saving to: ‘Miniconda3-py37_4.12.0-Linux-x86_64.sh’\r\n", + "\r\n", + "Miniconda3-py37_4.1 100%[===================>] 100,13M 8,87MB/s in 12s \r\n", + "\r\n", + "2023-12-19 11:09:12 (8,53 MB/s) - ‘Miniconda3-py37_4.12.0-Linux-x86_64.sh’ saved [104996770/104996770]\r\n", + "\r\n", + "PREFIX=/usr/local\r\n", + "./Miniconda3-py37_4.12.0-Linux-x86_64.sh: 396: cannot create /usr/local/conda.exe: Permission denied\r\n", + "chmod: cannot access '/usr/local/conda.exe': No such file or directory\r\n", + "Unpacking payload ...\r\n", + "./Miniconda3-py37_4.12.0-Linux-x86_64.sh: 412: /usr/local/conda.exe: not found\r\n", + "./Miniconda3-py37_4.12.0-Linux-x86_64.sh: 414: /usr/local/conda.exe: not found\r\n", + "Collecting git+https://github.com/ersilia-os/ersilia.git\r\n", + " Cloning https://github.com/ersilia-os/ersilia.git to /tmp/pip-req-build-enbhpjsb\r\n", + " Running command git clone --filter=blob:none --quiet https://github.com/ersilia-os/ersilia.git /tmp/pip-req-build-enbhpjsb\r\n", + " Resolved https://github.com/ersilia-os/ersilia.git to commit 911528b1d17a68bbe3f18a952ddcac865833c416\r\n", + " Installing build dependencies ... \u001b[?25l-\b \b\\\b \b|\b \bdone\r\n", + "\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\r\n", + "\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\r\n", + "\u001b[?25hRequirement already satisfied: PyYAML<7.0.0,>=6.0.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (6.0.1)\r\n", + "Requirement already satisfied: boto3<2.0.0,>=1.28.40 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (1.28.50)\r\n", + "Requirement already satisfied: click<9.0.0,>=8.1.7 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (8.1.7)\r\n", + "Requirement already satisfied: docker<7.0.0,>=6.1.3 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (6.1.3)\r\n", + "Requirement already satisfied: dockerfile-parse<3.0.0,>=2.0.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (2.0.1)\r\n", + "Requirement already satisfied: emoji<3.0.0,>=2.8.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (2.8.0)\r\n", + "Requirement already satisfied: h5py<4.0.0,>=3.7.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (3.9.0)\r\n", + "Requirement already satisfied: inputimeout<2.0.0,>=1.0.4 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (1.0.4)\r\n", + "Requirement already satisfied: loguru<0.7.0,>=0.6.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (0.6.0)\r\n", + "Requirement already satisfied: pyairtable<3 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (1.5.0)\r\n", + "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (4.66.1)\r\n", + "Requirement already satisfied: validators<0.22.0,>=0.21.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from ersilia==0.1.29) (0.21.2)\r\n", + "Requirement already satisfied: botocore<1.32.0,>=1.31.50 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from boto3<2.0.0,>=1.28.40->ersilia==0.1.29) (1.31.50)\r\n", + "Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from boto3<2.0.0,>=1.28.40->ersilia==0.1.29) (1.0.1)\r\n", + "Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from boto3<2.0.0,>=1.28.40->ersilia==0.1.29) (0.6.2)\r\n", + "Requirement already satisfied: packaging>=14.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from docker<7.0.0,>=6.1.3->ersilia==0.1.29) (23.1)\r\n", + "Requirement already satisfied: requests>=2.26.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from docker<7.0.0,>=6.1.3->ersilia==0.1.29) (2.31.0)\r\n", + "Requirement already satisfied: urllib3>=1.26.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from docker<7.0.0,>=6.1.3->ersilia==0.1.29) (1.26.16)\r\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from docker<7.0.0,>=6.1.3->ersilia==0.1.29) (1.6.3)\r\n", + "Requirement already satisfied: numpy>=1.17.3 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from h5py<4.0.0,>=3.7.0->ersilia==0.1.29) (1.26.0)\r\n", + "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from botocore<1.32.0,>=1.31.50->boto3<2.0.0,>=1.28.40->ersilia==0.1.29) (2.8.2)\r\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests>=2.26.0->docker<7.0.0,>=6.1.3->ersilia==0.1.29) (3.2.0)\r\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests>=2.26.0->docker<7.0.0,>=6.1.3->ersilia==0.1.29) (3.4)\r\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests>=2.26.0->docker<7.0.0,>=6.1.3->ersilia==0.1.29) (2023.7.22)\r\n", + "Requirement already satisfied: six>=1.5 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.32.0,>=1.31.50->boto3<2.0.0,>=1.28.40->ersilia==0.1.29) (1.16.0)\r\n", + "Requirement already satisfied: requests in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (2.31.0)\r\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests) (3.2.0)\r\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests) (3.4)\r\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests) (1.26.16)\r\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/gturon/miniconda3/envs/ersilia/lib/python3.10/site-packages (from requests) (2023.7.22)\r\n" + ] + } + ], + "source": [ + "%env MINICONDA_INSTALLER_SCRIPT=Miniconda3-py37_4.12.0-Linux-x86_64.sh\n", + "%env MINICONDA_PREFIX=/usr/local\n", + "%env PYTHONPATH= \"$PYTHONPATH:/usr/local/lib/python3.7/site-packages\"\n", + "%env PIP_ROOT_USER_ACTION=ignore\n", + "\n", + "!wget https://repo.anaconda.com/miniconda/$MINICONDA_INSTALLER_SCRIPT\n", + "!chmod +x $MINICONDA_INSTALLER_SCRIPT\n", + "!./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX\n", + "\n", + "!python -m pip install git+https://github.com/ersilia-os/ersilia.git\n", + "!python -m pip install requests --upgrade\n", + "!python -m pip install pandas\n", + "!rm $MINICONDA_INSTALLER_SCRIPT\n", + "import sys\n", + "\n", + "_ = sys.path.append(\"/usr/local/lib/python3.7/site-packages\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "execution": { + "iopub.execute_input": "2023-12-19T10:09:18.855989Z", + "iopub.status.busy": "2023-12-19T10:09:18.855723Z", + "iopub.status.idle": "2023-12-19T10:24:30.011293Z", + "shell.execute_reply": "2023-12-19T10:24:30.010724Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requested model eos4e41 is not available locally. Do you want to fetch it? [Y/n]🚀 Serving model eos4e41: chemprop-antibiotic-lite\n", + "\n", + " URL: http://0.0.0.0:52243\n", + " PID: -1\n", + " SRV: pulled_docker\n", + "\n", + "👉 To run model:\n", + " - run\n", + "\n", + " These APIs are also valid:\n", + " - predict\n", + "\n", + "💁 Information:\n", + " - info\n", + "⛔ Model eos4e41 closed\n" + ] + } + ], + "source": [ + "from ersilia import ErsiliaModel\n", + "\n", + "em = ErsiliaModel(\"chemprop-antibiotic-lite\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "execution": { + "iopub.execute_input": "2023-12-19T10:24:30.013598Z", + "iopub.status.busy": "2023-12-19T10:24:30.013331Z", + "iopub.status.idle": "2023-12-19T10:24:50.154576Z", + "shell.execute_reply": "2023-12-19T10:24:50.153277Z" + } + }, + "outputs": [], + "source": [ + "smiles = [\n", + " \"CC1C2C(CC3(C=CC(=O)C(=C3C2OC1=O)C)C)O\",\n", + " \"C1=CN=CC=C1C(=O)NN\",\n", + " \"CC(CN1C=NC2=C(N=CN=C21)N)OCP(=O)(O)O\",\n", + " \"CC(=O)OC1=CC=CC=C1C(=O)O\",\n", + " \"CC(C)CC1=CC=C(C=C1)C(C)C(=O)O\",\n", + " \"CC1(OC2C(OC(C2O1)(C#N)C3=CC=C4N3N=CN=C4N)CO)C\",\n", + " \"COC1=CC23CCCN2CCC4=CC5=C(C=C4C3C1O)OCO5\",\n", + "]\n", + "\n", + "em.serve()\n", + "data = em.run(smiles, output=\"pandas\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "execution": { + "iopub.execute_input": "2023-12-19T10:24:50.160737Z", + "iopub.status.busy": "2023-12-19T10:24:50.160410Z", + "iopub.status.idle": "2023-12-19T10:24:50.166888Z", + "shell.execute_reply": "2023-12-19T10:24:50.166129Z" + } + }, + "outputs": [], + "source": [ + "data.to_csv(\"output-python-api.csv\", index=False)" + ] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyN10gxVjdZEkUFNqJRGD4EG", + "include_colab_link": true, + "provenance": [] + }, + "kernelspec": { + "display_name": "ersilia", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" + }, + "vscode": { + "interpreter": { + "hash": "f4425e10f64e35b5c2846e94987c1961ae0dce9f7acb7463ce8901870868cb33" + } + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}