From 7f88b9fa8b051ab210c16564a6f5e0d87661635e Mon Sep 17 00:00:00 2001 From: ggutierrez-sunbright <94693768+ggutierrez-sunbright@users.noreply.github.com> Date: Fri, 22 Dec 2023 03:03:18 +0100 Subject: [PATCH] kickstart rdock-utils package (#57) * kickstart rdock-utils package --- .github/workflows/build_generic.yml | 2 +- .github/workflows/rdock-utils.yaml | 50 ++++++++ rdock-utils/.devcontainer/devcontainer.json | 47 +++++++ rdock-utils/.gitignore | 129 ++++++++++++++++++++ rdock-utils/Dockerfile | 10 ++ rdock-utils/README.md | 3 + rdock-utils/pyproject.toml | 13 ++ rdock-utils/rdock_utils/__init__.py | 0 rdock-utils/rdock_utils/sdnothing.py | 2 + rdock-utils/requirements-dev.txt | 5 + rdock-utils/requirements.txt | 0 rdock-utils/scripts/sdnothing | 12 ++ rdock-utils/setup.cfg | 36 ++++++ rdock-utils/setup.py | 20 +++ rdock-utils/tests/__init__.py | 0 rdock-utils/tests/conftest.py | 0 rdock-utils/tests/test_all_ok.py | 6 + 17 files changed, 334 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/rdock-utils.yaml create mode 100644 rdock-utils/.devcontainer/devcontainer.json create mode 100644 rdock-utils/.gitignore create mode 100644 rdock-utils/Dockerfile create mode 100644 rdock-utils/README.md create mode 100644 rdock-utils/pyproject.toml create mode 100644 rdock-utils/rdock_utils/__init__.py create mode 100644 rdock-utils/rdock_utils/sdnothing.py create mode 100644 rdock-utils/requirements-dev.txt create mode 100644 rdock-utils/requirements.txt create mode 100755 rdock-utils/scripts/sdnothing create mode 100644 rdock-utils/setup.cfg create mode 100644 rdock-utils/setup.py create mode 100644 rdock-utils/tests/__init__.py create mode 100644 rdock-utils/tests/conftest.py create mode 100644 rdock-utils/tests/test_all_ok.py diff --git a/.github/workflows/build_generic.yml b/.github/workflows/build_generic.yml index 4c98590b..65cc5f2a 100644 --- a/.github/workflows/build_generic.yml +++ b/.github/workflows/build_generic.yml @@ -33,7 +33,7 @@ jobs: - name: Build rDock run: docker run --rm -v $PWD:/rdock -w /rdock rdock-${{ inputs.distribution }}:base make CXX=${{ inputs.compiler }} -j 2 - + - name: Test rDock run: docker run --rm -v $PWD:/rdock -w /rdock rdock-${{ inputs.distribution }}:base make CXX=${{ inputs.compiler }} test diff --git a/.github/workflows/rdock-utils.yaml b/.github/workflows/rdock-utils.yaml new file mode 100644 index 00000000..fb2d2bc4 --- /dev/null +++ b/.github/workflows/rdock-utils.yaml @@ -0,0 +1,50 @@ +name: "[rdock-utils] Lint and Test" + +on: + pull_request: + branches: + - main + + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build rdock-utils dev image + uses: docker/build-push-action@v5 + with: + context: ./rdock-utils + tags: ghcr.io/cbdd/rdock-utils:dev + file: ./rdock-utils/Dockerfile + target: development + cache-from: type=gha,scope=rdock-utils + cache-to: type=gha,mode=max,scope=rdock-utils + load: true + + - name: flake8 + run: docker run --rm -v $PWD/rdock-utils:/rdock-utils -w /rdock-utils ghcr.io/cbdd/rdock-utils:dev flake8 . + + - name: black + run: docker run --rm -v $PWD/rdock-utils:/rdock-utils -w /rdock-utils ghcr.io/cbdd/rdock-utils:dev black --check . + + - name: isort + run: docker run --rm -v $PWD/rdock-utils:/rdock-utils -w /rdock-utils ghcr.io/cbdd/rdock-utils:dev isort --check . + + - name: mypy + run: docker run --rm -v $PWD/rdock-utils:/rdock-utils -w /rdock-utils ghcr.io/cbdd/rdock-utils:dev mypy . diff --git a/rdock-utils/.devcontainer/devcontainer.json b/rdock-utils/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7011b6cb --- /dev/null +++ b/rdock-utils/.devcontainer/devcontainer.json @@ -0,0 +1,47 @@ +{ + "name": "rdock-utils", + "build": { + "dockerfile": "../Dockerfile", + "context": "..", + "target": "development" + }, + "customizations": { + "vscode": { + "settings": { + "python.languageServer": "Pylance", + "python.linting.enabled": true, + "python.linting.flake8Enabled": true, + "python.formatting.provider": "black", + "python.linting.mypyEnabled": false, + "isort.check": true, + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": [ + "tests" + ], + "python.formatting.blackArgs": [ + "--line-length", + "119" + ], + "isort.args": [ + "--profile", + "black" + ], + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "editor.formatOnSave": true, + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 1000 + }, + "extensions": [ + "ms-python.python", + "littlefoxteam.vscode-python-test-adapter", + "ms-vsliveshare.vsliveshare", + "mhutchie.git-graph", + "ms-toolsai.jupyter" + ] + } + } +} diff --git a/rdock-utils/.gitignore b/rdock-utils/.gitignore new file mode 100644 index 00000000..b6e47617 --- /dev/null +++ b/rdock-utils/.gitignore @@ -0,0 +1,129 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/rdock-utils/Dockerfile b/rdock-utils/Dockerfile new file mode 100644 index 00000000..24164fd9 --- /dev/null +++ b/rdock-utils/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.12 AS base + +COPY requirements.txt requirements.txt +RUN python -m pip install --upgrade pip +RUN python -m pip install -r requirements.txt + +FROM base AS development + +COPY requirements-dev.txt requirements-dev.txt +RUN python -m pip install -r requirements-dev.txt diff --git a/rdock-utils/README.md b/rdock-utils/README.md new file mode 100644 index 00000000..a21c2edb --- /dev/null +++ b/rdock-utils/README.md @@ -0,0 +1,3 @@ +# rdock-utils python package + +coming soon \ No newline at end of file diff --git a/rdock-utils/pyproject.toml b/rdock-utils/pyproject.toml new file mode 100644 index 00000000..cfe556ba --- /dev/null +++ b/rdock-utils/pyproject.toml @@ -0,0 +1,13 @@ +[tool.black] +line-length = 119 +target-version = ['py312'] + +[tool.isort] +profile = "black" +line_length = 119 +combine_as_imports = true + +import_heading_stdlib = "Standard Library" +import_heading_thirdparty = "Dependencies" +import_heading_firstparty = "From apps" +import_heading_localfolder = "Local imports" diff --git a/rdock-utils/rdock_utils/__init__.py b/rdock-utils/rdock_utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rdock-utils/rdock_utils/sdnothing.py b/rdock-utils/rdock_utils/sdnothing.py new file mode 100644 index 00000000..b2397264 --- /dev/null +++ b/rdock-utils/rdock_utils/sdnothing.py @@ -0,0 +1,2 @@ +def main() -> None: + print("to be removed when we start having code migrated over here") diff --git a/rdock-utils/requirements-dev.txt b/rdock-utils/requirements-dev.txt new file mode 100644 index 00000000..4168d738 --- /dev/null +++ b/rdock-utils/requirements-dev.txt @@ -0,0 +1,5 @@ +black +flake8 +isort +mypy +pytest diff --git a/rdock-utils/requirements.txt b/rdock-utils/requirements.txt new file mode 100644 index 00000000..e69de29b diff --git a/rdock-utils/scripts/sdnothing b/rdock-utils/scripts/sdnothing new file mode 100755 index 00000000..1c328950 --- /dev/null +++ b/rdock-utils/scripts/sdnothing @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# remove this script when the first script is migrated here +# actual code for the scripts should be in rdock_utils. +# for example, +# from rdock_utils.sdsort import main + +# From apps +from rdock_utils.sdnothing import main + +if __name__ == "__main__": + main() diff --git a/rdock-utils/setup.cfg b/rdock-utils/setup.cfg new file mode 100644 index 00000000..b4464cce --- /dev/null +++ b/rdock-utils/setup.cfg @@ -0,0 +1,36 @@ +[flake8] +max-line-length = 119 +exclude = .git,__pycache__ +ignore = E231,E501,E203,W503 + + +[mypy] +python_version = 3.12 +pretty = True +show_error_context = True +show_error_codes = True + +follow_imports = silent +ignore_missing_imports = True + +disallow_incomplete_defs = True +disallow_any_generics = True +disallow_subclassing_any = False +disallow_untyped_calls = True +disallow_untyped_defs = True +disallow_untyped_decorators = True + +warn_unused_configs = True +warn_unreachable = True +warn_redundant_casts = True +warn_unused_ignores = True +warn_return_any = True + +check_untyped_defs = True + +no_implicit_optional = True +no_implicit_reexport = False + +strict_equality = True + +exclude = (^setup\.py$) diff --git a/rdock-utils/setup.py b/rdock-utils/setup.py new file mode 100644 index 00000000..174b367f --- /dev/null +++ b/rdock-utils/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# Dependencies +from setuptools import setup + +raise Exception("Please make sure you have modified all necessary attributes before pip installing the package") + +setup( + name="rdock-utils", + version="0.01", + description="", + author="", + author_email="", + url="", + packages=[], + # inlcude_package_data=True, + # package_data={'package.module':[folder/with/data/*]} + # scripts=[], + install_requires=[], +) diff --git a/rdock-utils/tests/__init__.py b/rdock-utils/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rdock-utils/tests/conftest.py b/rdock-utils/tests/conftest.py new file mode 100644 index 00000000..e69de29b diff --git a/rdock-utils/tests/test_all_ok.py b/rdock-utils/tests/test_all_ok.py new file mode 100644 index 00000000..fcfadd28 --- /dev/null +++ b/rdock-utils/tests/test_all_ok.py @@ -0,0 +1,6 @@ +# An empty test, to be able to run something with pytest : ) +# Remove me when you have something in place + + +def test_all_ok() -> None: + assert True