Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to hatch #749

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c69a578
update docs dependencies
willingc Nov 15, 2023
03f8595
install requirements for docs
willingc Nov 15, 2023
3f0fae6
remove dependencies and use pyproject.toml
willingc Nov 15, 2023
b049521
remove setuptools config
willingc Nov 15, 2023
3479672
update pyproject.toml
willingc Nov 16, 2023
9bc991c
remove tox
willingc Nov 16, 2023
7e5cdb4
remove some tox references
willingc Nov 16, 2023
6124299
Add pyproject.toml entries for hatch and turn off autocommit for now
willingc Nov 17, 2023
049509e
add flake8 to pyproject.toml and remove docs requirements file
willingc Nov 17, 2023
b6fc0f4
swap flake8p for flake8 in precommit
willingc Nov 17, 2023
0bb5752
just use ruff
willingc Nov 17, 2023
cc52363
fix end of file and add ruff per file ignores
willingc Nov 17, 2023
7284dc6
black files
willingc Nov 17, 2023
09572be
align black and ruff
willingc Nov 17, 2023
1ca45eb
remove black hook
willingc Nov 17, 2023
7b9b311
update ci pass 1
willingc Nov 17, 2023
e41cca4
ignore per file warnings
willingc Nov 17, 2023
dbd236f
add missed warning
willingc Nov 17, 2023
af6ab4d
ignore annoying stack level warning
willingc Nov 17, 2023
999c196
Update docs ci
willingc Nov 17, 2023
99a43e0
correct sphinx build command
willingc Nov 17, 2023
3fcb36d
troubleshoot ci
willingc Nov 17, 2023
7db11f6
troubleshoot ci
willingc Nov 17, 2023
1540d56
update docs build
willingc Nov 17, 2023
a117394
update ci
willingc Nov 17, 2023
bae4f6e
update doc deps
willingc Nov 17, 2023
db13d32
more more more
willingc Nov 17, 2023
9ef5266
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ on:
branches: ["main"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
STABLE_PYTHON_VERSION: '3.11'
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
tests:
name: "Python ${{ matrix.python-version }}"
Expand All @@ -21,42 +30,37 @@ jobs:

steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-python@v4"

- name: Set up Python ${{ matrix.python-version }}
uses: "actions/setup-python@v4"
with:
python-version: ${{ matrix.python-version }}
- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel coverage[toml] virtualenv tox tox-gh-actions

- name: "Run tox targets for ${{ matrix.python-version }}"
run: python -m tox
- name: "Upgrade pip"
run: python -m pip install --upgrade pip

- name: "Generate coverage XML"
if: "contains(env.USING_COVERAGE, matrix.python-version)"
run: python -m coverage xml
- name: "Install hatch"
run: pip install hatch

- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
- name: "Run tests for ${{ matrix.python-version }}"
run: hatch run test

others:
runs-on: ubuntu-20.04
docs:
name: Documentation
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
toxenv: ["manifest", "docs", "binder"]
env:
TOXENV: ${{ matrix.toxenv }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: "Install dependencies"
run: |
set -xe
python -m pip install virtualenv tox
- name: "Run tox targets for ${{ matrix.toxenv }}"
run: python -m tox

- name: "Upgrade pip"
run: python -m pip install --upgrade pip

- name: "Install hatch"
run: pip install hatch

- name: "Build docs"
run: hatch run docs:ci-build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
Expand Down
42 changes: 11 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
default_language_version:
python: python3.8
python: python3.10

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly
# submodules: true
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -21,31 +20,21 @@ repos:
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.2
hooks:
- id: ruff
args:
- --fix
- id: ruff-format

Comment on lines +23 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.2
hooks:
- id: ruff
args:
- --fix
- id: ruff-format

already added with switch flake8 -> ruff #752

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]
name: Upgrade code

#- repo: https://github.com/myint/docformatter
# rev: v1.5.0
# hooks:
# - id: docformatter
# args: [--in-place, --wrap-summaries=120, --wrap-descriptions=120]

#- repo: https://github.com/PyCQA/isort
# rev: 5.10.1
# hooks:
# - id: isort

- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
name: Black code
args: ["-S"]
Comment on lines -42 to -47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why drop Black?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this adds ruff-format instead.


- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand All @@ -58,12 +47,3 @@ repos:
rev: v1.5.0
hooks:
- id: yesqa

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
arge:
- "--count"
- "--show-source"
- "--statistics"
40 changes: 0 additions & 40 deletions MANIFEST.in

This file was deleted.

12 changes: 5 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'UPDATE.md']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
pygments_style = 'sphinx'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets fo these changes in separate PR so it is easier to follow what is the main change/focus of this PR


# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -90,22 +90,22 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "furo"
html_theme = 'furo'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
"sidebar_hide_name": True,
'sidebar_hide_name': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_logo = "_static/images/papermill.png"
html_logo = '_static/images/papermill.png'

# -- Options for HTMLHelp output ------------------------------------------

Expand All @@ -132,9 +132,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'papermill.tex', 'papermill Documentation', 'nteract team', 'manual')
]
latex_documents = [(master_doc, 'papermill.tex', 'papermill Documentation', 'nteract team', 'manual')]


# -- Options for manual page output ---------------------------------------
Expand Down
10 changes: 0 additions & 10 deletions docs/requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions papermill/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .version import version as __version__

from .exceptions import PapermillException, PapermillExecutionError
from .execute import execute_notebook
from .inspection import inspect_notebook
from .version import version as __version__
28 changes: 14 additions & 14 deletions papermill/abs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Utilities for working with Azure blob storage"""
import re
import io
import re

from azure.storage.blob import BlobServiceClient
from azure.identity import EnvironmentCredential
from azure.storage.blob import BlobServiceClient


class AzureBlobStore:
Expand All @@ -20,7 +20,7 @@ class AzureBlobStore:

def _blob_service_client(self, account_name, sas_token=None):
blob_service_client = BlobServiceClient(
account_url=f"{account_name}.blob.core.windows.net",
account_url=f'{account_name}.blob.core.windows.net',
credential=sas_token or EnvironmentCredential(),
)

Expand All @@ -32,38 +32,38 @@ def _split_url(self, url):
see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501
abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken
"""
match = re.match(r"abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/([^\?]*)\??(.*)$", url)
match = re.match(r'abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/([^\?]*)\??(.*)$', url)
if not match:
raise Exception(f"Invalid azure blob url '{url}'")
else:
params = {
"account": match.group(1),
"container": match.group(2),
"blob": match.group(3),
"sas_token": match.group(4),
'account': match.group(1),
'container': match.group(2),
'blob': match.group(3),
'sas_token': match.group(4),
}
return params

def read(self, url):
"""Read storage at a given url"""
params = self._split_url(url)
output_stream = io.BytesIO()
blob_service_client = self._blob_service_client(params["account"], params["sas_token"])
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
blob_client = blob_service_client.get_blob_client(params['container'], params['blob'])
blob_client.download_blob().readinto(output_stream)
output_stream.seek(0)
return [line.decode("utf-8") for line in output_stream]
return [line.decode('utf-8') for line in output_stream]

def listdir(self, url):
"""Returns a list of the files under the specified path"""
params = self._split_url(url)
blob_service_client = self._blob_service_client(params["account"], params["sas_token"])
container_client = blob_service_client.get_container_client(params["container"])
return list(container_client.list_blobs(params["blob"]))
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
container_client = blob_service_client.get_container_client(params['container'])
return list(container_client.list_blobs(params['blob']))

def write(self, buf, url):
"""Write buffer to storage at a given url"""
params = self._split_url(url)
blob_service_client = self._blob_service_client(params["account"], params["sas_token"])
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
blob_client = blob_service_client.get_blob_client(params['container'], params['blob'])
blob_client.upload_blob(data=buf, overwrite=True)
7 changes: 1 addition & 6 deletions papermill/adl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def listdir(self, url):
"""Returns a list of the files under the specified path"""
(store_name, path) = self._split_url(url)
adapter = self._create_adapter(store_name)
return [
"adl://{store_name}.azuredatalakestore.net/{path_to_child}".format(
store_name=store_name, path_to_child=path_to_child
)
for path_to_child in adapter.ls(path)
]
return [f'adl://{store_name}.azuredatalakestore.net/{path_to_child}' for path_to_child in adapter.ls(path)]

def read(self, url):
"""Read storage at a given url"""
Expand Down
Loading
Loading