From 968081f07c59a07f70c3556c6cd647f4cade09aa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 20:00:18 -0700 Subject: [PATCH 01/14] [pre-commit.ci] pre-commit autoupdate (#107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.6.0) - [github.com/asottile/pyupgrade: v3.3.1 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.17.0) - [github.com/pycqa/isort: 5.12.0 → 5.13.2](https://github.com/pycqa/isort/compare/5.12.0...5.13.2) - [github.com/psf/black: 23.3.0 → 24.8.0](https://github.com/psf/black/compare/23.3.0...24.8.0) - [github.com/PyCQA/flake8: 6.0.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/6.0.0...7.1.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 10 +++++----- jupyter_cache/base.py | 1 + jupyter_cache/cli/commands/cmd_main.py | 1 + jupyter_cache/entry_points.py | 1 + jupyter_cache/executors/utils.py | 14 ++++++++------ jupyter_cache/readers.py | 1 + 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index acdb270..b8e0f70 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-json - id: check-yaml @@ -17,23 +17,23 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.1.1 hooks: - id: flake8 diff --git a/jupyter_cache/base.py b/jupyter_cache/base.py index a033fbf..2df9d74 100644 --- a/jupyter_cache/base.py +++ b/jupyter_cache/base.py @@ -3,6 +3,7 @@ API access to the cache should use this interface, with no assumptions about the backend storage/retrieval mechanisms. """ + from abc import ABC, abstractmethod import io from pathlib import Path diff --git a/jupyter_cache/cli/commands/cmd_main.py b/jupyter_cache/cli/commands/cmd_main.py index 1581902..59020e2 100644 --- a/jupyter_cache/cli/commands/cmd_main.py +++ b/jupyter_cache/cli/commands/cmd_main.py @@ -1,4 +1,5 @@ """The main `jcache` click group.""" + import click from jupyter_cache.cli import options diff --git a/jupyter_cache/entry_points.py b/jupyter_cache/entry_points.py index 846768d..22ccd3f 100644 --- a/jupyter_cache/entry_points.py +++ b/jupyter_cache/entry_points.py @@ -1,4 +1,5 @@ """Module for dealing with entry points.""" + from typing import Optional, Set # TODO importlib.metadata was introduced into the standard library in python 3.8 diff --git a/jupyter_cache/executors/utils.py b/jupyter_cache/executors/utils.py index 33f4df8..0a9f492 100644 --- a/jupyter_cache/executors/utils.py +++ b/jupyter_cache/executors/utils.py @@ -94,12 +94,14 @@ def create_cache_bundle( project_nb.nb, project_nb.uri, # TODO retrieve assets that have changed file mtime? - artifacts=NbArtifacts( - [p for p in Path(execdir).glob("**/*") if p not in asset_files], - execdir, - ) - if (execdir is not None and asset_files is not None) - else None, + artifacts=( + NbArtifacts( + [p for p in Path(execdir).glob("**/*") if p not in asset_files], + execdir, + ) + if (execdir is not None and asset_files is not None) + else None + ), data={"execution_seconds": exec_time}, traceback=exec_tb, ) diff --git a/jupyter_cache/readers.py b/jupyter_cache/readers.py index 669198f..a246f68 100644 --- a/jupyter_cache/readers.py +++ b/jupyter_cache/readers.py @@ -1,4 +1,5 @@ """Module for handling different functions to read "notebook-like" files.""" + from typing import Any, Callable, Dict, Set import nbformat as nbf From 960ee31c3fd3b7633c4f62fab4ec3de10c26ed20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Sep 2024 01:34:17 -0700 Subject: [PATCH 02/14] MAINT: pre-commit config updates (#118) * MAINT: only doing monthly pre-commit update * MAINT: removing pre-commit GHA as it's in maintenance-only mode in favour of pre-commit.ci that we already use --- .github/workflows/tests.yml | 12 ------------ .pre-commit-config.yaml | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 205d1f9..b24a13e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,18 +9,6 @@ on: jobs: - pre-commit: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - uses: pre-commit/action@v3.0.0 - tests: strategy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8e0f70..c44f858 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,9 @@ exclude: > \.vscode/settings\.json )$ +ci: + autoupdate_schedule: 'monthly' + repos: - repo: https://github.com/pre-commit/pre-commit-hooks From a5efd20643b255de5ecfa8974aecdd6300fe4497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A8=97=E0=A8=97=E0=A8=A8=E0=A8=A6=E0=A9=80=E0=A8=AA=20?= =?UTF-8?q?=E0=A8=B8=E0=A8=BF=E0=A9=B0=E0=A8=98=20=28Gagandeep=20Singh=29?= Date: Mon, 16 Sep 2024 14:06:11 +0530 Subject: [PATCH 03/14] DEV: Update API calls to ``datetime`` functionality (#117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DEV: Update API calls to datetime functionality * DEV: Use newer APIs for Python >= 3.11 * DEV: Use datetime API without depending upon Python version * MISC: Remove unused import * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Brigitta Sipőcz --- jupyter_cache/cache/db.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/jupyter_cache/cache/db.py b/jupyter_cache/cache/db.py index e1a4cd0..de39943 100644 --- a/jupyter_cache/cache/db.py +++ b/jupyter_cache/cache/db.py @@ -1,5 +1,5 @@ from contextlib import contextmanager -from datetime import datetime +import datetime import os from pathlib import Path from typing import Any, Dict, List, Optional, Union @@ -51,6 +51,10 @@ def get_version(path: Union[str, Path]) -> Optional[str]: return version_file.read_text().strip() +def datetime_utcnow(): + return lambda: datetime.datetime.now(datetime.timezone.utc) + + @contextmanager def session_context(engine: Engine): """Open a connection to the database.""" @@ -128,7 +132,7 @@ class NbProjectRecord(OrmBase): """A list of file assets required for the notebook to run.""" exec_data = Column(JSON(), nullable=True) """Data on how to execute the notebook.""" - created = Column(DateTime, nullable=False, default=datetime.utcnow) + created = Column(DateTime, nullable=False, default=datetime_utcnow()) traceback = Column(Text(), nullable=True, default="") """A traceback is added if a notebook fails to execute fully.""" @@ -288,9 +292,9 @@ class NbCacheRecord(OrmBase): description = Column(String(255), nullable=False, default="") data = Column(JSON()) """Extra data, such as the execution time.""" - created = Column(DateTime, nullable=False, default=datetime.utcnow) + created = Column(DateTime, nullable=False, default=datetime_utcnow()) accessed = Column( - DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow + DateTime, nullable=False, default=datetime_utcnow(), onupdate=datetime_utcnow() ) def __repr__(self): @@ -368,7 +372,7 @@ def touch(pk, db: Engine): record = session.query(NbCacheRecord).filter_by(pk=pk).one_or_none() if record is None: raise KeyError(f"Cache record not found for NB with PK: {pk}") - record.accessed = datetime.utcnow() + record.accessed = datetime_utcnow()() session.commit() def touch_hashkey(hashkey, db: Engine): @@ -379,7 +383,7 @@ def touch_hashkey(hashkey, db: Engine): ) if record is None: raise KeyError(f"Cache record not found for NB with hashkey: {hashkey}") - record.accessed = datetime.utcnow() + record.accessed = datetime_utcnow()() session.commit() @staticmethod From 7beaee2bf6b7c15e56b8dd155b3acef0fd817e85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:36:26 +0100 Subject: [PATCH 04/14] Bump actions/setup-python from 4 to 5 (#121) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b24a13e..a6019c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -57,7 +57,7 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: install flit From 1d2cda06f987bb7d7d666882d371d64980a66275 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:36:31 +0100 Subject: [PATCH 05/14] Bump actions/checkout from 3 to 4 (#122) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a6019c5..7a8b5e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -55,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: From 50ee4d3aa15ebb25086d471738e2e8ff05c529cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Sep 2024 01:37:54 -0700 Subject: [PATCH 06/14] MAINT: remove upper limit of pytest (#115) * MAINT: remove upper limit of pytest * MAINT: update actions' versions * Update .github/workflows/tests.yml --------- Co-authored-by: Angus Hollands --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c34dbf1..6021cd4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ testing = [ "nbformat>=5.1", "numpy", "pandas", - "pytest>=6,<8", + "pytest>=6", "pytest-cov", "pytest-regressions", "sympy", From e12e9ad1c8ae93e3ebbc3ae22926182250c1879d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Sep 2024 01:38:06 -0700 Subject: [PATCH 07/14] CI: add cron and workflow dispatch (#119) * CI: default branch has been renamed * CI: adding cron * CI: adding workflow_dispatch --------- Co-authored-by: Angus Hollands --- .github/workflows/tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7a8b5e8..67294ca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,10 +2,14 @@ name: continuous-integration on: push: - branches: [master] + branches: + - main tags: - - 'v*' + - '*' pull_request: + schedule: + - cron: '0 5 * * 1' + workflow_dispatch: jobs: From fe94451342cffc7aa81abd63976e8b0b7bfa169e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Sep 2024 10:50:52 -0700 Subject: [PATCH 08/14] CI: don't realy on non-existing job any more (#126) --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67294ca..22a4688 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,7 +54,7 @@ jobs: publish: name: Publish to PyPi - needs: [pre-commit, tests] + needs: [tests] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: From 50ee895c7b0a2e9a0365b100601f1ed5a38b1157 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:04:50 -0700 Subject: [PATCH 09/14] [pre-commit.ci] pre-commit autoupdate (#128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c44f858..6d49fb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-json - id: check-yaml From 6fc92da2fcd6027c372aaf72356ab2bda5f98443 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:14:05 -0800 Subject: [PATCH 10/14] [pre-commit.ci] pre-commit autoupdate (#129) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.17.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.19.0) - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d49fb7..f9a2f83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.0 hooks: - id: pyupgrade args: [--py37-plus] @@ -31,7 +31,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black From 1c5f6d174112c7021161d86fe1505506845c076e Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Fri, 15 Nov 2024 14:30:50 +0000 Subject: [PATCH 11/14] maint: disable codecov (#131) --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 22a4688..b46e030 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,8 @@ jobs: # for some reason the tests/conftest.py::check_nbs fixture breaks pytest-cov's cov-report outputting # this is why we run `coverage xml` afterwards (required by codecov) - name: Upload to Codecov - if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + # FIXME: disable broken codecov + if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' && false uses: codecov/codecov-action@v3 with: name: jupyter-cache-pytests-py3.10 From 0de930a7a85e410783ff9ea3490612f5beb5be95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 15 Nov 2024 07:56:05 -0800 Subject: [PATCH 12/14] MAINT: update dependabot config (#127) * MAINT: switching to monthly dependabot and use only for actions * CI: group dependabot updates * CI: update codecov action version --------- Co-authored-by: Angus Hollands --- .github/dependabot.yml | 13 +++++++------ .github/workflows/tests.yml | 5 ++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d21cf00..42ecbd4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,12 +5,13 @@ version: 2 updates: - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "weekly" - - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "monthly" + groups: + actions: + patterns: + - "*" + labels: + - "github_actions" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b46e030..3906078 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,9 +43,8 @@ jobs: # for some reason the tests/conftest.py::check_nbs fixture breaks pytest-cov's cov-report outputting # this is why we run `coverage xml` afterwards (required by codecov) - name: Upload to Codecov - # FIXME: disable broken codecov - if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' && false - uses: codecov/codecov-action@v3 + if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v4 with: name: jupyter-cache-pytests-py3.10 flags: pytests From 65578f9a5a5ac534554854c790c4bf8c9931609d Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Fri, 15 Nov 2024 15:57:06 +0000 Subject: [PATCH 13/14] chore: bump version (#133) --- jupyter_cache/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_cache/__init__.py b/jupyter_cache/__init__.py index dc565cf..b546e0a 100644 --- a/jupyter_cache/__init__.py +++ b/jupyter_cache/__init__.py @@ -1,5 +1,5 @@ # NOTE: never import anything here, in order to maintain CLI speed -__version__ = "1.0.0" +__version__ = "1.0.1" def get_cache(path, cache_cls=None): From 16f0dbd283a03c6a757dfed65d7173735a7c93d7 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Fri, 15 Nov 2024 15:59:33 +0000 Subject: [PATCH 14/14] fix: disable uploader for now --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3906078..8424629 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: # for some reason the tests/conftest.py::check_nbs fixture breaks pytest-cov's cov-report outputting # this is why we run `coverage xml` afterwards (required by codecov) - name: Upload to Codecov - if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + if: github.repository == 'executablebooks/jupyter-cache' && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' && false uses: codecov/codecov-action@v4 with: name: jupyter-cache-pytests-py3.10