From 15fad119d8a5f6caa7055e19810c2432cab19631 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Tue, 19 Dec 2023 16:15:09 +0100 Subject: [PATCH] initial commit --- .flake8 | 7 ++ .gitattributes | 3 + .github/dependabot.yml | 16 +++ .github/labeler.yml | 8 ++ .github/labels.yml | 27 +++++ .github/workflows/ci_cd.yml | 110 +++++++++++++++++ .github/workflows/label.yml | 85 +++++++++++++ .gitignore | 159 +++++++++++++++++++++++++ .pre-commit-config.yaml | 40 +++++++ .vscode/settings.json | 3 + AUTHORS | 12 ++ CHANGELOG.md | 1 + CODE_OF_CONDUCT.md | 65 ++++++++++ CONTRIBUTING.md | 2 + CONTRIBUTORS.md | 9 ++ LICENSE | 21 ++++ README.rst | 191 ++++++++++++++++++++++++++++++ doc/.vale.ini | 28 +++++ doc/Makefile | 32 +++++ doc/make.bat | 41 +++++++ doc/source/_static/README.md | 1 + doc/source/_templates/README.md | 1 + doc/source/conf.py | 91 ++++++++++++++ doc/source/index.rst | 6 + doc/styles/.gitignore | 4 + doc/styles/Vocab/ANSYS/accept.txt | 3 + doc/styles/Vocab/ANSYS/reject.txt | 0 pyproject.toml | 66 +++++++++++ src/ansys/simai/core/__init__.py | 8 ++ tests/test_metadata.py | 5 + tox.ini | 40 +++++++ 31 files changed, 1085 insertions(+) create mode 100644 .flake8 create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/labels.yml create mode 100644 .github/workflows/ci_cd.yml create mode 100644 .github/workflows/label.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .vscode/settings.json create mode 100644 AUTHORS create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTORS.md create mode 100644 LICENSE create mode 100644 README.rst create mode 100644 doc/.vale.ini create mode 100644 doc/Makefile create mode 100644 doc/make.bat create mode 100644 doc/source/_static/README.md create mode 100644 doc/source/_templates/README.md create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst create mode 100644 doc/styles/.gitignore create mode 100644 doc/styles/Vocab/ANSYS/accept.txt create mode 100644 doc/styles/Vocab/ANSYS/reject.txt create mode 100644 pyproject.toml create mode 100644 src/ansys/simai/core/__init__.py create mode 100644 tests/test_metadata.py create mode 100644 tox.ini diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..41573c4a --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +[flake8] +exclude = venv, __init__.py, doc/_build, .venv +select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, E501, F401, F403 +count = True +max-complexity = 10 +max-line-length = 100 +statistics = True diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dccedadf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto !eol +*.sh eol=lf +*.bat eol=crlf diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..b5d1656a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + labels: + - "maintenance" + - "dependencies" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + labels: + - "maintenance" diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..f5d90427 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,8 @@ +documentation: +- doc/source/**/* +maintenance: +- .github/**/* +- .flake8 +- pyproject.toml +dependencies: +- requirements/* diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..bc6aeecf --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,27 @@ +- name: bug + description: Something isn't working + color: d42a34 + +- name: dependencies + description: Related with project dependencies + color: ffc0cb + +- name: documentation + description: Improvements or additions to documentation + color: 0677ba + +- name: enhancement + description: New features or code improvements + color: FFD827 + +- name: good first issue + description: Easy to solve for newcomers + color: 62ca50 + +- name: maintenance + description: Package and maintenance related + color: f78c37 + +- name: release + description: Anything related to an incoming release + color: ffffff diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml new file mode 100644 index 00000000..6d44e36a --- /dev/null +++ b/.github/workflows/ci_cd.yml @@ -0,0 +1,110 @@ +name: CI +on: + pull_request: + push: + tags: + - "*" + branches: + - main + +env: + MAIN_PYTHON_VERSION: '3.10' + DOCUMENTATION_CNAME: 'simai.docs.pyansys.com' + LIBRARY_NAME: 'ansys-simai-core' + LIBRARY_NAMESPACE: 'ansys.simai.core' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + code-style: + name: "Code style" + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/code-style@v4 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + doc-style: + name: "Documentation style" + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/doc-style@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + smoke-tests: + name: "Build and Smoke tests" + runs-on: ${{ matrix.os }} + needs: [code-style] + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ['3.10'] + steps: + - uses: ansys/actions/build-wheelhouse@v4 + with: + library-name: ${{ env.LIBRARY_NAME }} + operating-system: ${{ matrix.os }} + python-version: ${{ matrix.python-version }} + + tests: + name: "Tests" + runs-on: ${{ matrix.os }} + needs: [smoke-tests] + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ['3.10'] + fail-fast: false + steps: + - uses: ansys/actions/tests-pytest@v4 + with: + pytest-extra-args: "--cov=ansys --cov-report=term --cov-report=html:.cov/html" + + doc-build: + name: "Build documentation" + runs-on: ubuntu-latest + needs: [doc-style] + steps: + - uses: ansys/actions/doc-build@v4 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + check-links: false + + build-library: + name: "Build library basic example" + runs-on: ubuntu-latest + needs: [doc-build, tests] + steps: + - uses: ansys/actions/build-library@v4 + with: + library-name: ${{ env.LIBRARY_NAME }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + doc-deploy-dev: + name: "Deploy development documentation" + runs-on: ubuntu-latest + needs: [build-library] + if: github.event_name == 'push' && !contains(github.ref, 'refs/tags') + steps: + - uses: ansys/actions/doc-deploy-dev@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + + doc-deploy-stable: + name: "Deploy stable documentation" + runs-on: ubuntu-latest + needs: [build-library] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + steps: + - uses: ansys/actions/doc-deploy-stable@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + + diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..9dac7314 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,85 @@ +name: Labeler +on: + pull_request: + push: + branches: [ main ] + paths: + - '../labels.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + label-syncer: + name: Syncer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + labeler: + name: Set labels + needs: [label-syncer] + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + + # Label based on modified files + - name: Label based on changed files + uses: actions/labeler@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + sync-labels: '' + + # Label based on branch name + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'doc') || + startsWith(github.event.pull_request.head.ref, 'docs') + with: + labels: documentation + + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'maint') || + startsWith(github.event.pull_request.head.ref, 'no-ci') || + startsWith(github.event.pull_request.head.ref, 'ci') + with: + labels: maintenance + + - uses: actions-ecosystem/action-add-labels@v1 + if: startsWith(github.event.pull_request.head.ref, 'feat') + with: + labels: | + enhancement + + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'fix') || + startsWith(github.event.pull_request.head.ref, 'patch') + with: + labels: bug + + commenter: + runs-on: ubuntu-latest + steps: + - name: Suggest to add labels + uses: peter-evans/create-or-update-comment@v2 + # Execute only when no labels have been applied to the pull request + if: toJSON(github.event.pull_request.labels.*.name) == '{}' + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Please add one of the following labels to add this contribution to the Release Notes :point_down: + - [bug](https://github.com/ansys/simai/pulls?q=label%3Abug+) + - [documentation](https://github.com/ansys/simai/pulls?q=label%3Adocumentation+) + - [enhancement](https://github.com/ansys/simai/pulls?q=label%3Aenhancement+) + - [good first issue](https://github.com/ansys/simai/pulls?q=label%3Agood+first+issue) + - [maintenance](https://github.com/ansys/simai/pulls?q=label%3Amaintenance+) + - [release](https://github.com/ansys/simai/pulls?q=label%3Arelease+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..852dd375 --- /dev/null +++ b/.gitignore @@ -0,0 +1,159 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python +# Edit at https://www.toptal.com/developers/gitignore?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.cov +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +doc/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# End of https://www.toptal.com/developers/gitignore/api/python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..2d9f8d8e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +repos: + +- repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + +- repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + +- repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + +- repo: https://github.com/pycqa/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + additional_dependencies: [toml] + exclude: "tests/" + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: requirements-txt-fixer + - id: trailing-whitespace + +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.22.0 + hooks: + - id: check-github-workflows diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..a7d0fc7b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "esbonio.sphinx.confDir": "" +} \ No newline at end of file diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..29a51c70 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,12 @@ +# This is the list of simai's significant contributors. +# +# This file does not necessarily list everyone who has contributed code. +# +# For contributions made under a Corporate CLA, the organization is +# added to this file. +# +# If you have contributed to the repository and wish to be added to this file +# please submit a request. +# +# +ANSYS, Inc. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..505d21df --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +# CHANGELOG \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..1cf484f1 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,65 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our +project and our community a harassment-free experience for everyone, +regardless of age, body size, disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual + attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8ba1f31c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,2 @@ +# Contributing + diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..69b53479 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +# Contributors + +## Project Lead or Owner + +* [First Last]() + +## Individual Contributors + +* [First Last]() diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..69af3d3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 ANSYS, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..38fa3c43 --- /dev/null +++ b/README.rst @@ -0,0 +1,191 @@ +Pysimai simai +============= +|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| + +.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC + :target: https://docs.pyansys.com/ + :alt: PyAnsys + +.. |python| image:: https://img.shields.io/pypi/pyversions/simai?logo=pypi + :target: https://pypi.org/project/simai/ + :alt: Python + +.. |pypi| image:: https://img.shields.io/pypi/v/simai.svg?logo=python&logoColor=white + :target: https://pypi.org/project/simai + :alt: PyPI + +.. |codecov| image:: https://codecov.io/gh/ansys/simai/branch/main/graph/badge.svg + :target: https://codecov.io/gh/ansys/simai + :alt: Codecov + +.. |GH-CI| image:: https://github.com/ansys/simai/actions/workflows/ci_cd.yml/badge.svg + :target: https://github.com/ansys/simai/actions/workflows/ci_cd.yml + :alt: GH-CI + +.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg + :target: https://opensource.org/licenses/MIT + :alt: MIT + +.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat + :target: https://github.com/psf/black + :alt: Black + + +A Python wrapper for Ansys simai simai + + +How to install +-------------- + +At least two installation modes are provided: user and developer. + +For users +^^^^^^^^^ + +In order to install Pysimai simai, make sure you +have the latest version of `pip`_. To do so, run: + +.. code:: bash + + python -m pip install -U pip + +Then, you can simply execute: + +.. code:: bash + + python -m pip install ansys-simai-core + +For developers +^^^^^^^^^^^^^^ + +Installing Pysimai simai in developer mode allows +you to modify the source and enhance it. + +Before contributing to the project, please refer to the `PyAnsys Developer's guide`_. You will +need to follow these steps: + +#. Start by cloning this repository: + + .. code:: bash + + git clone https://github.com/ansys/simai + +#. Create a fresh-clean Python environment and activate it: + + .. code:: bash + + # Create a virtual environment + python -m venv .venv + + # Activate it in a POSIX system + source .venv/bin/activate + + # Activate it in Windows CMD environment + .venv\Scripts\activate.bat + + # Activate it in Windows Powershell + .venv\Scripts\Activate.ps1 + +#. Make sure you have the latest required build system and doc, testing, and CI tools: + + .. code:: bash + + python -m pip install -U pip flit tox + python -m pip install -r requirements/requirements_build.txt + python -m pip install -r requirements/requirements_doc.txt + python -m pip install -r requirements/requirements_tests.txt + + +#. Install the project in editable mode: + + .. code:: bash + + python -m pip install --editable ansys-simai-core + + #. Finally, verify your development installation by running: + + .. code:: bash + + tox + + +How to testing +-------------- + +This project takes advantage of `tox`_. This tool allows to automate common +development tasks (similar to Makefile) but it is oriented towards Python +development. + +Using tox +^^^^^^^^^ + +As Makefile has rules, `tox`_ has environments. In fact, the tool creates its +own virtual environment so anything being tested is isolated from the project in +order to guarantee project's integrity. The following environments commands are provided: + +- **tox -e style**: will check for coding style quality. +- **tox -e py**: checks for unit tests. +- **tox -e py-coverage**: checks for unit testing and code coverage. +- **tox -e doc**: checs for documentation building process. + + +Raw testing +^^^^^^^^^^^ + +If required, you can always call the style commands (`black`_, `isort`_, +`flake8`_...) or unit testing ones (`pytest`_) from the command line. However, +this does not guarantee that your project is being tested in an isolated +environment, which is the reason why tools like `tox`_ exist. + + +A note on pre-commit +^^^^^^^^^^^^^^^^^^^^ + +The style checks take advantage of `pre-commit`_. Developers are not forced but +encouraged to install this tool via: + +.. code:: bash + + python -m pip install pre-commit && pre-commit install + + +Documentation +------------- + +For building documentation, you can either run the usual rules provided in the +`Sphinx`_ Makefile, such us: + +.. code:: bash + + make -C doc/ html && your_browser_name doc/html/index.html + +However, the recommended way of checking documentation integrity is using: + +.. code:: bash + + tox -e doc && your_browser_name .tox/doc_out/index.html + + +Distributing +------------ + +If you would like to create either source or wheel files, start by installing +the building requirements and then executing the build module: + +.. code:: bash + + python -m pip install -r requirements/requirements_build.txt + python -m build + python -m twine check dist/* + + +.. LINKS AND REFERENCES +.. _black: https://github.com/psf/black +.. _flake8: https://flake8.pycqa.org/en/latest/ +.. _isort: https://github.com/PyCQA/isort +.. _pip: https://pypi.org/project/pip/ +.. _pre-commit: https://pre-commit.com/ +.. _PyAnsys Developer's guide: https://dev.docs.pyansys.com/ +.. _pytest: https://docs.pytest.org/en/stable/ +.. _Sphinx: https://www.sphinx-doc.org/en/master/ +.. _tox: https://tox.wiki/ diff --git a/doc/.vale.ini b/doc/.vale.ini new file mode 100644 index 00000000..4f0b6709 --- /dev/null +++ b/doc/.vale.ini @@ -0,0 +1,28 @@ +# Core settings +# ============= + +# Location of our `styles` +StylesPath = "styles" + +# The options are `suggestion`, `warning`, or `error` (defaults to “warning”). +MinAlertLevel = warning + +# By default, `code` and `tt` are ignored. +IgnoredScopes = code, tt + +# By default, `script`, `style`, `pre`, and `figure` are ignored. +SkippedScopes = script, style, pre, figure + +# WordTemplate specifies what Vale will consider to be an individual word. +WordTemplate = \b(?:%s)\b + +# List of Packages to be used for our guidelines +Packages = Google + +# Define the Ansys vocabulary +Vocab = ANSYS + +[*.{md,rst}] + +# Apply the following styles +BasedOnStyles = Vale, Google diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..fd967771 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,32 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = -j auto +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + + +# Customized clean due to examples gallery +clean: + rm -rf $(BUILDDIR)/* + rm -rf $(SOURCEDIR)/examples + find . -type d -name "_autosummary" -exec rm -rf {} + + +# Customized pdf for svg format images +pdf: + @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(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/make.bat b/doc/make.bat new file mode 100644 index 00000000..cfdfa1cf --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,41 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=_build + +if "%1" == "" goto help +if "%1" == "clean" goto clean + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:clean +rmdir /s /q %BUILDDIR% > /NUL 2>&1 +for /d /r %SOURCEDIR% %%d in (_autosummary) do @if exist "%%d" rmdir /s /q "%%d" +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/doc/source/_static/README.md b/doc/source/_static/README.md new file mode 100644 index 00000000..0723e4fc --- /dev/null +++ b/doc/source/_static/README.md @@ -0,0 +1 @@ +Static files can be found here (like images and other assets). diff --git a/doc/source/_templates/README.md b/doc/source/_templates/README.md new file mode 100644 index 00000000..86a233ca --- /dev/null +++ b/doc/source/_templates/README.md @@ -0,0 +1 @@ +## Contains templates for the documentation build diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..a0c3d3ab --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,91 @@ +"""Sphinx documentation configuration file.""" +from datetime import datetime +import os + +from ansys_sphinx_theme import get_version_match +from ansys_sphinx_theme import pyansys_logo_black as logo + +from ansys.simai.core import __version__ + +# Project information +project = "ansys-simai-core" +copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved" +author = "ANSYS, Inc." +release = version = __version__ +cname = os.getenv("DOCUMENTATION_CNAME", "docs.pyansys.com") + +# Select desired logo, theme, and declare the html title +html_logo = logo +html_theme = "ansys_sphinx_theme" +html_short_title = html_title = "simai" + +# specify the location of your github repo +html_theme_options = { + "github_url": "https://github.com/ansys/simai", + "show_prev_next": False, + "show_breadcrumbs": True, + "additional_breadcrumbs": [ + ("PyAnsys", "https://docs.pyansys.com/"), + ], + "switcher": { + "json_url": f"https://{cname}/versions.json", + "version_match": get_version_match(__version__), + }, + "check_switcher": False, +} + +# Sphinx extensions +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "numpydoc", + "sphinx.ext.intersphinx", + "sphinx_copybutton", +] + +# Intersphinx mapping +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + # kept here as an example + # "scipy": ("https://docs.scipy.org/doc/scipy/reference", None), + # "numpy": ("https://numpy.org/devdocs", None), + # "matplotlib": ("https://matplotlib.org/stable", None), + # "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None), + # "pyvista": ("https://docs.pyvista.org/", None), + # "grpc": ("https://grpc.github.io/grpc/python/", None), +} + +# numpydoc configuration +numpydoc_show_class_members = False +numpydoc_xref_param_type = True + +# Consider enabling numpydoc validation. See: +# https://numpydoc.readthedocs.io/en/latest/validation.html# +numpydoc_validate = True +numpydoc_validation_checks = { + "GL06", # Found unknown section + "GL07", # Sections are in the wrong order. + "GL08", # The object does not have a docstring + "GL09", # Deprecation warning should precede extended summary + "GL10", # reST directives {directives} must be followed by two colons + "SS01", # No summary found + "SS02", # Summary does not start with a capital letter + # "SS03", # Summary does not end with a period + "SS04", # Summary contains heading whitespaces + # "SS05", # Summary must start with infinitive verb, not third person + "RT02", # The first line of the Returns section should contain only the + # type, unless multiple values are being returned" +} + + +# static path +html_static_path = ["_static"] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +source_suffix = ".rst" + +# The master toctree document. +master_doc = "index" diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..d2824a5f --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,6 @@ +.. + Just reuse the root readme to avoid duplicating the documentation. + Provide any documentation specific to your online documentation + here. + +.. include:: ../../README.rst diff --git a/doc/styles/.gitignore b/doc/styles/.gitignore new file mode 100644 index 00000000..080f12aa --- /dev/null +++ b/doc/styles/.gitignore @@ -0,0 +1,4 @@ +* +!Vocab +!Vocab/** +!.gitignore \ No newline at end of file diff --git a/doc/styles/Vocab/ANSYS/accept.txt b/doc/styles/Vocab/ANSYS/accept.txt new file mode 100644 index 00000000..f59f7712 --- /dev/null +++ b/doc/styles/Vocab/ANSYS/accept.txt @@ -0,0 +1,3 @@ +ANSYS +Ansys +ansys diff --git a/doc/styles/Vocab/ANSYS/reject.txt b/doc/styles/Vocab/ANSYS/reject.txt new file mode 100644 index 00000000..e69de29b diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..d72d883e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections +name = "ansys-simai-core" +version = "0.1.dev0" +description = "A python wrapper for ansys simai simai" +readme = "README.rst" +requires-python = ">=3.10" +license = {file = "LICENSE"} +authors = [ + {name = "ANSYS, Inc.", email = "pyansys.support@ansys.com"}, +] +maintainers = [ + {name = "PyAnsys developers", email = "pyansys.core@ansys.com"}, +] + +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "importlib-metadata >=4.0", +] + +[project.optional-dependencies] +tests = [ + "pytest==7.3.0", + "pytest-cov==4.0.0", +] +doc = [ + "ansys-sphinx-theme==0.9.7", + "numpydoc==1.5.0", + "sphinx==5.3.0", + "sphinx-copybutton==0.5.1", +] + + +[tool.flit.module] +name = "ansys.simai.core" + +[project.urls] +Source = "https://github.com/ansys/simai" +Tracker = "https://github.com/ansys/simai/issues" +Homepage = "https://github.com/ansys/simai" + + +[tool.black] +line-length = 100 + +[tool.isort] +profile = "black" +force_sort_within_sections = true +line_length = 100 +default_section = "THIRDPARTY" +src_paths = ["doc", "src", "tests"] + +[tool.coverage.run] +source = ["ansys.simai"] + +[tool.coverage.report] +show_missing = true diff --git a/src/ansys/simai/core/__init__.py b/src/ansys/simai/core/__init__.py new file mode 100644 index 00000000..ce4b2b4b --- /dev/null +++ b/src/ansys/simai/core/__init__.py @@ -0,0 +1,8 @@ +"""Ansys SimAI Core.""" + +try: + import importlib.metadata as importlib_metadata +except ModuleNotFoundError: + import importlib_metadata + +__version__ = importlib_metadata.version(__name__.replace(".", "-")) diff --git a/tests/test_metadata.py b/tests/test_metadata.py new file mode 100644 index 00000000..baffc896 --- /dev/null +++ b/tests/test_metadata.py @@ -0,0 +1,5 @@ +from ansys.simai.core import __version__ + + +def test_pkg_version(): + assert __version__ == "0.1.dev0" diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..d68bb929 --- /dev/null +++ b/tox.ini @@ -0,0 +1,40 @@ +[tox] +description = Default tox environments list +envlist = + style,{py37,py38,py39,py310,py311}{,-coverage},doc +skip_missing_interpreters = true +isolated_build = true +isolated_build_env = build + +[testenv] +description = Checks for project unit tests and coverage (if desired) +basepython = + py38: python3.8 + py39: python3.9 + py310: python3.10 + py311: python3.11 + py: python3 + {style,reformat,doc,build}: python3 +extras = + tests +setenv = + PYTHONUNBUFFERED = yes + coverage: PYTEST_EXTRA_ARGS = --cov=ansys.simai --cov-report=term --cov-report=xml:.cov/xml --cov-report=html:.cov/html +commands = + pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv} + +[testenv:style] +description = Checks project code style +skip_install = true +deps = + pre-commit +commands = + pre-commit install + pre-commit run --all-files --show-diff-on-failure + +[testenv:doc] +description = Check if documentation generates properly +extras = + doc +commands = + sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxinidir}/_build/html" --color -vW -bhtml