Skip to content

Commit 41cd220

Browse files
committed
REF: exchange poetry for hatch and refactor with ruff
1 parent de4607d commit 41cd220

26 files changed

Lines changed: 310 additions & 2588 deletions

.github/workflows/tests.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@ jobs:
2323
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
26+
cache: "pip"
2627

27-
- name: install Poetry
28+
- name: install package with dev dependencies
2829
run: |
2930
python -m pip install --upgrade pip
30-
python -m pip install "poetry>=1.8.0,<2.0.0"
31-
32-
- name: install project (incl. dev group)
33-
run: |
34-
poetry install --with dev
31+
pip install -e .[dev]
3532
3633
- name: ruff lint
37-
run: poetry run ruff check alembic bionexus
34+
run: ruff check alembic src
3835

3936
- name: ruff format check
40-
run: poetry run ruff format --check alembic bionexus
37+
run: ruff format --check alembic src

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ __pycache__/
88
*.sql
99
.env
1010
.vscode/
11+
.ruff_cache/
1112

1213
# do not push /retromol_cache wherever it is
1314
# this is the default cache directory for retromol results if no directory is specified

README.md

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,24 @@
1515
```bash
1616
python -m venv .venv
1717
source .venv/bin/activate
18-
pip install poetry
18+
pip install -e .[dev]
1919
```
2020

2121
or using `conda`:
2222

2323
```bash
2424
conda create -n bionexus python=3.10
2525
conda activate bionexus
26-
pip install poetry
26+
pip install -e .[dev]
2727
```
2828

29-
4) Install deps:
30-
31-
```bash
32-
poetry install --all-extras
33-
```
34-
35-
5) Create/upgrade schema:
29+
4) Create/upgrade schema:
3630

3731
```bash
3832
bionexus upgrade head
3933
```
4034

41-
6) Load data:
35+
5) Load data:
4236

4337
* Load NPAtlas compound structures, their names and properties, and organism annotations:
4438

@@ -48,28 +42,12 @@
4842

4943
* Load MIBiG:
5044

51-
Make sure to have installed the `bio` extras:
52-
53-
```bash
54-
poetry install --extras bio
55-
```
56-
57-
Then run:
58-
5945
```bash
6046
bionexus load-mibig
6147
```
6248

6349
* (Optional) Compute compound fingerprints:
6450

65-
Make sure to have installed the `chem` extras:
66-
67-
```bash
68-
poetry install --extras chem
69-
```
70-
71-
Then run:
72-
7351
```bash
7452
bionexus compute-fp-morgan
7553
```
@@ -82,14 +60,6 @@
8260

8361
* (Optional) Parse compounds with RetroMol:
8462

85-
Make sure to have installed the `retromol` extras:
86-
87-
```bash
88-
poetry install --extras retromol
89-
```
90-
91-
Then run:
92-
9363
```bash
9464
bionexus parse-compounds
9565
```

alembic/env.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Alembic migration environment configuration file."""
22

33
from __future__ import annotations
4+
5+
import os
46
from logging.config import fileConfig
57
from pathlib import Path
6-
import os
78

89
from sqlalchemy import engine_from_config, pool
9-
from alembic import context
1010

11+
from alembic import context
1112
from bionexus.db import models as bnx_models
1213

1314
# Make sure we import local repo version, not installed package
@@ -65,9 +66,7 @@ def run_migrations_online() -> None:
6566
"""
6667
Run migrations in 'online' mode.
6768
"""
68-
connectable = engine_from_config(
69-
{"sqlalchemy.url": get_url()}, prefix="sqlalchemy.", poolclass=pool.NullPool
70-
)
69+
connectable = engine_from_config({"sqlalchemy.url": get_url()}, prefix="sqlalchemy.", poolclass=pool.NullPool)
7170
with connectable.connect() as connection:
7271
context.configure(
7372
connection=connection,

alembic/versions/0001_init.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from alembic import op
21
import sqlalchemy as sa
3-
from sqlalchemy.dialects.postgresql import ARRAY, BIT
42
from pgvector.sqlalchemy import Vector
3+
from sqlalchemy.dialects.postgresql import ARRAY, BIT
4+
5+
from alembic import op
56

67
revision = "0001_init"
78
down_revision = None
@@ -10,9 +11,7 @@
1011

1112

1213
def upgrade():
13-
op.execute(
14-
"CREATE EXTENSION IF NOT EXISTS vector;"
15-
) # pgvector for fp_morgan_b2048_r2_vec
14+
op.execute("CREATE EXTENSION IF NOT EXISTS vector;") # pgvector for fp_morgan_b2048_r2_vec
1615

1716
op.create_table(
1817
"compound",
@@ -87,9 +86,7 @@ def upgrade():
8786
"compound_record",
8887
["compound_id", "source", "ext_id"],
8988
)
90-
op.create_index(
91-
"ix_compound_record_compound_id", "compound_record", ["compound_id"]
92-
)
89+
op.create_index("ix_compound_record_compound_id", "compound_record", ["compound_id"])
9390
# speed lookups by accession
9491
op.create_index(
9592
"ix_compound_record_source_ext",
@@ -136,18 +133,14 @@ def upgrade():
136133
def downgrade():
137134
# drop in reverse order
138135
# drop triggers/functions first (otherwise DROP TABLE will drop dependent objs, but be explicit)
139-
op.execute(
140-
"DROP TRIGGER IF EXISTS compound_record_set_timestamp ON public.compound_record;"
141-
)
136+
op.execute("DROP TRIGGER IF EXISTS compound_record_set_timestamp ON public.compound_record;")
142137
op.execute("DROP FUNCTION IF EXISTS public.set_timestamp_compound_record;")
143138
op.execute("DROP TRIGGER IF EXISTS compound_set_timestamp ON public.compound;")
144139
op.execute("DROP FUNCTION IF EXISTS public.set_timestamp_compound;")
145140

146141
op.drop_index("ix_compound_record_source_ext", table_name="compound_record")
147142
op.drop_index("ix_compound_record_compound_id", table_name="compound_record")
148-
op.drop_constraint(
149-
"uq_compound_record_compound_source_ext", "compound_record", type_="unique"
150-
)
143+
op.drop_constraint("uq_compound_record_compound_source_ext", "compound_record", type_="unique")
151144
op.drop_table("compound_record")
152145

153146
op.drop_constraint("uq_compound_inchikey", "compound", type_="unique")

alembic/versions/0002_rev.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
Create Date: 2025-10-10 21:56:15.797293
55
"""
66

7-
from alembic import op
87
import sqlalchemy as sa
98

9+
from alembic import op
10+
1011
revision = "0002_rev"
1112
down_revision = "0001_init"
1213
branch_labels = None
@@ -21,9 +22,7 @@ def upgrade():
2122
sa.Column("ext_id", sa.String(128), nullable=False),
2223
sa.Column("gbk_text", sa.Text, nullable=False), # full GenBank as TEXT
2324
sa.Column("size_bytes", sa.Integer, nullable=True), # raw size on ingest
24-
sa.Column(
25-
"sha256", sa.String(64), nullable=True
26-
), # content checksum for dedup/integrity
25+
sa.Column("sha256", sa.String(64), nullable=True), # content checksum for dedup/integrity
2726
sa.Column(
2827
"created_at",
2928
sa.DateTime(timezone=True),
@@ -72,9 +71,7 @@ def upgrade():
7271

7372
def downgrade():
7473
# drop trigger and its function first
75-
op.execute(
76-
"DROP TRIGGER IF EXISTS genbank_region_set_timestamp ON public.genbank_region;"
77-
)
74+
op.execute("DROP TRIGGER IF EXISTS genbank_region_set_timestamp ON public.genbank_region;")
7875
op.execute("DROP FUNCTION IF EXISTS public.set_timestamp_genbank_region;")
7976

8077
# drop optional partial unique index (if created)

alembic/versions/0003_rev.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
Create Date: 2025-10-11 10:32:00.000000
55
"""
66

7-
from alembic import op
87
import sqlalchemy as sa
98
from sqlalchemy.dialects.postgresql import JSONB
109

10+
from alembic import op
11+
1112
revision = "0003_rev"
1213
down_revision = "0002_rev"
1314
branch_labels = None
@@ -72,12 +73,8 @@ def upgrade():
7273

7374
# helpful indexes for common lookups
7475
op.create_index("ix_annotation_compound_id", "annotation", ["compound_id"])
75-
op.create_index(
76-
"ix_annotation_genbank_region_id", "annotation", ["genbank_region_id"]
77-
)
78-
op.create_index(
79-
"ix_annotation_scheme_key_value", "annotation", ["scheme", "key", "value"]
80-
)
76+
op.create_index("ix_annotation_genbank_region_id", "annotation", ["genbank_region_id"])
77+
op.create_index("ix_annotation_scheme_key_value", "annotation", ["scheme", "key", "value"])
8178

8279
# JSON metadata indexing (existence/path queries)
8380
op.execute("""
@@ -115,9 +112,7 @@ def downgrade():
115112
op.drop_index("ix_annotation_scheme_key_value", table_name="annotation")
116113
op.drop_index("ix_annotation_genbank_region_id", table_name="annotation")
117114
op.drop_index("ix_annotation_compound_id", table_name="annotation")
118-
op.drop_constraint(
119-
"uq_annotation_target_scheme_key_value", "annotation", type_="unique"
120-
)
115+
op.drop_constraint("uq_annotation_target_scheme_key_value", "annotation", type_="unique")
121116

122117
# drop table
123118
op.drop_table("annotation")

alembic/versions/0004_rev.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
Create Date: 2025-10-14 12:25:00.000000
55
"""
66

7-
from alembic import op
87
import sqlalchemy as sa
98
from sqlalchemy.dialects.postgresql import BIT, JSONB
109

10+
from alembic import op
11+
1112
revision = "0004_rev"
1213
down_revision = "0003_rev"
1314
branch_labels = None
@@ -23,9 +24,7 @@ def upgrade():
2324
op.create_table(
2425
"ruleset",
2526
sa.Column("id", sa.BigInteger, primary_key=True),
26-
sa.Column(
27-
"version", sa.Integer, nullable=False, unique=True
28-
), # auto-assign by trigger
27+
sa.Column("version", sa.Integer, nullable=False, unique=True), # auto-assign by trigger
2928
# store rules as text (YAML) for both monomers and reaction rules, also store sha256 for integrity
3029
sa.Column("matching_rules_yaml", sa.Text, nullable=False),
3130
sa.Column("matching_rules_sha256", sa.String(64), nullable=False, unique=True),
@@ -206,9 +205,7 @@ def upgrade():
206205

207206
def downgrade():
208207
# drop child triggers/indexes/tables first
209-
op.execute(
210-
"DROP TRIGGER IF EXISTS retromol_compound_set_timestamp ON public.retromol_compound;"
211-
)
208+
op.execute("DROP TRIGGER IF EXISTS retromol_compound_set_timestamp ON public.retromol_compound;")
212209
op.execute("DROP FUNCTION IF EXISTS public.set_timestamp_retromol_compound;")
213210
op.drop_index("ix_retromol_compound_ruleset_id", table_name="retromol_compound")
214211
op.drop_index("ix_retromol_compound_compound_id", table_name="retromol_compound")

0 commit comments

Comments
 (0)