diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..42dd074 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,71 @@ +# This file is required by the the action 'https://github.com/actions/labeler' +# and used in the '.github/workflows/ci_cd_pr.yml' workflow + +# -- Labels based on PR title ------------------------------------------------ +'fix': + - head-branch: ['fix'] + +'enhancement': + - head-branch: ['feat'] + +# -- Documentation labels ---------------------------------------------------- +'docs': + - all: + - changed-files: + - any-glob-to-any-file: ['doc/source/**/*.rst'] + - all-globs-to-all-files: ['!doc/source/examples.rst', '!doc/source/api/**/*.rst', '!doc/styles/**', '!doc/.vale.ini'] + +'docs:api': + - any: + - changed-files: + - any-glob-to-any-file: ['doc/source/api/**/*.rst'] + +'docs:examples': + - any: + - changed-files: + - any-glob-to-any-file: ['examples/**/*.py', 'doc/source/examples.rst'] + +## -- Other labels ------------------------------------------------------------ +'style:code': + - any: + - changed-files: + - any-glob-to-any-file: ['.pre-commit-config.yaml', 'doc/.vale.ini'] + +'docker': + - any: + - changed-files: + - any-glob-to-any-file: ['docker/**'] + +'ci': + - any: + - changed-files: + - any-glob-to-any-file: ['.github/workflows/**'] + +'tests': + - any: + - changed-files: + - any-glob-to-any-file: ['tests/**'] + +# HACK: the following labels are declared with the only purpose of avoiding the +# GitHub labeler bot to remove those. This is a known issue reported in the +# official action/labeler repo https://github.com/actions/labeler/issues/763 + +'ci:skip': + - all: + - changed-files: + - all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE'] + +'docs:skip': + - all: + - changed-files: + - all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE'] + +'tests:skip': + - all: + - changed-files: + - all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE'] + +'blocked': + - all: + - changed-files: + - all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE'] diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..c2b5daf --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,116 @@ +# The labels declared in this file are the ones available +# https://github.com/ansys-internal/pylumerical/labels + +# -- Defects, glitches, and vulnerabilities labels --------------------------- + +- name: 'bug' + description: Defects or glitches reported by users or developers + color: d42a34 + +- name: 'fix' + description: Pull requests related to resolving problems or errors + color: d42a34 + +- name: 'vulnerability' + description: Pull requests related to resolving problems or errors + color: d42a34 + +# -- Style labels ------------------------------------------------------------ + +- name: 'style' + description: Improvements related to general project style + color: dcbeff + +- name: 'style:code' + description: Improvements related to code style + color: dcbeff + +- name: 'style:docs' + description: Improvements related to doc style + color: dcbeff + +- name: 'style:branch-name' + description: Verifies branch name is compliant with PyAnsys guidelines + color: dcbeff + +- name: 'style:skip' + description: Skip style runs in CI/CD + color: dcbeff + +# -- Tests labels ------------------------------------------------------------ + +- name: 'tests' + description: Related with improvements of the test suite + color: ffd8b1 + +- name: 'tests:skip' + description: Skip tests runs in CI/CD + color: ffd8b1 + +# -- Documentation labels ---------------------------------------------------- + +- name: 'docs' + description: Issues related to documentation + color: 0677ba + +- name: 'docs:api' + description: Related to API documentation + color: 0677ba + +- name: 'docs:examples' + description: Related to documentation examples + color: 0677ba + +- name: 'docs:skip' + description: Skip documentation runs in CI/CD + color: 0677ba + +# -- Dependencies labels ----------------------------------------------------- + +- name: 'dependencies' + description: Related with project dependencies + color: fabed4 + +- name: 'dependencies:pyproject' + description: Related with project file dependencies + color: fabed4 + +- name: 'dependencies:ci' + description: Related with pipelines dependencies + color: fabed4 + +# -- CI/CD labels ------------------------------------------------------------ + +- name: 'ci' + description: Pipelines maintenance related + color: a9a9a9 + +- name: 'ci:skip' + description: Skip CI/CD runs + color: a9a9a9 + +# -- Other labels ------------------------------------------------------------ + +- name: 'release' + description: Anything related to an incoming release + color: ffffff + +- name: 'good first issue' + description: Issues suitable for newcomers or those with less experience + color: 62ca50 + +- name: 'enhancement' + description: General improvements to existing features + color: ffd827 + +- name: 'maintenance' + description: Generic maintenance related + color: f78c37 + +- name: 'docker' + description: Docker maintenance related + color: 000075 + +- name: 'blocked' + description: Cannot be completed until other tasks are resolved + color: 000000 diff --git a/.github/workflows/ci_cd_pr.yml b/.github/workflows/ci_cd_pr.yml new file mode 100644 index 0000000..50062ff --- /dev/null +++ b/.github/workflows/ci_cd_pr.yml @@ -0,0 +1,160 @@ +name: pull-request +on: + pull_request: + types: [opened, reopened, synchronize, edited, labeled, closed] + +env: + MAIN_PYTHON_VERSION: '3.13' + LIBRARY_NAME: 'ansys-lumerical-core' + DOCKER_IMAGE_LUMERICAL_UNIFIED: 'ghcr.io/ansys-internal/lumerical-unified:latest' + DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME: 'lumerical-unified' + PIP_EXTRA_INDEX_URL: 'https://${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/' + +permissions: + contents: read + pull-requests: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + labeler: + name: "Labels" + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + + - name: "Checkout project" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: "Sync labels" + uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Label pull-request" + # HACK: skip if contributor does not have write permissions (forks) + if: github.event.pull_request.head.repo.full_name == github.repository + uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + changelog-fragment: + name: "Create changelog fragment" + needs: labeler + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/doc-changelog@v10 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + use-conventional-commits: true + use-default-towncrier-config: true + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + + code-style: + name: "Code style" + runs-on: ubuntu-latest + needs: changelog-fragment + steps: + - name: "Run code style checks" + uses: ansys/actions/code-style@v10 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + use-python-cache: false + + doc-style: + name: "Doc style" + runs-on: ubuntu-latest + needs: changelog-fragment + steps: + - uses: ansys/actions/doc-style@v10 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + doc-build: + name: "Doc build" + runs-on: ubuntu-latest + needs: doc-style + steps: + - uses: ansys/actions/doc-build@v10 + with: + skip-install: true + python-version: ${{ env.MAIN_PYTHON_VERSION }} + use-python-cache: false + needs-quarto: true + + wheelhouse: + name: "Wheelhouse / ${{ matrix.os }} / ${{ matrix.python }}" + runs-on: ${{ matrix.os }} + needs: code-style + permissions: + id-token: write + contents: write + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest', 'windows-latest'] + python: ['3.10', '3.11', '3.12', '3.13'] + steps: + - uses: ansys/actions/build-wheelhouse@v10 + with: + library-name: ${{ env.LIBRARY_NAME }} + operating-system: ${{ matrix.os }} + python-version: ${{ matrix.python }} + + tests: + name: "Test Python 3.13 with Lumerical Unified Linux Container" + runs-on: ubuntu-latest + needs: wheelhouse + permissions: + id-token: write + contents: write + steps: + + - name: "Checkout PyLumerical" + uses: actions/checkout@v4 + + - name: "Login to GitHub container registry" + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + + - name: "Pull Lumerical Unified Container" + run: | + docker pull ${{ env.DOCKER_IMAGE_LUMERICAL_UNIFIED }} + + - name: "Run Lumerical Unified Container" + run: | + docker run \ + --detach -it \ + --network="host" \ + --name ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} \ + --env ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }} \ + --volume ${PWD}:/home/ansys/pylumerical \ + ${{ env.DOCKER_IMAGE_LUMERICAL_UNIFIED }} + + - name: "Install project" + run: | + docker exec \ + --workdir /home/ansys/pylumerical \ + ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} /bin/bash --login -c \ + "python -m pip install -e .[tests] && pytest tests" + + - name: "Stop lumerical services" + if: always() + run: | + docker stop ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} + docker logs ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} + docker rm ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} diff --git a/doc/.vale.ini b/doc/.vale.ini index d09e059..52ed5ed 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -34,4 +34,4 @@ Google.WordList = NO # Ignore specific tokens for class references and such -TokenIgnores = (:(func|class|meth|attr|py):`(?:.|\n)*?`)|(<.*>)|(\|[A-Za-z0-9_]+\|) \ No newline at end of file +TokenIgnores = (:(func|class|meth|attr|py):`(?:.|\n)*?`)|(<.*>)|(\|[A-Za-z0-9_]+\|) diff --git a/doc/Makefile b/doc/Makefile index 7dc17b5..0318dc9 100755 --- a/doc/Makefile +++ b/doc/Makefile @@ -27,6 +27,6 @@ clean: # Customized pdf for svg format images pdf: - @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" -j auto --color --keep-going $(O) cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true (test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1 diff --git a/doc/source/api/interface_class.rst b/doc/source/api/interface_class.rst index a44b12c..f1d9bb8 100644 --- a/doc/source/api/interface_class.rst +++ b/doc/source/api/interface_class.rst @@ -5,6 +5,7 @@ Instances of these objects each represent an interactive session with a Lumerica .. autosummary:: :toctree: _autosummary + :recursive: ansys.lumerical.core.FDTD ansys.lumerical.core.MODE diff --git a/doc/source/changelog/5.maintenance.md b/doc/source/changelog/5.maintenance.md new file mode 100644 index 0000000..8154aff --- /dev/null +++ b/doc/source/changelog/5.maintenance.md @@ -0,0 +1 @@ +Add workflows diff --git a/doc/source/changelog/template b/doc/source/changelog/template new file mode 100644 index 0000000..3ca0146 --- /dev/null +++ b/doc/source/changelog/template @@ -0,0 +1,22 @@ +{% if sections[""] %} + +.. tab-set:: + +{%+ for category, val in definitions.items() if category in sections[""] %} + + .. tab-item:: {{ definitions[category]['name'] }} + + .. list-table:: + :header-rows: 0 + :widths: auto + +{% for text, values in sections[""][category].items() %} + * - {{ text }} + - {{ values|join(', ') }} + +{% endfor %} +{% endfor %} + +{% else %} +No significant changes. +{% endif %} diff --git a/doc/source/conf.py b/doc/source/conf.py index 3abfbf2..f1f1508 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -35,6 +35,9 @@ }, "check_switcher": False, "logo": "pyansys", + "ansys_sphinx_theme_autoapi": { + "project": "PyLumerical", + }, } # Sphinx extensions @@ -90,7 +93,7 @@ # Skipping members def autodoc_skip_member_custom(app, what, name, obj, skip, options): - """Skip members that are not documented.""" + """Skip members that are not intended to be in documentation.""" return True if obj.__doc__ is None else None # need to return none if exclude is false otherwise it will interfere with other skip functions @@ -116,6 +119,7 @@ def autodoc_skip_member_custom(app, what, name, obj, skip, options): linkcheck_ignore = [ "https://github.com/ansys/pylumerical/*", "https://pypi.org/project/ansys-lumerical-core", + r"https://optics.ansys.com/hc/", # ignore Zendesk articles because help center is not accessible by bots/crawlers ] # If we are on a release, we have to ignore the "release" URLs, since it is not diff --git a/doc/source/index.rst b/doc/source/index.rst index c274c5e..946c021 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -37,14 +37,6 @@ As a part of the PyAnsys project, PyLumerical also enables you to integrate with Description of classes and methods of the PyLumerical module. -.. - Just reuse the root readme to avoid duplicating the documentation. - Provide any documentation specific to your online documentation - here. - -.. include:: ../../README.rst - :start-after: .. contribute_start - .. toctree:: :hidden: :maxdepth: 3 diff --git a/doc/styles/config/vocabularies/ANSYS/accept.txt b/doc/styles/config/vocabularies/ANSYS/accept.txt index e18451b..f591ced 100644 --- a/doc/styles/config/vocabularies/ANSYS/accept.txt +++ b/doc/styles/config/vocabularies/ANSYS/accept.txt @@ -29,4 +29,4 @@ photonic photonics lumopt lumslurm -[Aa]utodiscovery \ No newline at end of file +[Aa]utodiscovery diff --git a/pyproject.toml b/pyproject.toml index 2aa83c0..9d5ba98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,31 +8,29 @@ dynamic = ["version"] description = "Python interface to Ansys Lumerical" readme = "README.rst" requires-python = ">=3.10,<4" -license = {file = "LICENSE"} +license = "MIT" +license_files = ["LICENSE"] authors=[ - {name="ANSYS, Inc.", email="pyansys.support@ansys.com"} + {name="ANSYS, Inc.", email="pyansys.core@ansys.com"} ] maintainers=[ - {name="PyAnsys developers", email="pyansys.core@ansys.com"} + {name="ANSYS, Inc.", email="pyansys.core@ansys.com"} ] keywords = ["Ansys", "Lumerical", "photonics", "simulation"] -classifiers=[ +classifiers = [ "Development Status :: 4 - Beta", - "License :: OSI Approved :: MIT License", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering :: Information Analysis", "Operating System :: OS Independent", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", - "Topic :: Software Development :: Libraries", - "Topic :: Scientific/Engineering :: Physics", - "Topic :: Scientific/Engineering :: Information Analysis", ] dependencies = [ "ansys-api-lumerical", - "numpy >= 2.2.2", - "importlib-metadata >=4.0" + "numpy>=2.2.2", ] [project.optional-dependencies] @@ -41,7 +39,7 @@ tests = [ "pytest-cov==4.1.0", ] doc = [ - "ansys-sphinx-theme==1.4.2", + "ansys-sphinx-theme[autoapi]==1.4.2", "numpydoc==1.8.0", "sphinx==8.2.3", "sphinx-copybutton==0.5.2", @@ -103,12 +101,12 @@ show_missing = true [tool.towncrier] package = "ansys.lumerical.core" -directory = "doc/changelog.d" +directory = "doc/source/changelog" filename = "doc/source/changelog.rst" start_string = ".. towncrier release notes start\n" -template = "doc/changelog.d/changelog_template.jinja" -title_format = "`{version} `_ - {project_date}" -issue_format = "`#{issue} `_" +template = "doc/source/changelog/template" +title_format = "`{version} `_ - {project_date}" +issue_format = "`#{issue} `_" [[tool.towncrier.type]] directory = "added" @@ -116,8 +114,13 @@ name = "Added" showcontent = true [[tool.towncrier.type]] -directory = "changed" -name = "Changed" +directory = "dependencies" +name = "Dependencies" +showcontent = true + +[[tool.towncrier.type]] +directory = "documentation" +name = "Documentation" showcontent = true [[tool.towncrier.type]] @@ -126,11 +129,16 @@ name = "Fixed" showcontent = true [[tool.towncrier.type]] -directory = "dependencies" -name = "Dependencies" +directory = "maintenance" +name = "Maintenance" showcontent = true [[tool.towncrier.type]] directory = "miscellaneous" name = "Miscellaneous" -showcontent = true \ No newline at end of file +showcontent = true + +[[tool.towncrier.type]] +directory = "test" +name = "Test" +showcontent = true diff --git a/src/ansys/lumerical/core/__init__.py b/src/ansys/lumerical/core/__init__.py index c54be0a..27135a1 100644 --- a/src/ansys/lumerical/core/__init__.py +++ b/src/ansys/lumerical/core/__init__.py @@ -37,5 +37,5 @@ if install_dir is not None: ansys.api.lumerical.lumapi.InteropPaths.setLumericalInstallPath(install_dir) else: - print("Warning: Lumerical installation not found. Please use InteropPaths.setLumericalInstallPath to set the interop library location.") + print("Lumerical installation not found. Please use InteropPaths.setLumericalInstallPath to set the interop library location.") del install_dir # remove the local variable to exclude from the namespace