diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 541b1697..2b505a1e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -25,20 +25,20 @@ repos: # args: [--in-place, --wrap-summaries=120, --wrap-descriptions=120] - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell additional_dependencies: [tomli] #args: ["--write-changes"] # uncomment if you want to get automatic fixing - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.10.0 hooks: - id: black name: Black code - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.21 hooks: - id: mdformat additional_dependencies: @@ -46,7 +46,7 @@ repos: - mdformat_frontmatter - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.8.6 hooks: - id: ruff args: ["--fix"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fac818ed..a1bfd464 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,6 +149,6 @@ _Note: You might want to set a reference to the main repository to fetch/merge f git remote add upstream https://github.com/nteract/papermill ``` -It's possible you will have conflicts between your repository and main. Here, `main` is meant to be synchronized with the `upstream` repository. GitHub has some good [documentation](https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/) on merging pull requests from the command line. +It's possible you will have conflicts between your repository and main. Here, `main` is meant to be synchronized with the `upstream` repository. GitHub has some good [documentation](https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/) on merging pull requests from the command line. Happy hacking on Papermill! diff --git a/README.md b/README.md index 8f3d6813..3b790500 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ pip install papermill ``` For all optional io dependencies, you can specify individual bundles -like `s3`, or `azure` -- or use `all`. To use Black to format parameters you can add as an extra requires \['black'\]. +like `s3`, or `azure` -- or use `all`. To use Black to format parameters you can add as an extra requires ['black']. ```{.sourceCode .bash} pip install papermill[all] @@ -100,7 +100,7 @@ $ papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1 ``` **NOTE:** -If you use multiple AWS accounts, and you have [properly configured your AWS credentials](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html), then you can specify which account to use by setting the `AWS_PROFILE` environment variable at the command-line. For example: +If you use multiple AWS accounts, and you have [properly configured your AWS credentials](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html), then you can specify which account to use by setting the `AWS_PROFILE` environment variable at the command-line. For example: ```{.sourceCode .bash} $ AWS_PROFILE=dev_account papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1 @@ -154,7 +154,7 @@ Papermill supports the following name handlers for input and output paths during - Local file system: `local` -- HTTP, HTTPS protocol: `http://, https://` +- HTTP, HTTPS protocol: `http://, https://` - Amazon Web Services: [AWS S3](https://aws.amazon.com/s3/) `s3://` diff --git a/binder/cli-simple/pm_example.ipynb b/binder/cli-simple/pm_example.ipynb index 58395577..141fcbec 100644 --- a/binder/cli-simple/pm_example.ipynb +++ b/binder/cli-simple/pm_example.ipynb @@ -64,6 +64,7 @@ ], "source": [ "import os\n", + "\n", "import papermill as pm\n", "\n", "binder_dir = '..'" diff --git a/docs/changelog.md b/docs/changelog.md index 5e5a2a55..82a6b27f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -188,8 +188,8 @@ We made it to our [1.0 milestone goals](https://github.com/nteract/papermill/mil - Input and output paths can now reference input parameters. `my_nb_{nb_type}.ipynb out_{nb_type}.ipynb -p nb_type test` will substitute values into the paths passed in with python format application patterns. - `read_notebook`, `read_notebooks`, `record`, and `display` api functions are now removed. -- \[upstream\] ipywidgets are now supported. See [nbconvert docs](https://nbconvert.readthedocs.io/en/latest/execute_api.html#widget-state) for details. -- \[upstream\] notebook executions which run out of memory no longer hang indefinitely when the kernel dies. +- [upstream] ipywidgets are now supported. See [nbconvert docs](https://nbconvert.readthedocs.io/en/latest/execute_api.html#widget-state) for details. +- [upstream] notebook executions which run out of memory no longer hang indefinitely when the kernel dies. ## 0.19.1 diff --git a/papermill/abs.py b/papermill/abs.py index 665d7f69..0f9d0d15 100644 --- a/papermill/abs.py +++ b/papermill/abs.py @@ -1,4 +1,5 @@ """Utilities for working with Azure blob storage""" + import io import re diff --git a/papermill/adl.py b/papermill/adl.py index 7dd48962..3df13330 100644 --- a/papermill/adl.py +++ b/papermill/adl.py @@ -1,4 +1,5 @@ """Utilities for working with Azure data lake storage""" + import re from azure.datalake.store import core, lib diff --git a/papermill/engines.py b/papermill/engines.py index 4d096ba5..3b7be2d9 100644 --- a/papermill/engines.py +++ b/papermill/engines.py @@ -1,4 +1,5 @@ """Engines to perform different roles""" + import datetime import sys from functools import wraps @@ -169,9 +170,7 @@ def autosave_cell(self): # Autosave is taking too long, so exponentially back off. self.autosave_cell_every *= 2 logger.warning( - "Autosave too slow: {:.2f} sec, over {}% limit. Backing off to {} sec".format( - save_elapsed, self.max_autosave_pct, self.autosave_cell_every - ) + f"Autosave too slow: {save_elapsed:.2f} sec, over {self.max_autosave_pct}% limit. Backing off to {self.autosave_cell_every} sec" ) @catch_nb_assignment diff --git a/papermill/inspection.py b/papermill/inspection.py index 40f6b6c8..d9e8d0b7 100644 --- a/papermill/inspection.py +++ b/papermill/inspection.py @@ -1,4 +1,5 @@ """Deduce parameters of a notebook from the parameters cell.""" + from pathlib import Path import click diff --git a/papermill/log.py b/papermill/log.py index b90225d2..79c7f0d9 100644 --- a/papermill/log.py +++ b/papermill/log.py @@ -1,4 +1,5 @@ """Sets up a logger""" + import logging logger = logging.getLogger('papermill') diff --git a/papermill/models.py b/papermill/models.py index 35c077e5..23bd31dd 100644 --- a/papermill/models.py +++ b/papermill/models.py @@ -1,4 +1,5 @@ """Models used by papermill.""" + from collections import namedtuple Parameter = namedtuple( diff --git a/papermill/tests/notebooks/gcs/gcs_in/gcs-simple_notebook.ipynb b/papermill/tests/notebooks/gcs/gcs_in/gcs-simple_notebook.ipynb index ecee54dc..887c9027 100644 --- a/papermill/tests/notebooks/gcs/gcs_in/gcs-simple_notebook.ipynb +++ b/papermill/tests/notebooks/gcs/gcs_in/gcs-simple_notebook.ipynb @@ -122,6 +122,7 @@ "outputs": [], "source": [ "import time\n", + "\n", "time.sleep(10)" ] }, @@ -147,14 +148,13 @@ "outputs": [], "source": [ "import sys\n", - "from ctypes import CDLL\n", "# This will crash a Linux or Mac system\n", "# equivalent calls can be made on Windows\n", "\n", "# Uncomment these lines if you would like to see the segfault\n", "\n", "# dll = 'dylib' if sys.platform == 'darwin' else 'so.6'\n", - "# libc = CDLL(\"libc.%s\" % dll) \n", + "# libc = CDLL(\"libc.%s\" % dll)\n", "# libc.time(-1) # BOOM!!" ] }, @@ -323,7 +323,9 @@ } ], "source": [ - "import time, sys\n", + "import sys\n", + "import time\n", + "\n", "for i in range(8):\n", " print(i)\n", " time.sleep(0.5)" @@ -333,8 +335,8 @@ "metadata": { "colab": { "name": "test.ipynb", - "version": "0.3.2", - "provenance": [] + "provenance": [], + "version": "0.3.2" }, "kernelspec": { "display_name": "Python 3", diff --git a/papermill/tests/notebooks/keyboard_interrupt.ipynb b/papermill/tests/notebooks/keyboard_interrupt.ipynb index 420d49d8..6b79dc92 100644 --- a/papermill/tests/notebooks/keyboard_interrupt.ipynb +++ b/papermill/tests/notebooks/keyboard_interrupt.ipynb @@ -19,6 +19,7 @@ ], "source": [ "from time import sleep\n", + "\n", "sleep(60)" ] } diff --git a/papermill/tests/notebooks/systemexit.ipynb b/papermill/tests/notebooks/systemexit.ipynb index 2fc4831d..779aaedb 100644 --- a/papermill/tests/notebooks/systemexit.ipynb +++ b/papermill/tests/notebooks/systemexit.ipynb @@ -5,9 +5,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "import sys" - ] + "source": [] }, { "cell_type": "code", diff --git a/papermill/tests/notebooks/test_autosave.ipynb b/papermill/tests/notebooks/test_autosave.ipynb index e3a6cfb7..dfe63c16 100644 --- a/papermill/tests/notebooks/test_autosave.ipynb +++ b/papermill/tests/notebooks/test_autosave.ipynb @@ -15,6 +15,7 @@ ], "source": [ "import time\n", + "\n", "for i in range(25): # This will take 2.5 seconds\n", " time.sleep(0.1)\n", " print(i)" diff --git a/papermill/tests/notebooks/test_logging.ipynb b/papermill/tests/notebooks/test_logging.ipynb index ec390567..a251f385 100644 --- a/papermill/tests/notebooks/test_logging.ipynb +++ b/papermill/tests/notebooks/test_logging.ipynb @@ -15,6 +15,7 @@ ], "source": [ "import logging\n", + "\n", "logger = logging.getLogger(\"test\")\n", "logger.setLevel(logging.INFO)\n", "logging.basicConfig(level=logging.INFO)\n", @@ -66,8 +67,10 @@ ], "source": [ "import warnings\n", + "\n", "warnings.simplefilter(action='ignore', category=FutureWarning)\n", "from ggplot import mpg\n", + "\n", "mpg['cty'].plot.hist(bins=12)" ] },