Skip to content

Commit

Permalink
Merge pull request #46 from gdsfactory/update_gdsfactory
Browse files Browse the repository at this point in the history
update_gdsfactory
  • Loading branch information
joamatab authored May 4, 2024
2 parents 10976ad + e22d660 commit f5c0b47
Show file tree
Hide file tree
Showing 35 changed files with 764 additions and 1,326 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
name: Sphinx docs to gh-pages
name: build docs

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-docs:
runs-on: ubuntu-latest
name: Sphinx docs to gh-pages
container: ghcr.io/gdsfactory/gdsfactory:main
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Installing the library
env:
TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }}
TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }}
SIMCLOUD_APIKEY: ${{ secrets.SIMCLOUD_APIKEY }}
DISPLAY: 1.0
DOCS: True
GDSFACTORY_DISPLAY_TYPE: klayout
shell: bash -l {0}
run: |
make dev
- name: make docs
run: |
make install
make docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: "./docs/_build/html/"

deploy-docs:
needs: build-docs
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
pages: write
id-token: write
Expand All @@ -43,4 +49,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ jobs:
run: |
make build
twine upload dist/*
- name: Publish Latest Draft
run: |
gh release edit ${{ github.ref_name }} --draft=false
gh release upload ${{ github.ref_name }} dist/gvtt-${{ github.ref_name}}-py3-none-any.whl --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 11 additions & 44 deletions .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test pre-commit, code and docs
name: Test code

on:
pull_request:
Expand All @@ -11,60 +11,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Test pre-commit hooks
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit run -a
test_code:
runs-on: ${{ matrix.os }}
container: ghcr.io/gdsfactory/gdsfactory:main
strategy:
max-parallel: 12
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
make dev
- name: Test with pytest
run: pytest tests/
test_docs:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 12
matrix:
python-version: [3.11]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
make dev
pip freeze > requirements.txt
- uses: actions/upload-artifact@v3
with:
name: requirements
path: requirements.txt
- name: Test documentation
env:
TIDY3D_USER: ${{ secrets.TIDY3D_EMAIL }}
TIDY3D_PASS: ${{ secrets.TIDY3D_PASSWORD }}
DISPLAY: 1.0
DOCS: True
GDSFACTORY_DISPLAY_TYPE: klayout
run: |
mkdir -p $HOME/.tidy3d
make docs
35 changes: 27 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 9260cbc9c84c06022993bfbcc42fdbf0305c5b8e
rev: v4.6.0
hooks:
- id: check-yaml
exclude: ^(conda\.recipe/meta\.yaml|conda_build/templates/.*\.yaml|docs/click/meta\.yaml|conda/meta\.yaml|conda/construct.yaml|.*\.pic\.yml|conda/constructor/Miniforge3/construct.yaml)
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
files: ".ipynb"

- repo: https://github.com/psf/black
rev: 25d886f52c2bbbb58386ac8050f4e67952507bc7
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: black
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "6a0ba1854991b693612486cc84a2254de82d071d"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.1"
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- id: ruff-format

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.10.0
rev: v2.13.0
hooks:
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/aristanetworks/j2lint.git
rev: v1.1.0
hooks:
- id: j2lint
types: [file]
files: \.(j2|yml|yaml)$
exclude: .github/.*
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

install:
pip install -e .[dev]
pip install -e .[dev,docs]
pre-commit install

dev:
pip install -e .[dev,docs]


test:
pytest -s

Expand Down
4 changes: 4 additions & 0 deletions gvtt/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
strip_taper,
xs_rib_strip,
)
from gvtt.xsections import straight, straight_rib, straight_sc

__all__ = [
"bend_euler",
Expand All @@ -32,4 +33,7 @@
"rib_to_strip",
"strip_taper",
"xs_rib_strip",
"straight_sc",
"straight_rib",
"straight",
]
13 changes: 5 additions & 8 deletions gvtt/components/bend_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@ def bend_euler(
)

ref = c << p.extrude(x)
c.info["length"] = np.round(p.length(), 3)
c.info["dy"] = np.round(abs(float(p.points[0][0] - p.points[-1][0])), 3)
c.info["radius_min"] = np.round(p.info["Rmin"], 3)
c.info["radius"] = p.xmax
c.info["width"] = x.width

if x.info:
c.info.update(x.info)
c.info["length"] = float(np.round(p.length(), 3))
c.info["dy"] = float(np.round(abs(float(p.points[0][0] - p.points[-1][0])), 3))
c.info["radius_min"] = float(np.round(p.info["Rmin"], 3))
c.info["radius"] = float(p.xmax)
c.info["width"] = float(x.width)

if with_bbox and x.bbox_layers:
padding = []
Expand Down
9 changes: 9 additions & 0 deletions gvtt/components/edge_coupler_rib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ def edge_coupler_rib(
xpos: float = 0.0,
ypos: float = 0.0,
) -> Component:
"""Returns a rib waveguide edge coupler.
Args:
edge_coupling_width: width of the edge coupling waveguide.
polishing_length: length of the edge coupling waveguide.
side: side of the edge coupler (W, E, N, S).
xpos: x position of the edge coupler.
ypos: y position of the edge coupler.
"""
c = gf.Component()
side = side.upper()

Expand Down
Loading

0 comments on commit f5c0b47

Please sign in to comment.