From 1311f0506ae3b57533b97a7099f714c17112c915 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Thu, 5 Jan 2023 08:25:02 -0700 Subject: [PATCH 01/20] publishing to pypi can only happen with a push, not a pr --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2cf52f829..724cedb8c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -46,7 +46,7 @@ jobs: skip_existing: true - name: publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: python_version: ${{ matrix.python-version }} From 25639accd4284565ca141bcee2d50687e8d21dfa Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Thu, 5 Jan 2023 08:39:59 -0700 Subject: [PATCH 02/20] trigger --- .github/workflows/cd.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 724cedb8c..55a1db7a0 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,7 +5,9 @@ on: branches: - develop - main - release: + push: + branches: + - main jobs: @@ -46,7 +48,7 @@ jobs: skip_existing: true - name: publish distribution 📦 to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: python_version: ${{ matrix.python-version }} From e739c209311900586138aa2723509fc806b7860f Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Thu, 5 Jan 2023 08:53:48 -0700 Subject: [PATCH 03/20] fix pypi inputs --- .github/workflows/cd.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 55a1db7a0..581508397 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -51,5 +51,4 @@ jobs: if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: - python_version: ${{ matrix.python-version }} - pypi_token: ${{ secrets.PYPI_API_TOKEN }} + password: ${{ secrets.PYPI_API_TOKEN }} From a7659a1c50bfc53d8658a8739da8032bdd327d22 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Thu, 5 Jan 2023 09:59:51 -0700 Subject: [PATCH 04/20] add on release --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 581508397..2452539df 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,6 +8,7 @@ on: push: branches: - main + release: jobs: From ea769a11af8381945a559947d42db3f35bd7acd0 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 14:36:36 -0700 Subject: [PATCH 05/20] update docs.yml --- .github/workflows/docs.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 59c26e9b2..4b23a0ef7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,8 +2,8 @@ name: build-deploy-docs on: push: - branches: - - main + # branches: + # - main # If your git repository has the Jupyter Book within some-subfolder next to # unrelated files, you can make this run only if a file within that specific # folder has been modified. @@ -36,11 +36,14 @@ jobs: - name: build jupyter book working-directory: ${{runner.workspace}}/BuildingMOTIF/docs/ - run: jupyter-book build . + run: | #jupyter-book build . + jupyter-book config sphinx . + sphinx-build . _build/html -b html + # TODO can we use an official GitHub Action? https://github.com/actions/deploy-pages - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/_build/html + # - name: GitHub Pages action + # uses: peaceiris/actions-gh-pages@v3.6.1 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # publish_dir: ./docs/_build/html From 78db0c4a35e7735a188a2215eb3e39347a2cc7fd Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 14:42:33 -0700 Subject: [PATCH 06/20] add default .readthedocs.yaml --- .readthedocs.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 000000000..a83fae56d --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,29 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.11" + # You can also specify other tool versions: + # nodejs: "19" + # rust: "1.64" + # golang: "1.19" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +# If using Sphinx, optionally build your docs in additional formats such as PDF +# formats: +# - pdf + +# Optionally declare the Python requirements required to build your docs +python: + install: + - requirements: docs/requirements.txt \ No newline at end of file From 6027a4b6ec223614d45d90c19c6ae658a9602437 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 14:49:25 -0700 Subject: [PATCH 07/20] rename docs/README.md to index.md --- docs/{README.md => index.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{README.md => index.md} (100%) diff --git a/docs/README.md b/docs/index.md similarity index 100% rename from docs/README.md rename to docs/index.md From afaea7eda8c433d6c1d05d1cdca6509cb63f057f Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 14:49:57 -0700 Subject: [PATCH 08/20] update toc --- docs/_toc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_toc.yml b/docs/_toc.yml index 3a50ef1de..2439fe271 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -3,7 +3,7 @@ # framework = https://diataxis.fr/ format: jb-book -root: README +root: index parts: - caption: Reference chapters: From 0c27e4607cfc69006ab784a4ce83a76ddb2c8e8d Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 15:13:17 -0700 Subject: [PATCH 09/20] intro.md is default --- docs/_toc.yml | 2 +- docs/{index.md => intro.md} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/{index.md => intro.md} (100%) diff --git a/docs/_toc.yml b/docs/_toc.yml index 2439fe271..9f0afcece 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -3,7 +3,7 @@ # framework = https://diataxis.fr/ format: jb-book -root: index +root: intro parts: - caption: Reference chapters: diff --git a/docs/index.md b/docs/intro.md similarity index 100% rename from docs/index.md rename to docs/intro.md From 14bd728e9b9615a88002fad92f901526edb2a88b Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Tue, 10 Jan 2023 15:21:05 -0700 Subject: [PATCH 10/20] update .readthedocs.yaml --- .readthedocs.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a83fae56d..b175b5e86 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,11 +9,15 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.10" # You can also specify other tool versions: # nodejs: "19" # rust: "1.64" # golang: "1.19" + jobs: + pre_build: + # Generate the Sphinx configuration for this Jupyter Book so it builds. + - "jupyter-book config sphinx docs/" # Build documentation in the docs/ directory with Sphinx sphinx: From 73ac02eab139a0800dc11c802c8a6960392f783e Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:05:42 -0700 Subject: [PATCH 11/20] exclude/skip conf.py --- mypy.ini | 3 ++- pylama.ini | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 1f858c6ce..540fe0531 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,3 @@ [mypy] -plugins = sqlalchemy.ext.mypy.plugin \ No newline at end of file +plugins = sqlalchemy.ext.mypy.plugin +exclude = docs/conf.py \ No newline at end of file diff --git a/pylama.ini b/pylama.ini index e1219f0f1..826b6f212 100644 --- a/pylama.ini +++ b/pylama.ini @@ -1,2 +1,3 @@ [pylama] ignore = E203 +skip = docs/conf.py From 555144a1e950dd5680717bcdee103a8aeb141013 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:09:39 -0700 Subject: [PATCH 12/20] exclude conf.py from pre-commit --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dcf4b5715..48d90a15e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,3 +19,4 @@ repos: - id: mypy args: ["--install-types", "--non-interactive", "--ignore-missing-imports"] additional_dependencies: [sqlalchemy2-stubs <= 0.0.2a20, SQLAlchemy <= 1.4] +exclude: docs/conf.py \ No newline at end of file From d295d9598bada1b52ebec5da9b36c3ef4538f116 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:09:56 -0700 Subject: [PATCH 13/20] add conf.py --- docs/conf.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 docs/conf.py diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..6e74e26b4 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,38 @@ +############################################################################### +# Auto-generated by `jupyter-book config` +# If you wish to continue using _config.yml, make edits to that file and +# re-generate this one. +############################################################################### +add_module_names = False +author = 'NREL' +autodoc_default_options = {'members': True, 'member-order': 'bysource', 'undoc-members': True, 'private-members': False} +autosummary_generate = True +bibtex_bibfiles = ['bibliography.bib'] +comments_config = {'hypothesis': False, 'utterances': False} +copyright = '2022' +exclude_patterns = ['**.ipynb_checkpoints', '.DS_Store', 'Thumbs.db', '_build'] +execution_allow_errors = False +execution_excludepatterns = [] +execution_in_temp = False +execution_timeout = 30 +extensions = ['sphinx_togglebutton', 'sphinx_copybutton', 'myst_nb', 'jupyter_book', 'sphinx_thebe', 'sphinx_comments', 'sphinx_external_toc', 'sphinx.ext.intersphinx', 'sphinx_design', 'sphinx_book_theme', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinxcontrib.bibtex', 'sphinx_jupyterbook_latex'] +external_toc_exclude_missing = False +external_toc_path = '_toc.yml' +html_baseurl = '' +html_favicon = '' +html_logo = '' +html_sourcelink_suffix = '' +html_theme = 'sphinx_book_theme' +html_theme_options = {'search_bar_text': 'Search this book...', 'launch_buttons': {'notebook_interface': 'classic', 'binderhub_url': 'https://mybinder.org', 'jupyterhub_url': '', 'thebe': False, 'colab_url': ''}, 'path_to_docs': 'docs', 'repository_url': 'https://github.com/NREL/BuildingMOTIF', 'repository_branch': 'main', 'google_analytics_id': '', 'extra_navbar': 'Powered by Jupyter Book', 'extra_footer': '', 'home_page_in_toc': True, 'announcement': '⚠️ This is an ALPHA release for testing purposes only ⚠️', 'use_repository_button': True, 'use_edit_page_button': False, 'use_issues_button': True} +html_title = 'BuildingMOTIF Documentation' +jupyter_cache = '' +jupyter_execute_notebooks = 'force' +latex_engine = 'pdflatex' +myst_enable_extensions = ['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist'] +myst_url_schemes = ['mailto', 'http', 'https'] +nb_output_stderr = 'show' +numfig = True +pygments_style = 'sphinx' +suppress_warnings = ['myst.domains'] +use_jupyterbook_latex = True +use_multitoc_numbering = True From 0256f9fa891fb1628308b6084659d15990f25183 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:22:51 -0700 Subject: [PATCH 14/20] remove exclude/skip conf.py --- mypy.ini | 3 +-- pylama.ini | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mypy.ini b/mypy.ini index 540fe0531..1f858c6ce 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,2 @@ [mypy] -plugins = sqlalchemy.ext.mypy.plugin -exclude = docs/conf.py \ No newline at end of file +plugins = sqlalchemy.ext.mypy.plugin \ No newline at end of file diff --git a/pylama.ini b/pylama.ini index 826b6f212..f55351897 100644 --- a/pylama.ini +++ b/pylama.ini @@ -1,3 +1,2 @@ [pylama] -ignore = E203 -skip = docs/conf.py +ignore = E203 \ No newline at end of file From ef1805c2a074adcc0e9d410f54ac9a3b23738ee9 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:23:22 -0700 Subject: [PATCH 15/20] update .readthedocs.yaml --- .readthedocs.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b175b5e86..4f4552e28 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -28,6 +28,6 @@ sphinx: # - pdf # Optionally declare the Python requirements required to build your docs -python: - install: - - requirements: docs/requirements.txt \ No newline at end of file +# python: +# install: +# - requirements: docs/requirements.txt \ No newline at end of file From 04878fe31d18165da0397e55d5cb6fe86410d3d9 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:29:19 -0700 Subject: [PATCH 16/20] rename intro back to README --- docs/{intro.md => README.md} | 0 docs/_toc.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/{intro.md => README.md} (100%) diff --git a/docs/intro.md b/docs/README.md similarity index 100% rename from docs/intro.md rename to docs/README.md diff --git a/docs/_toc.yml b/docs/_toc.yml index 9f0afcece..3a50ef1de 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -3,7 +3,7 @@ # framework = https://diataxis.fr/ format: jb-book -root: intro +root: README parts: - caption: Reference chapters: From a7a518dbd0cb09d0fa5b0e5931a75e7925c10bfa Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:33:04 -0700 Subject: [PATCH 17/20] update README files with ReadTheDocs badge --- README.md | 2 +- docs/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 248de9ae7..3016e804b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # BuildingMOTIF [![codecov](https://codecov.io/gh/NREL/BuildingMOTIF/branch/main/graph/badge.svg?token=HAFSYH45NX)](https://codecov.io/gh/NREL/BuildingMOTIF) -[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://nrel.github.io/BuildingMOTIF/) +[![Documentation Status](https://readthedocs.org/projects/buildingmotif/badge/?version=latest)](https://buildingmotif.readthedocs.io/en/latest/?badge=latest) ![PyPI](https://img.shields.io/pypi/v/buildingmotif) ![PyPI - Downloads](https://img.shields.io/pypi/dm/buildingmotif) diff --git a/docs/README.md b/docs/README.md index 248de9ae7..3016e804b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,7 @@ # BuildingMOTIF [![codecov](https://codecov.io/gh/NREL/BuildingMOTIF/branch/main/graph/badge.svg?token=HAFSYH45NX)](https://codecov.io/gh/NREL/BuildingMOTIF) -[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://nrel.github.io/BuildingMOTIF/) +[![Documentation Status](https://readthedocs.org/projects/buildingmotif/badge/?version=latest)](https://buildingmotif.readthedocs.io/en/latest/?badge=latest) ![PyPI](https://img.shields.io/pypi/v/buildingmotif) ![PyPI - Downloads](https://img.shields.io/pypi/dm/buildingmotif) From 676b93f38d85dbc1b2f61bb84699c0d3108885df Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 10:58:40 -0700 Subject: [PATCH 18/20] update docs.yml --- .github/workflows/docs.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4b23a0ef7..c974d386e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,8 +2,9 @@ name: build-deploy-docs on: push: - # branches: - # - main + branches: + - main + - develop # If your git repository has the Jupyter Book within some-subfolder next to # unrelated files, you can make this run only if a file within that specific # folder has been modified. @@ -36,14 +37,13 @@ jobs: - name: build jupyter book working-directory: ${{runner.workspace}}/BuildingMOTIF/docs/ - run: | #jupyter-book build . + run: | jupyter-book config sphinx . sphinx-build . _build/html -b html - # TODO can we use an official GitHub Action? https://github.com/actions/deploy-pages - # - name: GitHub Pages action - # uses: peaceiris/actions-gh-pages@v3.6.1 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # publish_dir: ./docs/_build/html + - name: GitHub Pages action + uses: peaceiris/actions-gh-pages@v3.6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html From ae70c834fffe489459953a5c768cd9883e2fa4b1 Mon Sep 17 00:00:00 2001 From: Matt Steen Date: Wed, 11 Jan 2023 11:18:31 -0700 Subject: [PATCH 19/20] exclude/skip conf.py --- mypy.ini | 3 ++- pylama.ini | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mypy.ini b/mypy.ini index 1f858c6ce..9b3eff535 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,3 @@ [mypy] -plugins = sqlalchemy.ext.mypy.plugin \ No newline at end of file +plugins = sqlalchemy.ext.mypy.plugin +exclude = docs/conf.py diff --git a/pylama.ini b/pylama.ini index f55351897..826b6f212 100644 --- a/pylama.ini +++ b/pylama.ini @@ -1,2 +1,3 @@ [pylama] -ignore = E203 \ No newline at end of file +ignore = E203 +skip = docs/conf.py From 0b51a9d8c6cd1de6387a90eab2b7da1c97632dec Mon Sep 17 00:00:00 2001 From: Hannah Eslinger Date: Wed, 11 Jan 2023 16:14:59 -0700 Subject: [PATCH 20/20] Fix Library serralizer --- buildingmotif/api/serializers/library.py | 6 ++++-- tests/unit/api/test_library.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/buildingmotif/api/serializers/library.py b/buildingmotif/api/serializers/library.py index 1046fb2e8..619a950b6 100644 --- a/buildingmotif/api/serializers/library.py +++ b/buildingmotif/api/serializers/library.py @@ -2,7 +2,7 @@ from typing_extensions import TypedDict -from buildingmotif.database.tables import DBLibrary +from buildingmotif.database.tables import DBLibrary, DBTemplate LibraryDict = TypedDict( "LibraryDict", @@ -43,9 +43,11 @@ def _serialize(library: DBLibrary) -> LibraryDict: :return: serialized library :rtype: LibraryDict """ + templates: List[DBTemplate] = library.templates # apleasing the type checker. + return { "id": library.id, "name": library.name, - "template_ids": library.templates, + "template_ids": [t.id for t in templates], "shape_collection_id": library.shape_collection_id, } diff --git a/tests/unit/api/test_library.py b/tests/unit/api/test_library.py index 118d3a47e..4b22080d0 100644 --- a/tests/unit/api/test_library.py +++ b/tests/unit/api/test_library.py @@ -27,6 +27,7 @@ def test_get_all_libraries(client, building_motif): def test_get_library(client, building_motif): # Setup lib = Library.create("my_library") + lib.create_template("my_template") # Act results = client.get(f"/libraries/{lib.id}")