Skip to content

Commit

Permalink
Merge branch 'main' into fix-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Jul 3, 2024
2 parents f0d4448 + 49bd762 commit d08edde
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 28 deletions.
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@
autodoc_preserve_defaults = True

# -- get version -------------------------------------------------------------
from cool_seq_tool.version import __version__
from cool_seq_tool import __version__

version = __version__
release = version
version = release = __version__


# -- linkcode ----------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ Source = "https://github.com/genomicmedlab/cool-seq-tool"
"Bug Tracker" = "https://github.com/genomicmedlab/cool-seq-tool/issues"

[build-system]
requires = ["setuptools>=64"]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "cool_seq_tool.version.__version__"}
[tool.setuptools_scm]

# Scanning for namespace packages in the ``src`` directory is true by
# default in pyproject.toml, so you do NOT need to include the
Expand Down
9 changes: 9 additions & 0 deletions src/cool_seq_tool/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
"""The cool_seq_tool package"""

from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("cool_seq_tool")
except PackageNotFoundError:
__version__ = "unknown"
finally:
del version, PackageNotFoundError
2 changes: 1 addition & 1 deletion src/cool_seq_tool/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi

from cool_seq_tool import __version__
from cool_seq_tool.routers import SERVICE_NAME, default, mane, mappings
from cool_seq_tool.version import __version__

app = FastAPI(
docs_url=f"/{SERVICE_NAME}",
Expand Down
15 changes: 1 addition & 14 deletions src/cool_seq_tool/schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Defines attribute constants, useful object structures, and API response schemas."""

import datetime
import re
from enum import Enum, IntEnum
from typing import Literal

Expand All @@ -10,11 +9,10 @@
ConfigDict,
StrictInt,
StrictStr,
field_validator,
model_validator,
)

from cool_seq_tool.version import __version__
from cool_seq_tool import __version__

_now = str(datetime.datetime.now(tz=datetime.timezone.utc))

Expand Down Expand Up @@ -276,17 +274,6 @@ class ServiceMeta(BaseModelForbidExtra):
"https://github.com/GenomicMedLab/cool-seq-tool"
)

@field_validator("version")
def validate_version(cls, v):
"""Check version matches semantic versioning regex pattern.
https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
"""
version_regex = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
if not re.match(version_regex, v):
msg = f"Invalid version {v}"
raise ValueError(msg)
return v

model_config = ConfigDict(
json_schema_extra={
"example": {
Expand Down
2 changes: 1 addition & 1 deletion src/cool_seq_tool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import datetime
import logging

from cool_seq_tool import __version__
from cool_seq_tool.schemas import ResidueMode, ServiceMeta
from cool_seq_tool.version import __version__

_logger = logging.getLogger(__name__)

Expand Down
3 changes: 0 additions & 3 deletions src/cool_seq_tool/version.py

This file was deleted.

4 changes: 1 addition & 3 deletions tests/mappers/test_exon_genomic_coords.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Module for testing that Cool Seq Tool works correctly."""

import copy
import re
from datetime import datetime

import pytest
Expand Down Expand Up @@ -303,8 +302,7 @@ def check_service_meta(actual):
:param ServiceMeta actual: Actual service metadata
"""
assert actual.name == "cool_seq_tool"
version_regex = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
assert bool(re.match(version_regex, actual.version))
# pydantic checks that version is a string
assert isinstance(actual.response_datetime, datetime)
assert actual.url == "https://github.com/GenomicMedLab/cool-seq-tool"

Expand Down

0 comments on commit d08edde

Please sign in to comment.