Skip to content

Commit

Permalink
use ruff and python instead of notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Mar 3, 2023
1 parent a103eb0 commit 057efdd
Show file tree
Hide file tree
Showing 45 changed files with 1,814 additions and 3,632 deletions.
46 changes: 27 additions & 19 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,43 @@ on:
workflow_dispatch:

jobs:
sphinx_docs_to_gh-pages:
build-docs:
runs-on: ubuntu-latest
name: Sphinx docs to gh-pages
steps:
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.11.0
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.9
channels: conda-forge,defaults
channel-priority: true
activate-environment: anaconda-client-env
- name: Add conda to system path
run: |
echo $CONDA/bin >> $GITHUB_PATH
- name: Installing the library
shell: bash -l {0}
run: |
sudo apt install pandoc
make plugins
pip install -e .[docs]
- name: Running the Sphinx to gh-pages Action
uses: uibcdf/action-sphinx-docs-to-gh-pages@v1.0-beta.2
env:
TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }}
TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }}
DISPLAY: 1.0
DOCS: True
GDSFACTORY_LAYOUT_PLOTTER: klayout
shell: bash -l {0}
run: |
sudo apt install libglu1-mesa
make plugins-
make docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
branch: main
dir_docs: docs
sphinxopts: ""
path: "./docs/_build/html/"

deploy-docs:
needs: build-docs
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
5 changes: 3 additions & 2 deletions .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ jobs:
TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }}
TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }}
DISPLAY: 1.0
DOCS: True
GDSFACTORY_LAYOUT_PLOTTER: klayout
run: |
mkdir -p $HOME/.tidy3d
echo ${{ secrets.TIDY3D_AUTH }} > $HOME/.tidy3d/auth.json
cd docs
make html
make docs
108 changes: 6 additions & 102 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,121 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 507fb40267012da3720be8866f0792a3817f7d9e
rev: 9260cbc9c84c06022993bfbcc42fdbf0305c5b8e
hooks:
- id: check-yaml
exclude: ^(conda\.recipe/meta\.yaml|conda_build/templates/.*\.yaml|docs/click/meta\.yaml|conda/meta\.yaml|construct.yaml)
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: https://github.com/hakancelikdev/unimport
rev: 33ead41ee30f1d323a9c2fcfd0114297efbbc4d5
hooks:
- id: unimport
args: [--remove, --include-star-import]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 7b69d092ae4885dcc45648538ae780a6326bcd1e
hooks:
- id: isort
files: ubcdpk/.*
args: [--profile, black, --filter-files]

- repo: https://github.com/psf/black
rev: 5d0d5936db2ed7a01c50a374e32753e1afe9cc71
rev: 25d886f52c2bbbb58386ac8050f4e67952507bc7
hooks:
- id: black

# - repo: https://github.com/omnilib/ufmt
# rev: v2.0.0b1
# hooks:
# - id: ufmt
- repo: https://github.com/asottile/blacken-docs
rev: 79ef671d15161b9dbc16ac3760086b5222836583
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
- repo: https://github.com/pycqa/flake8
rev: ed3012d29f107fb0c8e4ef2b77a69c8bf3a85343
hooks:
- id: flake8
entry: pflake8
additional_dependencies: [flake8-docstrings, pyproject-flake8]

- repo: https://github.com/kynan/nbstripout
rev: 1185a8d25bb45ada13f64d9591c14d81d69206bc
hooks:
- id: nbstripout
files: .ipynb

- repo: https://github.com/asottile/pyupgrade
rev: 97ed6fb3cf2e650d4f762ba231c3f04c41797710
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-runtime-typing]

- repo: https://github.com/codespell-project/codespell
rev: 587ee566f61dc3cb7e1af6c44bf85bc5ced4c730
hooks:
- id: codespell
args: ["-L TE,TE/TM,te,ba,FPR,fpr_spacing,ro,nd,donot,schem,pard"]

# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: 98854f809ca9d0e235c0bd5c0ad5e986e02120a4
# hooks:
# - id: shellcheck

- repo: https://github.com/pre-commit/pygrep-hooks
rev: 72bd2c94721ba5b87d0b61f3beab9eb01783ef9c # Use the ref you want to point at
hooks:
- id: python-use-type-annotations

- repo: https://github.com/PyCQA/bandit
rev: d9fe642e01866e460454641bcd14b9de9d2b1478
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "6a0ba1854991b693612486cc84a2254de82d071d"
hooks:
- id: bandit
args: [--exit-zero]
# ignore all tests, not just tests data
exclude: ^tests/
# - repo: https://github.com/PyCQA/pylint
# rev: v2.14.1
# hooks:
# - id: pylint
# args: [--exit-zero]
# - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
# rev: 6565d773ca281682d7062d4c0be74538cc474cc9
# hooks:
# - id: pretty-format-java
# args: [--autofix]
# - id: pretty-format-kotlin
# args: [--autofix]
# - id: pretty-format-yaml
# args: [--autofix, --indent, "2"]
# - repo: https://github.com/adrienverge/yamllint.git
# rev: v1.21.0 # or higher tag
# hooks:
# - id: yamllint
# args: [--format, parsable, --strict]
# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
# rev: 0.1.0 # or specific tag
# hooks:
# - id: yamlfmt
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: "214c33306afe17f1cc7d2d55e4da705b6ebe0627"
# hooks:
# - id: mypy
# exclude: ^(docs/|example-plugin/|tests/fixtures)
# additional_dependencies:
# - "pydantic"
# - repo: https://github.com/terrencepreilly/darglint
# rev: master
# hooks:
# - id: darglint
#
# - repo: https://github.com/pycqa/pydocstyle
# rev: "a6fe4222012e990042c86cdaaa904a8d059752ee"
# hooks:
# - id: pydocstyle
# additional_dependencies: ["pydocstyle[toml]"]
# - repo: https://github.com/asottile/reorder_python_imports
# rev: 2b2f0c74acdb3de316e23ceb7dd0d7945c354050
# hooks:
# - id: reorder-python-imports
- id: ruff
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,17 @@ notebooks:

mask:
python ubcpdk/samples/test_masks.py

jupytext:
jupytext docs/**/*.ipynb --to py

notebooks:
jupytext docs/**/*.py --to ipynb

notebooks-rm:
rm docs/notebooks/*.ipynb

docs:
jb build docs

.PHONY: drc doc docs
1 change: 0 additions & 1 deletion docs/CHANGELOG.md

This file was deleted.

25 changes: 0 additions & 25 deletions docs/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

60 changes: 60 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: ubc
author: SiEPIC

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: cache
timeout: -1
allow_errors: true
# timeout: -1
# execute_notebooks: force
# execute_notebooks: "off"
# exclude_patterns:
# - '*notebooks/devsim/01_pin_waveguide*'

latex:
latex_engine: pdflatex # one of 'pdflatex', 'xelatex' (recommended for unicode), 'luatex', 'platex', 'uplatex'
use_jupyterbook_latex: true # use sphinx-jupyterbook-latex for pdf builds as default

# Add a bibtex file so that we can create citations

html:
home_page_in_navbar: true
use_edit_page_button: true
use_repository_button: true
use_issues_button: true
baseurl: https://github.com/gdsfactory/ubc

# Information about where the book exists on the web
repository:
url: https://github.com/gdsfactory/ubc
path_to_book: docs # Optional path to your book, relative to the repository root
branch: main # Which branch of the repository should be used when creating links (optional)

launch_buttons:
notebook_interface: jupyterlab
colab_url: "https://colab.research.google.com"

sphinx:
extra_extensions:
- "sphinx.ext.autodoc"
- "sphinx.ext.autodoc.typehints"
- "sphinx.ext.autosummary"
- "sphinx.ext.napoleon"
- "sphinx.ext.viewcode"
- "matplotlib.sphinxext.plot_directive"
- "sphinx_click"
- "sphinxcontrib.autodoc_pydantic"
config:
#autodoc_typehints: description
autodoc_type_aliases:
"ComponentSpec": "ComponentSpec"
nb_execution_show_tb: True
nb_custom_formats:
.py:
- jupytext.reads
- fmt: py
16 changes: 0 additions & 16 deletions docs/_static/css/custom.css

This file was deleted.

12 changes: 12 additions & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Table of contents
# Learn more at https://jupyterbook.org/customize/toc.html

format: jb-book
root: index
chapters:
- file: tech
- file: components
- file: tutorial
sections:
- glob: notebooks/*
- file: changelog
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```{include} ../CHANGELOG.md
```
Loading

0 comments on commit 057efdd

Please sign in to comment.