-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Final touches for pre-release 🔎
- Loading branch information
1 parent
7d2c9a2
commit 53a436b
Showing
93 changed files
with
818 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Tidy3d Release | ||
name: "tidy3d-release" | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: sync-to-readthedocs-repo | ||
name: "sync-to-readthedocs-repo" | ||
permissions: | ||
contents: write | ||
on: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: "tidy3d-coverage" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ develop, main ] | ||
pull_request: | ||
branches: | ||
- develop | ||
- 'pre/*' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
PIP_DISABLE_PIP_VERSION_CHECK: 1 | ||
FORCE_COLOR: 1 # Get colored pytest output | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Test pre-commit hooks | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pre-commit | ||
pre-commit run | ||
build: | ||
name: Coverage Test | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
env: # Set environment variables for the whole job | ||
PIP_ONLY_BINARY: gdstk | ||
MPLBACKEND: agg | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.10" | ||
#---------------------------------------------- | ||
# ----- install & configure poetry ----- | ||
#---------------------------------------------- | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.6.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
#---------------------------------------------- | ||
# load cached venv if cache exists | ||
#---------------------------------------------- | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
#---------------------------------------------- | ||
# install dependencies if cache does not exist | ||
#---------------------------------------------- | ||
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root -E dev | ||
#---------------------------------------------- | ||
# install your root project, if required | ||
#---------------------------------------------- | ||
- name: Install library | ||
run: poetry install --no-interaction -E dev | ||
#---------------------------------------------- | ||
# add matrix specifics and run test suite | ||
#---------------------------------------------- | ||
- name: Run tests | ||
run: | | ||
source $VENV | ||
black . --check --diff | ||
ruff check tidy3d --fix --exit-non-zero-on-fix | ||
coverage run -m pytest -rA tests | ||
coverage report -m | ||
echo "total=$(coverage report --format=total)" >> $GITHUB_ENV | ||
echo '### Total coverage: ${{ env.total }}%' | ||
- name: "Create badge" | ||
# if: ${{ github.ref == 'refs/heads/latest' }} | ||
# https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5 | ||
uses: schneegans/dynamic-badges-action@v1.7.0 | ||
with: | ||
auth: ${{ secrets.GH_TIDY3D_COVERAGE_GIST }} | ||
gistID: 4702549574741e87deaadba436218ebd | ||
filename: tidy3d_extension.json | ||
label: Coverage | ||
message: ${{ env.total }}% | ||
minColorRange: 60 | ||
maxColorRange: 95 | ||
valColorRange: ${{ env.total }} | ||
style: "for-the-badge" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. mdinclude:: ../../../tidy3d/plugins/adjoint/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. mdinclude:: ../../../tidy3d/plugins/design/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
Documentation | ||
============== | ||
|
||
Getting Started | ||
--------------- | ||
|
||
Assuming you already have ``poetry`` and the ``tidy3d develop`` commands installed (see the instructions if not), then building the documentation is easy: | ||
|
||
.. code:: | ||
poetry run tidy3d develop build-docs | ||
The output of the build will be in ``_docs/`` and you can view it by opening ``_docs/index.html`` in your browser. You might just have to click the ``index.html`` file to open it in your browser within a File Explorer. | ||
|
||
Theme | ||
------ | ||
|
||
Under ``docs/_static/css`` we can find ``custom.css`` which the color themes custom to Flexcompute can be found. | ||
Under ``docs/_static/css`` we can find ``custom.css`` which the color themes custom to Flexcompute can be found. | ||
|
||
Common Updates | ||
-------------- | ||
|
||
Adding a new notebook | ||
'''''''''''''''''''''' | ||
|
||
This process is self-contained in ``tidy3d-notebooks``. | ||
|
||
Make sure to add a link to the notebook in ``tidy3d-notebooks/docs/*`` directory in a relevant file. | ||
|
||
Then you have to commit to either the ``develop`` branch or your custom one. However, the important thing to understand is that the submodule in ``docs/notebooks`` has a state that is also committed. This means that when you or any tool clones this directory, then the state and mapped branch/commit of the submodule will be the one that was committed. However, you have to be careful that when your commit gets merged the commit of the ``tidy3d-notebooks`` submodule is also pointing to the latest ``develop`` branch and not any local branch in which you have been developing. Otherwise, the documentation will be built with your local branch, and not the published branch. | ||
|
||
This submodule commit process can be done by running ``git add docs/notebooks`` and then committing the change. | ||
|
||
If you want to locally develop notebooks in ``tidy3d/docs/notebooks`` then just use that submodule as your main development repository and commit to your local branch. Then when you are ready to publish, just make sure to commit the submodule to the latest ``develop`` branch. You can then build the documentation locally easily using this approach before it is published. | ||
|
||
Updating Docstrings | ||
''''''''''''''''''''' | ||
|
||
``tidy3d develop`` has a utility to update docstrings in the codebase. | ||
This is useful when updating the API and you want to update the docstrings to reflect the changes from multiple versions. | ||
|
||
Example usage: | ||
|
||
.. code:: | ||
poetry run tidy3d develop replace-in-files -d ./ -j ./docs/versions/test_replace_in_files.json -v 0.18.0 --dry-run True | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
Project Structure | ||
================= | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Recommendations | ||
================= | ||
|
||
Package Speedup Best Practices | ||
'''''''''''''''''''''''''''''' | ||
|
||
``tidy3d`` is a pretty big project already, and will get bigger. We want to optimise the performance of the codebase throughout the multiple operations that we perform. | ||
|
||
We want to improve the speed of the project ``import`` and there are a few techniques to do this which are inherent to the way we write our code. | ||
|
||
- `For profiling the package distribution in the import <https://stackoverflow.com/questions/16373510/improving-speed-of-python-module-import>`_ | ||
- `In terms of speeding our operations <https://wearecommunity.io/communities/tectoniques/articles/2499#:~:text=Proper%20Import,in%20slowing%20down%20code%20performance.>`_ | ||
|
||
We have already begun facing these type of code-speed issues as first raised `here <https://github.com/flexcompute/tidy3d/pull/1300>`_, `here <https://github.com/flexcompute/tidy3d/pull/1300>`_ | ||
|
||
So when we import dependencies inside our code-base in particular where these are used, we will try to do the following: | ||
|
||
.. code:: | ||
from mypackage import just_what_I_need | ||
instead of | ||
|
||
.. code:: | ||
import mypackage | ||
This is because the latter will import the entire package, which is not necessary and will slow down the code. | ||
|
||
|
||
Managing Optional Dependencies On-The-Fly | ||
'''''''''''''''''''''''''''''''''''''''''' | ||
|
||
If you look within ``pyproject.toml``, it is possible to see that we have different packages relating to different functionalities that are optional. | ||
|
||
Some examples from these are ``[vtk, jax, trimesh, gdstk, gdspy]`` etc. What we want to do is improve the import speed of the core-package in order to minimise small core operations. As we scale into a bigger package, decoupling these type of imports from the total pacakge import is essential. | ||
|
Oops, something went wrong.