Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

feat: e2e test, build: update tools cicd #22

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c50176e
refactor:ut by module
dp-yuanyn Feb 16, 2024
4b887b5
rm old ut
dp-yuanyn Feb 16, 2024
9105373
refactor:use pytest syntex for ut
dp-yuanyn Feb 17, 2024
b74f2b2
fix:ut
YNYuan Feb 18, 2024
ffa4a91
fix static type
YNYuan Feb 19, 2024
f0b9284
fix static type 2
YNYuan Feb 19, 2024
81513d3
fix static type 3
YNYuan Feb 19, 2024
7284eb5
build:base env dockerfile
YNYuan Feb 19, 2024
cbc400f
feat:add application e2e tests
YNYuan Feb 19, 2024
ef8fa46
fix:e2e tests
dp-yuanyn Feb 19, 2024
7c788b8
fix:app test read score
YNYuan Feb 19, 2024
1dcf29f
fix:app test
dp-yuanyn Feb 19, 2024
48fb9df
build:update unidocktools ci
YNYuan Feb 20, 2024
4e1c426
test:update tools ci trigger condition
YNYuan Feb 20, 2024
ee03ff3
build:fix tool yaml
YNYuan Feb 20, 2024
63901f7
build:fix ci yaml variable
YNYuan Feb 20, 2024
3af7376
build:fix build ninja dep
YNYuan Feb 20, 2024
7cc4f15
build:fix ninja dep
YNYuan Feb 20, 2024
8c8f8fa
test: ut unidock input change to 1iep
YNYuan Feb 20, 2024
262e0a9
test: skip ad4 test
YNYuan Feb 20, 2024
746e83c
build:change push image condition
YNYuan Feb 20, 2024
0d07060
feat(unidock):add energy_range arg
YNYuan Feb 20, 2024
97f8f3d
build:downgrade docker login action
YNYuan Feb 20, 2024
d590468
build:reupdate docker login action
YNYuan Feb 20, 2024
9ff2413
build:dockerhub token
dp-yuanyn Feb 20, 2024
e1dd16d
build:add checkout
dp-yuanyn Feb 20, 2024
82554f9
build:change docker login action version
YNYuan Feb 21, 2024
cea1434
build:change docker login action version 2
YNYuan Feb 21, 2024
38ab1a7
build:docker login action 3
YNYuan Feb 21, 2024
bac5bf0
build:docker build job
YNYuan Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 86 additions & 64 deletions .github/workflows/ci_tools.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
name: Uni-Dock Tools CI/CD
on:
push:
branches: []
pull_request:
branches: [ main ]

env:
PYTHON_VERSION: "3.11"

jobs:
flake8:
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
Expand All @@ -25,89 +27,109 @@ jobs:

- name: Run flake8 formating
run: |
flake8 unidock_tools/unidock_tools --exit-zero
flake8 unidock_tools/unidock_tools

pylint:
pyright:
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint

- name: Run pylint formating
run: |
pylint unidock_tools/unidock_tools --exit-zero

mypy:
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
pip install pyright

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy

- name: Run mypy check
id: mypy_check
- name: Run pyright check
id: pyright_check
working-directory: ./unidock_tools
run: |
mypy unidock_tools/unidock_tools --ignore-missing-imports
pyright

ut:
tests:
if: ${{ always() }}
needs: [flake8, pylint]
needs: [flake8,pyright]
runs-on: nvidia
strategy:
matrix:
python-version: ["3.9"]
cuda-version: ["12.0.0"]
container:
image: docker.io/dptechnology/unidock:latest
image: docker.io/xmyyn/unidock_tools_base:0.0.1_cuda${{ matrix.cuda-version }}
options: --gpus all
steps:
- name: checkout repo
uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}

- name: install dependency
- name: install unidock
working-directory: ./unidock
run: |
apt-get update && apt-get install -y ninja-build
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --install .
cd ..

- name: check env
run: |
conda create -n mgltools mgltools -c bioconda -y
conda install -n test -c conda-forge -y openbabel
conda run -n test pip install --upgrade pip
conda run -n test pip install pytest
unidock --version
confgen --version
which python

- name: install package
- name: install tools
working-directory: ./unidock_tools
run: |
export PATH=/__w/Uni-Dock/Uni-Dock/3/envs/test/bin:$PATH
conda run -n test python setup.py install
pip install .

- name: perform unit-test
- name: run unit-test
run: |
export PATH=/__w/Uni-Dock/Uni-Dock/3/envs/test/bin:$PATH
conda run -n test pytest unidock_tools/tests/ut -v
pip install pytest pytest-cov
pytest unidock_tools/tests/ut -vv --cov --cov-report term

- name: run application e2e test
run: |
pytest unidock_tools/tests/applications -vv --cov --cov-report term

build_docker_image:
needs: tests
runs-on: ubuntu-latest
strategy:
matrix:
cuda-version: ["12.0.0"]
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name == 'pull_request'
with:
username: dptechnology
password: ${{ secrets.DOCKERHUB_PAT }}

- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 7

- name: check commit short sha
run: echo ${{ steps.short-sha.outputs.sha }}

- name: build and push container
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
build-args: BASE_IMAGE=xmyyn/unidock_tools_base:0.0.1_cuda${{ matrix.cuda-version }}
tags: dptechnology/unidock_tools:${{ steps.short-sha.outputs.sha }},dptechnology/unidock_tools:latest
file: unidock_tools/containers/Dockerfile
push: ${{ github.event_name == 'pull_request' }}
16 changes: 9 additions & 7 deletions .github/workflows/ci_unidock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,20 @@ jobs:
needs: unidock_test
runs-on: ubuntu-latest
steps:

- name: log in to docker hub
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name == 'push'
if: github.event_name == 'pull_request'
with:
username: dptechnology
password: ${{ secrets.DOCKERHUB_PAT }}

- name: set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2

- uses: benjlevesque/[email protected]
id: short-sha
with:
Expand Down
30 changes: 0 additions & 30 deletions unidock_tools/Dockerfile

This file was deleted.

16 changes: 16 additions & 0 deletions unidock_tools/containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG BASE_IMAGE

FROM ${BASE_IMAGE}

COPY ./unidock /opt/unidock

RUN cd /opt/unidock && \
cmake -B build && \
cmake --build build -j`nprocs` && \
cmake --install build && \
rm -r /opt/unidock

COPY ./unidock_tools /opt/unidock_tools
RUN cd /opt/unidock_tools && \
pip install . && \
rm -r /opt/unidock_tools
37 changes: 37 additions & 0 deletions unidock_tools/containers/Dockerfile_base
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ARG CUDA_VERSION
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04

SHELL ["/bin/bash", "-c"]

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get clean && apt-get update \
&& apt-get install -y build-essential zip unzip vim git wget \
&& rm -rf /var/lib/apt/lists/*

RUN wget -O /tmp/conda.sh \
https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-23.11.0-0-Linux-$(uname -m).sh \
&& bash /tmp/conda.sh -b -p /opt/conda \
&& rm /tmp/conda.sh
ENV PATH /opt/conda/bin:$PATH

RUN mamba install -y cmake boost -c conda-forge

RUN mkdir /root/.ssh
RUN --mount=type=secret,id=rsa,target=/root/.ssh/id_rsa \
ssh-keyscan github.com >> /root/.ssh/known_hosts \
&& git clone [email protected]:molinfo-vienna/CDPKit.git /tmp/CDPKit

WORKDIR /tmp
RUN cd /tmp/CDPKit && mkdir build && cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/opt/CDPKit \
&& make -j4 && make install
RUN rm -rf /tmp/CDPKit
ENV PATH=/opt/CDPKit/Bin:$PATH
WORKDIR /opt

RUN mamba install -y ipython rdkit openbabel networkx numpy pandas -c conda-forge
RUN mamba create -y -n mgltools mgltools autogrid -c bioconda
ENV PATH $PATH:/opt/conda/envs/mgltools/bin
RUN pip install tqdm
RUN rm -rf /opt/conda/pkgs/*
17 changes: 16 additions & 1 deletion unidock_tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ classifiers = [
# "networkx",
#]

[tool.setuptools.packages.find]
exclude = ["containers"]

[tool.setuptools.package-data]
"*" = ["*.dat"]

Expand All @@ -36,4 +39,16 @@ Repository = "https://github.com/dptech-corp/Uni-Dock.git"
unidocktools = "unidock_tools.main:main_cli"

#[project.entry-points."unidocktools"]
#unidocktools = "unidock_tools.main:main_cli"
#unidocktools = "unidock_tools.main:main_cli"

[tool.pyright]
include = ["unidock_tools"]
exclude = ["**/node_modules",
"**/__pycache__",
"unidock_tools/data"
]
reportMissingImports = true
reportMissingTypeStubs = false
pythonVersion = "3.11"
pythonPlatform = "Linux"
reportAttributeAccessIssue = false
34 changes: 34 additions & 0 deletions unidock_tools/tests/applications/test_ligprep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pathlib import Path
import os
import shutil
import subprocess
import pytest


@pytest.fixture
def input_ligand():
return os.path.join(os.path.dirname(os.path.dirname(__file__)), "inputs", "Imatinib.sdf")


def test_ligprep_app_ligand_file(input_ligand):
results_dir = "prepared_ligands"
cmd = f"unidocktools ligprep -l {input_ligand} -sd {results_dir}"
print(cmd)
resp = subprocess.run(cmd, shell=True, capture_output=True, encoding="utf-8")
print(resp.stdout)
assert resp.returncode==0, f"run ligprep app err:\n{resp.stderr}"
shutil.rmtree(results_dir, ignore_errors=True)


def test_ligprep_app_ligand_index(input_ligand):
index_file = "ligand_index.txt"
with open(index_file, "w") as f:
f.write(input_ligand)
results_dir = "prepared_ligands"
cmd = f"unidocktools ligprep -i {index_file} -sd {results_dir}"
print(cmd)
resp = subprocess.run(cmd, shell=True, capture_output=True, encoding="utf-8")
print(resp.stdout)
assert resp.returncode==0, f"run ligprep app err:\n{resp.stderr}"
Path(index_file).unlink(missing_ok=True)
shutil.rmtree(results_dir, ignore_errors=True)
Loading
Loading