Skip to content

Commit

Permalink
build(retrocookie): reflect updates to source template from generated…
Browse files Browse the repository at this point in the history
… project 'science-institute_brain-lab'
  • Loading branch information
Joseph Burling committed Apr 21, 2022
1 parent 8c0a968 commit 6340195
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: name-tests-test
args: ["--django"]
- id: check-added-large-files
args: ["--maxkb=5000"]
args: ["--maxkb=25000"]
- id: end-of-file-fixer
exclude: LICENSE
- id: mixed-line-ending
Expand All @@ -43,12 +43,11 @@ repos:
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args:
- "--settings-file"
- "./pyproject.toml"

# Run black on python code blocks in documentation files.
# run black on python code blocks in documentation files.
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
Expand All @@ -60,3 +59,17 @@ repos:
rev: 0.5.0
hooks:
- id: nbstripout

# python linting
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: ^tests/(integration/fixtures|unit/data)/
args:
# making isort line length compatible with black
# https://flake8.pycqa.org/en/latest/user/error-codes.html
- "--max-line-length=88"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"
- "--ignore=E203,E266,E501,W503,F403,F401,E402"
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"vivaxy.vscode-conventional-commits",
"yzhang.markdown-all-in-one"
],
"features": {
"github": "latest"
},
"service": "devcontainer_env",
// Set *default* container specific settings.json values on container create.
"settings": {
Expand Down Expand Up @@ -69,5 +66,6 @@
"python.terminal.activateEnvironment": true
},
"shutdownAction": "none",
"workspaceFolder": "/home/{{cookiecutter.github_user}}/{{cookiecutter.__org}}_{{cookiecutter.__wf}}"
"workspaceFolder": "/home/{{cookiecutter.github_user}}/{{cookiecutter.__org}}_{{cookiecutter.__wf}}",
"initializeCommand": "test -f \"${localWorkspaceFolder}/.env\" || exit 1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ services:
- /bin/bash
- -c
- |
wf_entrypoint --help &
{{cookiecutter.__pkg_import_name}}_entrypoint --help &
tail -f /dev/null
31 changes: 26 additions & 5 deletions datajoint-workflow/{{cookiecutter.github_repo}}/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import argparse
import os
import re

import nox
Expand Down Expand Up @@ -100,6 +101,17 @@ def git_action_bot(
session.run("git", "push", *push, external=True)


@nox.session(python=default_python_version, reuse_venv=True)
def run_entrypoint(session: nox.Session) -> None:
"""Install all dependencies then run package entrypoint 'help'.
nox -s run_entrypoint
"""

install_dependencies(session, "dev", "test", "doc", "sciops")
session.run("{{cookiecutter.__pkg_import_name}}_entrypoint", "--help")


@nox.session(python=default_python_version, reuse_venv=True)
def write_version(session: nox.Session) -> None:
"""Bump version.py to the latest version.
Expand Down Expand Up @@ -137,19 +149,28 @@ def pre_commit(session: nox.Session) -> None:
install_dependencies(session, "dev")
session.run("pre-commit", "install")

failed_hooks = []
failed_hooks = {}
log_file = ".nox.pre-commit.log"
for hook in hooks:
try:
session.run("pre-commit", "run", "--all-files", "-v", hook)
with open(log_file, "w") as fout:
session.run("pre-commit", "run", "--all-files", hook, stdout=fout)

except Exception as err:
session.log(err)
failed_hooks.append(hook)
with open(log_file, "r") as fin:
failed_hooks[hook] = fin.read()

finally:
os.remove(log_file)

if failed_hooks:
failed_str = "Failed pre-commit hooks:"
failed_str += "".join([f"\n - {hk}" for hk in failed_hooks])
failed_str += "".join(
[f"\n::{hk}\n\n{txt}\n" for hk, txt in failed_hooks.items()]
)
if raise_exception:
raise SyntaxError(failed_str)
session.error(failed_str)
else:
session.log(failed_str)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["black", "flake8", "pre-commit", "nox", "mypy"]
dev = ["black", "isort", "flake8", "pre-commit", "nox", "mypy"]
doc = [
"mkdocs",
"mkdocstrings-python",
Expand All @@ -65,7 +65,7 @@ test = ["pytest"]
sciops = ["ipykernel", "djsciops", "datajoint>=0.13.4"]

[project.scripts]
wf_entrypoint = "{{cookiecutter.__pkg_import_name}}.entrypoint:cli"
{{cookiecutter.__pkg_import_name}}_entrypoint = "{{cookiecutter.__pkg_import_name}}.entrypoint:cli"

[project.urls]
Homepage = "{{cookiecutter.homepage_url}}"
Expand Down

0 comments on commit 6340195

Please sign in to comment.