diff --git a/.gitignore b/.gitignore index 03424bc..11b6964 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,8 @@ profile_default/ ipython_config.py .python-version +!/.python-version +!/scripts/population/.python-version # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ @@ -71,4 +73,4 @@ venv.bak/ # mac os .DS_Store -common/.DS_Store \ No newline at end of file +common/.DS_Store diff --git a/Dockerfile.dev b/Dockerfile.dev index f22d887..150f3bf 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM python:3.10 +FROM python:3.12 # Contains relevant basics for Python, like GCC and similar by default LABEL maintainer="ensembl-variation@ebi.ac.uk" diff --git a/Dockerfile.prod b/Dockerfile.prod index 550c585..35d0371 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,4 +1,4 @@ -FROM python:3.10 +FROM python:3.12 # Contains relevant basics for Python, like GCC and similar by default LABEL maintainer="ensembl-variation@ebi.ac.uk" diff --git a/README.md b/README.md index a4c545f..dd1cd27 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ The API can be queried against a single endpoint specifying the payload to be re ![alt text](assets/architecture.png) +## Python version + +Use Python 3.12 for local development and Docker builds. + ## Running the API using Docker @@ -72,4 +76,4 @@ query variant_example { } } ``` -More example queries can be found in `examples/` \ No newline at end of file +More example queries can be found in `examples/` diff --git a/common/base_file_client.py b/common/base_file_client.py index fe83af2..2388311 100644 --- a/common/base_file_client.py +++ b/common/base_file_client.py @@ -5,10 +5,10 @@ import io import os import subprocess -from common.file_model.variant import Variant -from common.file_model.structural_variant import StructuralVariant -import vcfpy +from common.file_model.structural_variant import StructuralVariant +from common.file_model.variant import Variant +from common.vcf_reader import read_vcf class BaseFileClient: @@ -81,7 +81,7 @@ def get_record_from_file( reader = None try: - reader = vcfpy.Reader.from_path(datafile) + reader = read_vcf(datafile) try: for rec in reader.fetch(contig, pos - 1, pos): if self.record_matches(rec, contig, pos, id): @@ -90,7 +90,7 @@ def get_record_from_file( if not fallback_to_iteration: return None self.close_reader(reader) - reader = vcfpy.Reader.from_path(datafile) + reader = read_vcf(datafile) for rec in reader: if self.record_matches(rec, contig, pos, id): return record_class(rec, reader.header, genome_uuid) @@ -133,7 +133,7 @@ def get_record_with_bcftools( if result.returncode != 0: return None - reader = vcfpy.Reader(io.StringIO(result.stdout)) + reader = read_vcf(stream=io.StringIO(result.stdout)) for rec in reader: if self.record_matches(rec, contig, pos, id): return record_class(rec, reader.header, genome_uuid) diff --git a/mypy.ini b/mypy.ini index 48e6a29..d1842c1 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,12 +1,9 @@ [mypy] -python_version = 3.8 +python_version = 3.12 [mypy-requests.*] ignore_missing_imports = True -[mypy-snapshottest.*] -ignore_missing_imports = True - [mypy-aiodataloader.*] ignore_missing_imports = True diff --git a/requirements-dev.txt b/requirements-dev.txt index d320b4f..c0a4149 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,7 @@ -r requirements.txt -pytest==7.1.2 -pytest-asyncio==0.18.3 -snapshottest==0.6.0 -pylint==2.14.3 -mypy==0.961 -black==22.6.0 -ruff==0.12.7 \ No newline at end of file +pytest==7.4.4 +pytest-asyncio==0.23.8 +pylint==3.0.4 +mypy==1.8.0 +black==24.3.0 +ruff==0.12.7 diff --git a/requirements.txt b/requirements.txt index 6fd2929..4cecdd7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ duckdb -mongomock==4.0.0 +mongomock==4.3.0 pymongo==4.1.1 requests==2.28.0 aiodataloader==0.2.1 ariadne==0.19.1 python-dotenv==0.20.0 uvicorn==0.18.1 -pysam==0.21.0 -vcfpy @ git+https://github.com/likhitha-surapaneni/vcfpy@header-fix +pysam==0.22.1 +vcfpy==0.13.8 diff --git a/ruff.toml b/ruff.toml index e278674..6b71752 100644 --- a/ruff.toml +++ b/ruff.toml @@ -3,7 +3,7 @@ # --- Linting rules --- line-length = 88 # Black style -target-version = "py310" +target-version = "py312" # --- Formatting --- [format] diff --git a/setup.py b/setup.py index b2ec30a..f5c4e5d 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ -""" +"""Configure packaging for the Ensembl Variation GraphQL API. + .. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +14,8 @@ """ from pathlib import Path -from setuptools import setup, find_packages +from setuptools import find_packages, setup with open(Path(__file__).parent / "LICENSE") as f: LICENSE_CT = f.read() @@ -26,7 +27,7 @@ version="0.1.0", packages=find_packages(), license=LICENSE_CT, - python_requires=">=3.8", + python_requires=">=3.12", package_data={ # Make sure schema makes it to distro "common": ["*.graphql"]