diff --git a/Dockerfile b/Dockerfile index bb30ee8..399df52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,24 @@ FROM python:3.13.2-alpine3.21 AS base -WORKDIR /de-denker -FROM base AS requirements -RUN pip install poetry-plugin-export -COPY pyproject.toml poetry.lock ./ -RUN poetry export --without-hashes --format=requirements.txt > requirements.txt FROM base AS build + +WORKDIR /dedenker + RUN apk add --no-cache build-base -ENV PYTHONDONTWRITEBYTECODE=1 -COPY --from=requirements /de-denker/requirements.txt . -RUN pip install -r requirements.txt - -FROM base AS artifact -RUN apk add --no-cache libgomp libstdc++ -COPY --from=build /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages -COPY --from=build /usr/local/bin /usr/local/bin -COPY config.py main.py models.py static_probabilities.py telraam_api.py ./ -CMD ["python", "main.py"] +RUN pip install poetry==2.1 +RUN poetry self add poetry-pyinstaller-plugin==1.4 + +COPY pyproject.toml poetry.lock . +RUN poetry install --no-root + +COPY dedenker/ dedenker/ +RUN PYTHONOPTIMIZE=2 poetry build --format=pyinstaller +RUN mv dist/pyinstaller/musllinux_1_2_x86_64/dedenker dist/ + + +FROM scratch AS artifact +COPY --from=base /lib/ld-musl-x86_64.so.1 /usr/lib/libz.so.1 /lib/ +COPY --from=base /tmp /tmp +COPY --from=build /dedenker/dist/dedenker /dedenker +CMD ["/dedenker"] diff --git a/README.md b/README.md index bfdf4d7..47666e7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A possible `docker-compose.yml` can be the next one. Adapt where needed. ```yml services: - de-denker: + dedenker: image: ghcr.io/12urenloop/dedenker:main restart: unless-stopped environment: diff --git a/dedenker/__init__.py b/dedenker/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.py b/dedenker/config.py similarity index 100% rename from config.py rename to dedenker/config.py diff --git a/main.py b/dedenker/main.py similarity index 95% rename from main.py rename to dedenker/main.py index d38934d..14dfcad 100644 --- a/main.py +++ b/dedenker/main.py @@ -1,15 +1,15 @@ -from time import time, sleep +from time import sleep, time import colorlog -import numpy as np -import requests.exceptions from hmmlearn.base import ConvergenceMonitor from hmmlearn.hmm import CategoricalHMM +import numpy as np +import requests.exceptions -from config import RONNY_COUNT, SLEEP_DURATION -from models import Detection -from static_probabilities import START_PROBABILITIES_12UL, EMISSION_PROBABILITIES_12UL, TRANSITION_PROBABILITIES_12UL -from telraam_api import TelraamAPI +from dedenker.config import RONNY_COUNT, SLEEP_DURATION +from dedenker.models import Detection +from dedenker.static_probabilities import TRANSITION_PROBABILITIES_12UL, START_PROBABILITIES_12UL, EMISSION_PROBABILITIES_12UL +from dedenker.telraam_api import TelraamAPI handler = colorlog.StreamHandler() handler.setFormatter(colorlog.ColoredFormatter('%(log_color)s%(levelname)s\t%(message)s')) diff --git a/models.py b/dedenker/models.py similarity index 100% rename from models.py rename to dedenker/models.py diff --git a/static_probabilities.py b/dedenker/static_probabilities.py similarity index 100% rename from static_probabilities.py rename to dedenker/static_probabilities.py diff --git a/telraam_api.py b/dedenker/telraam_api.py similarity index 95% rename from telraam_api.py rename to dedenker/telraam_api.py index af10e2f..cb05094 100644 --- a/telraam_api.py +++ b/dedenker/telraam_api.py @@ -1,8 +1,7 @@ from requests import get, post -from config import TELRAAM_URL -from models import Detection - +from dedenker.config import TELRAAM_URL +from dedenker.models import Detection class TelraamAPI: """ diff --git a/poetry.lock b/poetry.lock index 1cae156..a8b2dd3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "certifi" @@ -6,6 +6,7 @@ version = "2025.1.31" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe"}, {file = "certifi-2025.1.31.tar.gz", hash = "sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651"}, @@ -17,6 +18,7 @@ version = "3.4.1" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "charset_normalizer-3.4.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:91b36a978b5ae0ee86c394f5a54d6ef44db1de0815eb43de826d41d21e4af3de"}, {file = "charset_normalizer-3.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7461baadb4dc00fd9e0acbe254e3d7d2112e7f92ced2adc96e54ef6501c5f176"}, @@ -118,6 +120,8 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] +markers = "sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -129,6 +133,7 @@ version = "6.9.0" description = "Add colours to the output of Python's logging module." optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "colorlog-6.9.0-py3-none-any.whl", hash = "sha256:5906e71acd67cb07a71e779c47c4bcb45fb8c2993eebe9e5adcd6a6f1b283eff"}, {file = "colorlog-6.9.0.tar.gz", hash = "sha256:bfba54a1b93b94f54e1f4fe48395725a3d92fd2a4af702f6bd70946bdc0c6ac2"}, @@ -146,6 +151,7 @@ version = "0.3.3" description = "Hidden Markov Models in Python with scikit-learn like API" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "hmmlearn-0.3.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:06abdc7f1905c1c10132e62d4e9d6bdf88bf17d267cae68b6ad834b0c2efef0b"}, {file = "hmmlearn-0.3.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ad910c05fb42f4261b5cebd683adc44e270cfb53330d21a5ce2bd907df9703fe"}, @@ -195,6 +201,7 @@ version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, @@ -209,6 +216,7 @@ version = "1.4.2" description = "Lightweight pipelining with Python functions" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "joblib-1.4.2-py3-none-any.whl", hash = "sha256:06d478d5674cbc267e7496a410ee875abd68e4340feff4490bcb7afb88060ae6"}, {file = "joblib-1.4.2.tar.gz", hash = "sha256:2382c5816b2636fbd20a09e0f4e9dad4736765fdfb7dca582943b9c1366b3f0e"}, @@ -220,6 +228,7 @@ version = "2.2.4" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.10" +groups = ["main"] files = [ {file = "numpy-2.2.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8146f3550d627252269ac42ae660281d673eb6f8b32f113538e0cc2a9aed42b9"}, {file = "numpy-2.2.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e642d86b8f956098b564a45e6f6ce68a22c2c97a04f5acd3f221f57b8cb850ae"}, @@ -284,6 +293,7 @@ version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, @@ -305,6 +315,7 @@ version = "1.6.1" description = "A set of python modules for machine learning and data mining" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "scikit_learn-1.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d056391530ccd1e501056160e3c9673b4da4805eb67eb2bdf4e983e1f9c9204e"}, {file = "scikit_learn-1.6.1-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:0c8d036eb937dbb568c6242fa598d551d88fb4399c0344d95c001980ec1c7d36"}, @@ -359,6 +370,7 @@ version = "1.15.2" description = "Fundamental algorithms for scientific computing in Python" optional = false python-versions = ">=3.10" +groups = ["main"] files = [ {file = "scipy-1.15.2-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:a2ec871edaa863e8213ea5df811cd600734f6400b4af272e1c011e69401218e9"}, {file = "scipy-1.15.2-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:6f223753c6ea76983af380787611ae1291e3ceb23917393079dcc746ba60cfb5"}, @@ -414,7 +426,7 @@ numpy = ">=1.23.5,<2.5" [package.extras] dev = ["cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy (==1.10.0)", "pycodestyle", "pydevtool", "rich-click", "ruff (>=0.0.292)", "types-psutil", "typing_extensions"] doc = ["intersphinx_registry", "jupyterlite-pyodide-kernel", "jupyterlite-sphinx (>=0.16.5)", "jupytext", "matplotlib (>=3.5)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (>=0.15.2)", "sphinx (>=5.0.0,<8.0.0)", "sphinx-copybutton", "sphinx-design (>=0.4.0)"] -test = ["Cython", "array-api-strict (>=2.0,<2.1.1)", "asv", "gmpy2", "hypothesis (>=6.30)", "meson", "mpmath", "ninja", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] +test = ["Cython", "array-api-strict (>=2.0,<2.1.1)", "asv", "gmpy2", "hypothesis (>=6.30)", "meson", "mpmath", "ninja ; sys_platform != \"emscripten\"", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] [[package]] name = "threadpoolctl" @@ -422,6 +434,7 @@ version = "3.6.0" description = "threadpoolctl" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "threadpoolctl-3.6.0-py3-none-any.whl", hash = "sha256:43a0b8fd5a2928500110039e43a5eed8480b918967083ea48dc3ab9f13c4a7fb"}, {file = "threadpoolctl-3.6.0.tar.gz", hash = "sha256:8ab8b4aa3491d812b623328249fab5302a68d2d71745c8a4c719a2fcaba9f44e"}, @@ -433,18 +446,19 @@ version = "2.3.0" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "urllib3-2.3.0-py3-none-any.whl", hash = "sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df"}, {file = "urllib3-2.3.0.tar.gz", hash = "sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""] h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] [metadata] -lock-version = "2.0" -python-versions = "^3.11" -content-hash = "4ce4b736aa324dd94ede1bbe1f24089e24dd612268df62ee99d82cc60f722dfc" +lock-version = "2.1" +python-versions = ">=3.13" +content-hash = "eb1d69108c089d88423b45d0cd064dca0532ec40ec96366e8d49dd2ed5648b8b" diff --git a/pyproject.toml b/pyproject.toml index 9d23478..4b3fa2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,22 @@ -[tool.poetry] -package-mode = false -name = "De Denker" +[project] +name = "DeDenker" +version = "0.1.0" description = "A HMM lapper for Telraam using the API" license = "MIT" -readme = "README.md" - -[tool.poetry.dependencies] -python = "^3.11" -hmmlearn = "^0.3.0" -requests = "^2.31.0" -colorlog = "^6.7.0" - +requires-python = ">=3.13" +dependencies = [ + "hmmlearn (>=0.3.3,<1.0.0)", + "requests (>=2.32.2,<3.0.0)", + "colorlog (>=6.9.0,<7.0.0)", +] [build-system] -requires = ["poetry-core"] +requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.poetry-pyinstaller-plugin] +version = "6.12.0" + +[tool.poetry-pyinstaller-plugin.scripts.dedenker] +source = "dedenker/main.py" +type = "onefile"