Skip to content

Commit

Permalink
Merge pull request #138 from edina/nbgrader_0.8.4
Browse files Browse the repository at this point in the history
Nbgrader 0.8.4
  • Loading branch information
alasdair-macleod authored Jul 31, 2023
2 parents 83190f1 + 68b7ca1 commit 19ee804
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@master
- name: Setup Python ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions nbexchange/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def init_logging(self):
See sqlalchemy.create_engine for details.
"""
).tag(config=True)

upgrade_db = Bool(
False,
help="""Upgrade the database automatically on start.
Expand Down
14 changes: 8 additions & 6 deletions nbexchange/dbutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def register_ping_connection(engine):
From SQLAlchemy docs on pessimistic disconnect handling:
https://docs.sqlalchemy.org/en/rel_1_1/core/pooling.html#disconnect-handling-pessimistic
https://docs.sqlalchemy.org/en/20/core/pooling.html#custom-legacy-pessimistic-ping
"""

@event.listens_for(engine, "engine_connect")
Expand All @@ -236,7 +236,7 @@ def ping_connection(connection, branch):
# run a SELECT 1. use a core select() so that
# the SELECT of a scalar value without a table is
# appropriately formatted for the backend
connection.scalar(select([1]))
connection.scalar(select(1))
except exc.DBAPIError as err:
# catch SQLAlchemy's DBAPIError, which is a wrapper
# for the DBAPI's exception. It includes a .connection_invalidated
Expand All @@ -249,7 +249,7 @@ def ping_connection(connection, branch):
# itself and establish a new connection. The disconnect detection
# here also causes the whole connection pool to be invalidated
# so that all stale connections are discarded.
connection.scalar(select([1]))
connection.scalar(select(1))
else:
raise
finally:
Expand Down Expand Up @@ -349,13 +349,15 @@ def setup_db(url="sqlite:///:memory:", reset=False, log=None, **kwargs):
# is ever created.
kwargs.setdefault("poolclass", StaticPool)

engine = create_engine(url, **kwargs)
# From sqlalchemy 2.0, testing pools is now built in
engine = create_engine(url, pool_pre_ping=True, **kwargs)

if url.startswith("sqlite"):
register_foreign_keys(engine)

# enable pessimistic disconnect handling
register_ping_connection(engine)
# not needed: https://docs.sqlalchemy.org/en/20/core/pooling.html#disconnect-handling-pessimistic
# # enable pessimistic disconnect handling
# register_ping_connection(engine)

if reset:
Base.metadata.drop_all(engine)
Expand Down
3 changes: 2 additions & 1 deletion nbexchange/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
must be imported below the declaration for `Alembic`
autogenerate to work.
"""
from sqlalchemy.ext.declarative import declarative_base
# import sqlalchemy.orm as orm
from sqlalchemy.orm import declarative_base

Base = declarative_base()

Expand Down
6 changes: 0 additions & 6 deletions nbexchange/tests/test_smoketest.py

This file was deleted.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ classifiers = [
"Intended Audience :: Education",
]

# nbgrader 0.8.4 requires sqlalchemy 2, which breaks Jupyterhub
# pyjwt limited due to djangorestframework-jwt dependencies
# sqlalchemy spec is whatever nbgrader uses
dependencies = [
"alembic>=1.6.5",
"jupyterhub>=1.4.1",
"nbgrader==0.8.2", # From pypi dated March 28th 2023
"nbgrader==0.8.3",
"psycopg2-binary>=2.8.6",
"pyjwt<2",
"sentry-sdk==1.14.0",
"sqlalchemy>=1.4.3",
"sqlalchemy>=1.4,<3",
"tornado==6.1",
"tornado-prometheus==0.1.1",
]
Expand Down

0 comments on commit 19ee804

Please sign in to comment.