Skip to content

Commit 1f3b307

Browse files
authored
Merge branch 'main' into MAINT_adding_py313
2 parents 8aec1d1 + e12e9ad commit 1f3b307

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,17 @@ name: continuous-integration
22

33
on:
44
push:
5-
branches: [master]
5+
branches:
6+
- main
67
tags:
7-
- 'v*'
8+
- '*'
89
pull_request:
10+
schedule:
11+
- cron: '0 5 * * 1'
12+
workflow_dispatch:
913

1014

1115
jobs:
12-
pre-commit:
13-
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python 3.9
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: "3.9"
22-
- uses: pre-commit/action@v3.0.0
23-
2416
tests:
2517

2618
strategy:
@@ -35,9 +27,9 @@ jobs:
3527
runs-on: ${{ matrix.os }}
3628

3729
steps:
38-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3931
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v4
32+
uses: actions/setup-python@v5
4133
with:
4234
python-version: ${{ matrix.python-version }}
4335
allow-prereleases: true
@@ -68,9 +60,9 @@ jobs:
6860
runs-on: ubuntu-latest
6961
steps:
7062
- name: Checkout source
71-
uses: actions/checkout@v3
63+
uses: actions/checkout@v4
7264
- name: Set up Python
73-
uses: actions/setup-python@v4
65+
uses: actions/setup-python@v5
7466
with:
7567
python-version: "3.10"
7668
- name: install flit

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ exclude: >
66
\.vscode/settings\.json
77
)$
88
9+
ci:
10+
autoupdate_schedule: 'monthly'
11+
912
repos:
1013

1114
- repo: https://github.com/pre-commit/pre-commit-hooks

jupyter_cache/cache/db.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from contextlib import contextmanager
2-
from datetime import datetime
2+
import datetime
33
import os
44
from pathlib import Path
55
from typing import Any, Dict, List, Optional, Union
@@ -51,6 +51,10 @@ def get_version(path: Union[str, Path]) -> Optional[str]:
5151
return version_file.read_text().strip()
5252

5353

54+
def datetime_utcnow():
55+
return lambda: datetime.datetime.now(datetime.timezone.utc)
56+
57+
5458
@contextmanager
5559
def session_context(engine: Engine):
5660
"""Open a connection to the database."""
@@ -128,7 +132,7 @@ class NbProjectRecord(OrmBase):
128132
"""A list of file assets required for the notebook to run."""
129133
exec_data = Column(JSON(), nullable=True)
130134
"""Data on how to execute the notebook."""
131-
created = Column(DateTime, nullable=False, default=datetime.utcnow)
135+
created = Column(DateTime, nullable=False, default=datetime_utcnow())
132136
traceback = Column(Text(), nullable=True, default="")
133137
"""A traceback is added if a notebook fails to execute fully."""
134138

@@ -288,9 +292,9 @@ class NbCacheRecord(OrmBase):
288292
description = Column(String(255), nullable=False, default="")
289293
data = Column(JSON())
290294
"""Extra data, such as the execution time."""
291-
created = Column(DateTime, nullable=False, default=datetime.utcnow)
295+
created = Column(DateTime, nullable=False, default=datetime_utcnow())
292296
accessed = Column(
293-
DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow
297+
DateTime, nullable=False, default=datetime_utcnow(), onupdate=datetime_utcnow()
294298
)
295299

296300
def __repr__(self):
@@ -368,7 +372,7 @@ def touch(pk, db: Engine):
368372
record = session.query(NbCacheRecord).filter_by(pk=pk).one_or_none()
369373
if record is None:
370374
raise KeyError(f"Cache record not found for NB with PK: {pk}")
371-
record.accessed = datetime.utcnow()
375+
record.accessed = datetime_utcnow()()
372376
session.commit()
373377

374378
def touch_hashkey(hashkey, db: Engine):
@@ -379,7 +383,7 @@ def touch_hashkey(hashkey, db: Engine):
379383
)
380384
if record is None:
381385
raise KeyError(f"Cache record not found for NB with hashkey: {hashkey}")
382-
record.accessed = datetime.utcnow()
386+
record.accessed = datetime_utcnow()()
383387
session.commit()
384388

385389
@staticmethod

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ testing = [
7272
"nbformat>=5.1",
7373
"numpy",
7474
"pandas",
75-
"pytest>=6,<8",
75+
"pytest>=6",
7676
"pytest-cov",
7777
"pytest-regressions",
7878
"sympy",

0 commit comments

Comments
 (0)