Skip to content

Commit

Permalink
style and type-check
Browse files Browse the repository at this point in the history
  • Loading branch information
alex75 committed Jul 25, 2024
1 parent 4f8d768 commit 0e34e00
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ In case of database structure upgrade, developers must follow these steps:

For details about the alembic migration tool, see the [Alembic tutorial](https://alembic.sqlalchemy.org/en/latest/tutorial.html).


## License

```
Expand Down
2 changes: 1 addition & 1 deletion alembic/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Generic single-database configuration.
Generic single-database configuration.
4 changes: 2 additions & 2 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def run_migrations_online() -> None:
alembic.context.configure(
connection=connection,
target_metadata=cacholote.database.Base.metadata,
version_table='alembic_version_cacholote'
version_table="alembic_version_cacholote",
)

with alembic.context.begin_transaction():
alembic.context.run_migrations()


if context.is_offline_mode():
if alembic.context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""add created_at and rename timestamp column.
Revision ID: a38663d192e5
Revises:
Revises:
Create Date: 2024-07-24 15:53:43.989464
"""
import datetime

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op
import cacholote
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'a38663d192e5'
revision: str = "a38663d192e5"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
Expand Down
6 changes: 5 additions & 1 deletion cacholote/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
import datetime
import functools
import json
import os
import warnings
from typing import Any

import sqlalchemy as sa
import sqlalchemy.orm
import sqlalchemy_utils

import alembic.command
import alembic.config

from . import utils

Expand Down Expand Up @@ -116,7 +121,6 @@ def cached_sessionmaker(url: str, **kwargs: Any) -> sa.orm.sessionmaker[sa.orm.S
return _cached_sessionmaker(url, **_encode_kwargs(**kwargs))



def init_database(connection_string: str, force: bool = False) -> sa.engine.Engine:
"""
Make sure the db located at URI `connection_string` exists updated and return the engine object.
Expand Down
1 change: 1 addition & 0 deletions ci/environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ dependencies:
- zarr
- pip:
- pytest-structlog
- types-sqlalchemy-utils
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies:
- pydantic
- pydantic-settings
- sqlalchemy>=2.0.9
- sqlalchemy-utils
- structlog
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = [
"pydantic",
"pydantic-settings",
"sqlalchemy>=2.0.9",
"sqlalchemy_utils",
"structlog"
]
description = "Efficiently cache calls to functions"
Expand Down

0 comments on commit 0e34e00

Please sign in to comment.