Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/GitHub deploy #222

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# from https://github.com/actinia-org/actinia-core/blob/main/.github/workflows/update-version.yml
name: Update Version Number

on:
release:
types: [published]

jobs:
update-version-number:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Update Version Number
run: |
OLD_VERSION=$(grep ^version pyproject.toml | cut -d '"' -f 2)
OLD_VERSION="\"$OLD_VERSION\""
NEW_VERSION="\"$GITHUB_REF_NAME\""
sed -i "s+version = $OLD_VERSION+version = $NEW_VERSION+g" pyproject.toml
- name: Commit Changes
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git commit -a -m "Update version number to new_version"
git push origin HEAD:main
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-setuptools]
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.0.1
# hooks:
# - id: mypy
# additional_dependencies: [types-PyYAML, types-setuptools]
4 changes: 3 additions & 1 deletion big_scape/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
from big_scape.cli import query_cli as query
from big_scape.cli import benchmark_cli as benchmark
from big_scape.cli.cli_config import CommandOrder
from big_scape.utility.version import get_bigscape_version


def print_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.echo("BiG-SCAPE 2.0 beta")
bigscape_version = get_bigscape_version()
click.echo(f"BiG-SCAPE {bigscape_version}")
ctx.exit()


Expand Down
10 changes: 8 additions & 2 deletions big_scape/run_bigscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import big_scape.file_input as bs_files

# import big_scape.genbank as bs_gbk
from big_scape.utility.version import get_bigscape_version
import big_scape.data as bs_data
import big_scape.enums as bs_enums
import big_scape.comparison as bs_comparison
Expand All @@ -45,9 +46,14 @@ def run_bigscape(run: dict) -> None:
command line arguments, loads the data, runs the analysis and saves the output.
"""
# starting information
# TODO: add automatic updating of version number
# this is, lightly and delicately put, *not a great way to get the version*
# but after some research, it seems no one had the idea to make this easy

bigscape_version = get_bigscape_version()

logging.info(
"Starting BiG-SCAPE 2.0.0 %s run on %s level with %s alignment and %s weights",
"Starting BiG-SCAPE %s %s run on %s level with %s alignment and %s weights",
bigscape_version,
run["mode"],
run["record_type"].value,
run["alignment_mode"].value,
Expand Down
30 changes: 30 additions & 0 deletions big_scape/utility/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Module that contains helper functions specifically related to the bigscape version
"""

import toml

from importlib import metadata
from pathlib import Path


def get_bigscape_version() -> str:
"""Get the version of BiG-SCAPE.
The way we retrieve the version is different depending on whether the package is
installed or not.

We need a dedicated library for this because the python community has not figured
out that version numbers are pretty core to software development and there is no
single place to put them. We want it to only be in the pyproject.toml file and not
anywhere else, but this file is not available when installed as a package
"""
# can we get to the pyproject.toml file?
print(__file__)
pyproject_toml = Path(__file__).parent.parent.parent / "pyproject.toml"

if pyproject_toml.exists():
return toml.load(pyproject_toml)["project"]["version"]

# if not, we're probably running as a package. get the version of the currently
# installed big-scape package

return metadata.version("big-scape")
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
- pip:
- click==8.1.7
- PyYAML==6.0.1
- importlib-metadata==8.5.0
Loading