Skip to content

Commit

Permalink
Merge pull request #727 from padix-key/release-fix
Browse files Browse the repository at this point in the history
Fix problems in current Biotite relase
  • Loading branch information
padix-key authored Dec 23, 2024
2 parents 8ad4856 + 197a8fc commit 031fd92
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,17 @@ jobs:
name: Upload package to GitHub Releases & PyPI
permissions:
contents: write
id-token: write
needs:
- lint
- test-and-build
- sdist
- test-interfaces
- test-muscle5
runs-on: ubuntu-latest
environment:
name: publish
url: https://pypi.org/p/biotite
steps:
- uses: actions/download-artifact@v4
with:
Expand All @@ -347,10 +351,8 @@ jobs:
with:
files: dist//*
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@v1.9.0
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
password: ${{ secrets.PYPI_TOKEN }}


upload-ccd:
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
sys.path.insert(0, DOC_PATH)
import apidoc
import bibliography
import key
import preamble
import scraper
import switcher
import viewcode
Expand Down Expand Up @@ -206,7 +206,7 @@
"backreferences_dir": "examples/backreferences",
"doc_module": ("biotite",),
# Set the NCBI API key
"reset_modules": (key.set_ncbi_api_key_from_env,),
"reset_modules": (preamble.setup_script),
"remove_config_comments": True,
}

Expand Down
11 changes: 0 additions & 11 deletions doc/key.py

This file was deleted.

29 changes: 29 additions & 0 deletions doc/preamble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import numpy as np


def setup_script():
"""
Prepare API keys, formatting, etc. for running a tutorial or example script.
"""
# Import inside function as Biotite may not be known
# at the time of function definition
import biotite.application.blast as blast
import biotite.database.entrez as entrez

# Improve readability of large arrays
np.set_printoptions(precision=2)

# Use API key to increase request limit
ncbi_api_key = os.environ.get("NCBI_API_KEY")
if ncbi_api_key is not None and ncbi_api_key != "":
entrez.set_api_key(ncbi_api_key)

# Mock the BlastWebApp class
# to allow subsequent BLAST calls when building the tutorial
class MockedBlastApp(blast.BlastWebApp):
def __init__(self, *args, **kwargs):
kwargs["obey_rules"] = False
super().__init__(*args, **kwargs)

blast.BlastWebApp = MockedBlastApp
24 changes: 4 additions & 20 deletions doc/tutorial/preamble.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
.. jupyter-execute::
.. jupyter-execute:: /preamble.py
:hide-code:

import os
import numpy as np
import biotite.database.entrez as entrez
import biotite.application.blast as blast

# Improve readability of large arrays
np.set_printoptions(precision=2)

# Use API key to increase request limit
ncbi_api_key = os.environ.get("NCBI_API_KEY")
if ncbi_api_key is not None and ncbi_api_key != "":
entrez.set_api_key(ncbi_api_key)
.. jupyter-execute::
:hide-code:

# Mock the BlastWebApp class
# to allow subsequent BLAST calls when building the tutorial
class MockedBlastApp(blast.BlastWebApp):
def __init__(self, *args, **kwargs):
kwargs["obey_rules"] = False
super().__init__(*args, **kwargs)
blast.BlastWebApp = MockedBlastApp
setup_script()

0 comments on commit 031fd92

Please sign in to comment.