Skip to content

Commit

Permalink
Setup linting and formatting dev tools (zenml-io#4)
Browse files Browse the repository at this point in the history
* Move all .py code files into src/.

* Add linting/formatting pre-commit hooks (requires poetry install).

* Refactoring: reformat src/ with scripts/format.sh.

* Add missing docstrings.

* Remove mypy from lint script.

* Moved requirements.txt contents into pyproject.toml.

* Add *.ipynb to spell-checking.sh and fix all spelling issues.

* Include .ipynb notebooks in linting/formatting.

* Reformatted notebooks.

* Fixed linting issues in notebooks.

* Remove hardcoded UUID.
  • Loading branch information
fa9r authored May 4, 2022
1 parent 9fab1c1 commit 94f0bdd
Show file tree
Hide file tree
Showing 26 changed files with 407 additions and 168 deletions.
3 changes: 3 additions & 0 deletions .codespell-ignore-words
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
grey
"\nTo"
iam
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
max-line-length = 79
max-complexity = 18
select = B,C,E,F,W,T4,B9
ignore = E203, E266, E501, W503, F403, F401
exclude = __init__.py, pyproject.toml
7 changes: 7 additions & 0 deletions .flake8_nb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8_nb]
max-line-length = 79
max-complexity = 18
select = B,C,E,F,W,T4,B9
ignore = E402, F811, E501, E999, E226, E225, F401
keep_parsed_notebooks = False
notebook_cell_format = {nb_path}#In[{exec_count}]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ dmypy.json

# for wandb
mlruns

# poetry
*poetry.lock*
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fail_fast: true

repos:
- repo: local
hooks:
- id: lint
name: lint
entry: poetry run bash scripts/lint.sh
language: system
pass_filenames: false

- repo: local
hooks:
- id: spellcheck
name: spellcheck
entry: poetry run bash scripts/check-spelling.sh
language: system
21 changes: 13 additions & 8 deletions 00 - Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"source": [
"from absl import logging as absl_logging\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"absl_logging.set_verbosity(-10000)"
Expand Down Expand Up @@ -93,27 +94,31 @@
"source": [
"from zenml.steps import step\n",
"from zenml.pipelines import pipeline\n",
"import pandas as pd\n",
"\n",
"\n",
"@step\n",
"def a() -> int:\n",
" return 2\n",
"\n",
"\n",
"@step\n",
"def b() -> int:\n",
" return 3\n",
"\n",
"\n",
"@step\n",
"def add(a: int, b: int) -> int:\n",
" print(f'Adding {a} + {b}')\n",
" return a+b\n",
" print(f\"Adding {a} + {b}\")\n",
" return a + b\n",
"\n",
"\n",
"@pipeline\n",
"def my_pipeline(first, second, add):\n",
" f = first()\n",
" s = second()\n",
" add(f, s)\n",
" \n",
"\n",
"\n",
"my_pipeline(\n",
" first=a(),\n",
" second=b(),\n",
Expand Down Expand Up @@ -163,7 +168,7 @@
"metadata": {},
"outputs": [],
"source": [
"p = repo.get_pipeline('my_pipeline')\n",
"p = repo.get_pipeline(\"my_pipeline\")\n",
"p"
]
},
Expand Down Expand Up @@ -273,7 +278,7 @@
" PipelineRunLineageVisualizer,\n",
")\n",
"\n",
"latest_run = repo.get_pipeline('my_pipeline').runs[-1]\n",
"latest_run = repo.get_pipeline(\"my_pipeline\").runs[-1]\n",
"PipelineRunLineageVisualizer().visualize(latest_run)"
]
}
Expand All @@ -294,7 +299,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 94f0bdd

Please sign in to comment.