From 9d117a37eabdae446aa81519d17b9c4739edb056 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 17 Feb 2025 15:13:27 +0000 Subject: [PATCH] Re-organizing repositories by splitting this into two --- .devcontainer/Dockerfile | 16 ++++++++++ .devcontainer/devcontainer.json | 24 +++++++++++++++ .devcontainer/noop.txt | 3 ++ .vscode/launch.json | 19 ++++++++++++ Jenkinsfile | 54 +++++++++++++++++++++++++++++++++ autobigs-engine/meta.yaml | 14 ++++----- environment.yml | 10 ++++++ scripts/adapt_names.py | 30 ++++++++++++++++++ 8 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/noop.txt create mode 100644 .vscode/launch.json create mode 100644 Jenkinsfile create mode 100644 environment.yml create mode 100644 scripts/adapt_names.py diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..808f11b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/devcontainers/miniconda:1-3 + +# Copy environment.yml (if found) to a temp location so we update the environment. Also +# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists. +COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/ +RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \ + && rm -rf /tmp/conda-tmp + +# [Optional] Uncomment to install a different version of Python than the default +# RUN conda install -y python=3.6 \ +# && pip install --no-cache-dir pipx \ +# && pipx reinstall-all + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..43d26c5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda +{ + "name": "Miniconda (Python 3)", + "build": { + "context": "..", + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "python --version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/noop.txt b/.devcontainer/noop.txt new file mode 100644 index 0000000..abee195 --- /dev/null +++ b/.devcontainer/noop.txt @@ -0,0 +1,3 @@ +This file is copied into the container along with environment.yml* from the +parent folder. This is done to prevent the Dockerfile COPY instruction from +failing if no environment.yml is found. \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5045d5b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: Current File with Arguments", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "args": [ + "${command:pickArgs}" + ] + } + ] +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..99fa74a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,54 @@ +pipeline { + agent { + kubernetes { + cloud 'rsys-devel' + defaultContainer 'miniforge3' + inheritFrom 'miniforge' + } + } + stages { + stage("prepare") { + parallel { + stage("recipes repo") { + steps { + sh 'git clone https://github.com/RealYHD/bioconda-recipes.git' + dir('bioconda-recipes') { + sh 'git pull' + sh 'git pull origin update-autobigs-engine' + sh 'git pull origin update-autobigs-engine' + } + } + } + stage("conda") { + steps { + sh 'conda env update -n base --file environment.yml' + } + } + } + } + stage("update recipes") { + parallel { + stage("autoBIGS.cli") { + steps { + sh 'grayskull pypi autobigs.cli --maintainers "Harrison Deng"' + sh 'python scripts/adapt_names.py autobigs.cli' + } + } + stage("autoBIGS.engine") { + steps { + sh 'grayskull pypi autobigs.cli --maintainers "Harrison Deng"' + sh 'python scripts/adapt_names.py autobigs.engine' + } + } + } + stage("overwrite") { + steps { + dir('bioconda-recipes') { + sh 'checkout ' + sh 'cp autobigs-engine/* ' + } + } + } + } + } +} \ No newline at end of file diff --git a/autobigs-engine/meta.yaml b/autobigs-engine/meta.yaml index d635227..75457f3 100644 --- a/autobigs-engine/meta.yaml +++ b/autobigs-engine/meta.yaml @@ -1,4 +1,4 @@ -{% set name = "autoBIGS.engine" %} +{% set name = "autobigs.engine" %} {% set version = "0.11.0" %} package: @@ -13,8 +13,6 @@ build: noarch: python script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation number: 0 - run_exports: - - {{ pin_subpackage( name|lower|replace(".", "-"), max_pin="x.x") }} requirements: host: @@ -24,8 +22,8 @@ requirements: - pip run: - python >=3.12 - - biopython - - aiohttp + - biopython ==1.85 + - aiohttp ==3.11.* test: imports: @@ -36,11 +34,11 @@ test: - pip about: - home: https://github.com/RealYHD/autoBIGS.engine summary: A library to rapidly fetch fetch MLST profiles given sequences for various diseases. - license: GPL-3.0-or-later + dev_url: https://github.com/RealYHD/autoBIGS.engine + license: GPL-3.0 license_file: LICENSE extra: recipe-maintainers: - - Harrison Deng + - RealYHD diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..a055fbd --- /dev/null +++ b/environment.yml @@ -0,0 +1,10 @@ +name: base +channels: + - conda-forge + - bioconda +dependencies: + - conda-build + - grayskull + - bioconda-utils + - python=3.10 + - git \ No newline at end of file diff --git a/scripts/adapt_names.py b/scripts/adapt_names.py new file mode 100644 index 0000000..6103340 --- /dev/null +++ b/scripts/adapt_names.py @@ -0,0 +1,30 @@ +import argparse +from os import fdopen, path +import os +import re +import shutil +from sys import argv +import tempfile + +def main(): + original_recipe = path.abspath(argv[1]) + original_meta = path.join(original_recipe, "meta.yaml") + new_fd, new_file_path = tempfile.mkstemp() + with fdopen(new_fd, "w") as new_file_handle: + with open(original_meta, "r") as original_file_handle: + for line in original_file_handle: + matches = re.finditer(r"\{\{\s*name\|lower()\s+\}\}", line) + modified_line = line + for match in matches: + modified_line = modified_line[:match.start(1)] + r'|replace(".", "-")' + modified_line[match.end(1):] + new_file_handle.write(modified_line) + shutil.move(new_file_path, original_meta) + new_recipe_name = path.join( + path.dirname(original_recipe), + path.basename(original_recipe).replace(".", "-").lower()) + shutil.rmtree(new_recipe_name, ignore_errors=True) + os.replace(original_recipe, + new_recipe_name) + +if __name__ == "__main__": + main() \ No newline at end of file