Skip to content

Commit

Permalink
Linting fixes and CI config for multiple Python 3.9+ (#34)
Browse files Browse the repository at this point in the history
* Disable fail-fast

* Disable py38 build

* Remove docs workflow and re-add 3.8 to test matrix

* Linting fixes; set default language version to 3.9 in pre-commit

* Use 3.9 as the default CI version

* Update dummy version tag in tests

* Cancel running CI jobs if new changes are pushed to a PR

* Run pre-commit autoupdate and unpin flake8 plugins

* Add a second dummy test that checks top-level imports

* Drop 3.8 support

* Run linting with new black rules and fix warnings stacklevel warning

* Reinforce python3.9 in pre-commit to avoid linting slosh

* Use Python 3.9 compatible type hints for pydantic objects
  • Loading branch information
ml-evs authored Oct 11, 2023
1 parent 1cfc5b8 commit 3542a70
Show file tree
Hide file tree
Showing 33 changed files with 100 additions and 117 deletions.
31 changes: 9 additions & 22 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:

pull_request:

# Cancel running workflows when additional changes are pushed
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -15,7 +21,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
cache: pip
cache-dependency-path: pyproject.toml

Expand All @@ -30,8 +36,9 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand All @@ -49,23 +56,3 @@ jobs:
- name: Test
run: pytest --cov=jobflow_remote --cov-report=xml

docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[strict,docs]
- name: Build
run: jupyter-book build docs --path-output docs_build
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
default_language_version:
python: python3
python: python3.9
#exclude: '^src/{{ package_name }}/some/directory/'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/myint/autoflake
rev: v2.0.0
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
Expand All @@ -29,18 +29,18 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
entry: pflake8
files: ^src/
additional_dependencies:
- pyproject-flake8==6.0.0
- flake8-bugbear==22.12.6
- flake8-typing-imports==1.14.0
- flake8-docstrings==1.6.0
- flake8-rst-docstrings==0.3.0
- flake8-rst==0.8.0
- pyproject-flake8
- flake8-bugbear
- flake8-typing-imports
- flake8-docstrings
- flake8-rst-docstrings
- flake8-rst
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -49,7 +49,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.6.0
hooks:
- id: mypy
files: ^src/
Expand All @@ -58,13 +58,13 @@ repos:
- types-pkg_resources==0.1.2
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.6
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, 'titel,statics,ba,nd,te,nin']
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
4 changes: 2 additions & 2 deletions doc/source/_static/index-images/api.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions doc/source/_static/index-images/contributor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/source/_static/index-images/getting_started.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/source/_static/index-images/image_licences.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
getting_started.svg: https://www.svgrepo.com/svg/393367/rocket (PD Licence)
user_guide.svg: https://www.svgrepo.com/svg/75531/user-guide (CC0 Licence)
api.svg: https://www.svgrepo.com/svg/157898/gears-configuration-tool (CC0 Licence)
contributor.svg: https://www.svgrepo.com/svg/57189/code-programing-symbol (CC0 Licence)
contributor.svg: https://www.svgrepo.com/svg/57189/code-programing-symbol (CC0 Licence)
4 changes: 2 additions & 2 deletions doc/source/_static/index-images/user_guide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/source/_static/jobflow_remote.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ html[data-theme=dark] h3 {
.sd-btn-secondary:hover, .sd-btn-secondary:focus {
background-color: var(--matgenix-dark-color) !important;
border-color: var(--matgenix-dark-color) !important;
}
}
2 changes: 1 addition & 1 deletion doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ API Reference

This is the API reference

.. include:: jobflow_remote.rst
.. include:: jobflow_remote.rst
34 changes: 17 additions & 17 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -28,6 +27,7 @@


import jobflow_remote

# The short X.Y version
version = jobflow_remote.__version__
# The full version, including alpha/beta/rc tags
Expand All @@ -49,16 +49,16 @@
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon", # For Google Python Style Guide
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.autosummary',
'sphinx.ext.graphviz',
'sphinx.ext.ifconfig',
'matplotlib.sphinxext.plot_directive',
'IPython.sphinxext.ipython_console_highlighting',
'IPython.sphinxext.ipython_directive',
'sphinx.ext.mathjax',
'sphinx_design',
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.autosummary",
"sphinx.ext.graphviz",
"sphinx.ext.ifconfig",
"matplotlib.sphinxext.plot_directive",
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
"sphinx.ext.mathjax",
"sphinx_design",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -78,7 +78,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -95,7 +95,7 @@
# a list of builtin themes.
#
# html_theme = 'sphinx_book_theme'
html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"
# html_favicon = '_static/favicon/favicon.ico'

# Theme options are theme-specific and customize the look and feel of a theme
Expand All @@ -108,7 +108,7 @@
# "image_dark": "index-image/contributor.svg",
# },
"collapse_navigation": True,
'announcement': (
"announcement": (
"<p>"
"Jobflow-Remote is still in beta phase. The API may change at any time."
"</p>"
Expand Down Expand Up @@ -137,14 +137,14 @@
# -- Options for HTMLHelp output ---------------------------------------------

html_css_files = ["jobflow_remote.css"]
html_title = "%s v%s Manual" % (project, version)
html_last_updated_fmt = '%b %d, %Y'
html_title = f"{project} v{version} Manual"
html_last_updated_fmt = "%b %d, %Y"
# html_css_files = ["numpy.css"]
html_context = {"default_mode": "light"}
html_use_modindex = True
html_copy_source = False
html_domain_indices = False
html_file_suffix = '.html'
html_file_suffix = ".html"

# Output file base name for HTML help builder.
htmlhelp_basename = "jobflow_remote_doc"
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
Contributing to Jobflow-Remote
##############################

Here are the things that can be done.
Here are the things that can be done.
1 change: 0 additions & 1 deletion doc/source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Glossary

Worker
The description of a given resource where to execute flows.

2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ Jobflow-Remote is a package to submit jobflow flows remotely.

.. This is not really the index page, that is found in
_templates/indexcontent.html The toctree content here will be added to the
top of the template header
top of the template header
1 change: 0 additions & 1 deletion doc/source/user/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ fundamental Jobflow-Remote ideas and philosophy.
..
.. toctree::
:maxdepth: 1
2 changes: 1 addition & 1 deletion doc/source/user/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Building from source
====================

Get the source from the git repository.
Install it with pip install .
Install it with pip install .
2 changes: 1 addition & 1 deletion doc/source/user/whatisjobflowremote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ What is Jobflow-Remote?
=======================

Jobflow-Remote is ...
TODO: add the features that it has.
TODO: add the features that it has.
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authors = [{ name = "Guido Petretto", email = "[email protected]" }]
dynamic = ["version"]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -24,7 +23,7 @@ classifiers = [
"Topic :: Other/Nonlisted Topic",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies =[
"jobflow[strict]",
"pydantic<2",
Expand Down Expand Up @@ -81,7 +80,7 @@ max-line-length = 88
max-doc-length = 88
select = "C, E, F, W, B"
extend-ignore = "E203, W503, E501, F401, RST21"
min-python-version = "3.8.0"
min-python-version = "3.9.0"
docstring-convention = "numpy"
rst-roles = "class, func, ref, obj"

Expand Down
1 change: 0 additions & 1 deletion src/jobflow_remote/cli/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def flow_info(
flow_ids = [jf_id]

with loading_spinner():

jc = JobController()

flows_info = jc.get_flows_info(
Expand Down
1 change: 0 additions & 1 deletion src/jobflow_remote/cli/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def format_job_info(job_info: JobInfo, show_none: bool = False):


def format_flow_info(flow_info: FlowInfo):

title = f"Flow: {flow_info.name} - {flow_info.flow_id} - {flow_info.state.name}"
table = Table(title=title)
table.title_style = "bold"
Expand Down
1 change: 0 additions & 1 deletion src/jobflow_remote/cli/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def job_info(
db_id, job_id = get_job_db_ids(job_db_id, job_index)

with loading_spinner():

jc = JobController()

job_info = jc.get_job_info(
Expand Down
1 change: 0 additions & 1 deletion src/jobflow_remote/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def convert_metadata(string_metadata: str | None) -> dict | None:


def get_start_date(start_date: datetime | None, days: int | None, hours: int | None):

if start_date and (start_date.year, start_date.month, start_date.day) == (
1900,
1,
Expand Down
Loading

0 comments on commit 3542a70

Please sign in to comment.