diff --git a/.github/workflows/pypackage_build.yml b/.github/workflows/pypackage_build.yml new file mode 100644 index 00000000..07b7873c --- /dev/null +++ b/.github/workflows/pypackage_build.yml @@ -0,0 +1,92 @@ +name: Build and publish python package + +on: + push: + tags: + - "*" + +# Define permissions needed for the workflow GITHUB_TOKEN +permissions: + contents: read # Allow checkout + packages: write # Allow publishing to GitHub Packages + + +jobs: + build: + strategy: + matrix: + operating-system: [ macos-latest, ubuntu-latest, windows-latest ] + python-version: [ "3.10", "3.11", "3.12", "3.13" ] + + name: Build Python Package (${{ matrix.operating-system }}, Python ${{ matrix.python-version }}) + runs-on: ${{ matrix.operating-system }} + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install hatch + + - name: Build distributions + run: hatch build # Uses pyproject.toml to build sdist and wheel into dist/ + + - name: Upload distributions artifact + uses: actions/upload-artifact@v4 # Action to save artifacts between jobs + with: + name: como-distribution-package-${{ matrix.operating-system }}-${{ matrix.python-version }} # Name for the artifact + path: dist/ # Path to the directory to upload + + publish: + strategy: + matrix: + python-version: [ "3.10", "3.11", "3.12", "3.13" ] + operating-system: [ macos-latest, windows-latest, ubuntu-latest ] + + name: Publish to GitHub Packages + runs-on: ubuntu-latest + needs: build # Depends on the build job succeeding + + # IMPORTANT: Only run the publish job when a tag starting with 'v' is pushed + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + + + permissions: # Explicit permissions needed for this job + packages: write # Required to write to GitHub Packages registry + contents: read # Needed if accessing repo content (e.g., for download artifact) + + steps: + - name: Download distributions artifact + uses: actions/download-artifact@v4 # Action to retrieve artifacts from previous job. + with: + name: como-distribution-package-${{ matrix.operating-system }}-${{ matrix.python-version }} + path: dist/ + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Twine + run: pip install twine + + - name: Publish package to GitHub Packages + env: + # Use __token__ as username and the automatically generated GITHUB_TOKEN as password + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Uploading to GitHub Packages for repository: ${{ github.repository }}" + # Construct the repository URL dynamically using the repository owner + TWINE_REPOSITORY_URL="https://pypi.pkg.github.com/${{ github.repository_owner }}" + python -m twine upload --verbose --repository-url ${TWINE_REPOSITORY_URL} dist/* + + + diff --git a/main/como/create_context_specific_model.py b/main/como/create_context_specific_model.py index c072404c..4e483985 100644 --- a/main/como/create_context_specific_model.py +++ b/main/como/create_context_specific_model.py @@ -172,7 +172,7 @@ def _gene_rule_logical(gpr_expression: str, level: int = 0) -> str: inner_string = inner_string.replace("[", "") inner_string = inner_string.replace("]", "") - expression_out = f"{gpr_expression[:loc_l]}{inner_string}{gpr_expression[loc_r + 1:]}" + expression_out = f"{gpr_expression[:loc_l]}{inner_string}{gpr_expression[loc_r + 1 :]}" expression_out = _gene_rule_logical(expression_out, level + 1) return expression_out @@ -384,7 +384,7 @@ def _map_expression_to_reaction( continue for gid in gene_ids: if gid in gene_expressions.index: - rep_val = f' {gene_expressions.at[gid, "active"]} ' + rep_val = f" {gene_expressions.at[gid, 'active']} " else: rep_val = f" {unknown_val!s} " gene_reaction_rule = f" {gene_reaction_rule} " # pad white space to prevent gene matches inside floats diff --git a/main/como/rnaseq.py b/main/como/rnaseq.py index 8afa9779..45fc669b 100644 --- a/main/como/rnaseq.py +++ b/main/como/rnaseq.py @@ -418,8 +418,7 @@ def zfpkm_transform( cores = multiprocessing.cpu_count() - 2 logger.debug(f"Processing {total:,} samples through zFPKM transform using {cores} cores") logger.debug( - f"Will update every {update_per_step:,} steps as this is approximately " - f"{update_every_percent:.1%} of {total:,}" + f"Will update every {update_per_step:,} steps as this is approximately {update_every_percent:.1%} of {total:,}" ) with Pool(processes=cores) as pool: diff --git a/pyproject.toml b/pyproject.toml index 155641be..3bb1d01b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,10 +13,11 @@ dependencies = [ "loguru>=0.7.2", "pandas>=1.3.5", "plotly>=5.24.1", - "scanpy>=1.9.8", + "scanpy>=1.11.1", "scipy>=1.7.3", "scikit-learn>=1.5.2", "setuptools<60.0", + "statsmodels>=0.14", "openpyxl>=3.1.5", "aiofiles>=24.1.0", "aioftp>=0.23.1", @@ -49,4 +50,4 @@ packages = ["main/como"] allow-direct-references = true [tool.pytest.ini_options] -pythonpath = [ "main/src" ] \ No newline at end of file +pythonpath = [ "main/src" ]