Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sphinx documentation (incl. built html files) and deploy workflow #3

Closed
wants to merge 22 commits into from
Closed

Add Sphinx documentation (incl. built html files) and deploy workflow #3

wants to merge 22 commits into from

Conversation

MarcoHuebner
Copy link
Collaborator

@MarcoHuebner MarcoHuebner commented May 7, 2023

Rohversion einer Sphinx Doku, dementsprechend ebenfalls pyproject.toml dev-dependencies angepasst

tbd:

  • (Done) Design (aktuell: Sphinx Standard)
  • (Done) Testen des Bauens der Dokumentation in CI/CD (und vllt. lokal)
  • "Hosting" z.B. auf readthedocs -> CorrelAid Account?
    • Automatisches Bauen der Dokumentation bei Code Updates/ PRs?
  • Copyright (CorrelAid...?), Autoren und weitere Metadaten?

resolves #10

@MarcoHuebner MarcoHuebner self-assigned this May 7, 2023
@pmayd
Copy link
Collaborator

pmayd commented May 7, 2023

Das sind ne Menge roter Tests XD Schön, dass hier noch weiter gearbeitet wird, mir war nicht bewusst, das jemand daran arbeitet aber ich schaue es mir gerne an!

@MarcoHuebner
Copy link
Collaborator Author

Oje - werde mir in den nächsten zwei Wochen mal anschauen, woher die grundlegenden Fehler kommen. Die Rohversion sollte eigentlich keine Tests - außer vllt. code quality - beeinflussen, ich wollte mit dem PR erstmal mögliche feature-Wünsche abklappern :)

@pmayd
Copy link
Collaborator

pmayd commented May 8, 2023

Relativ einfach die angegebenen Versionen von Python existieren wohl nicht mehr, warum auch immer, sollte also schnell behoben sein

…in cache and cube. Hosting on ReadTheDocs has to be done by Owner/ CorrelAid (but can be requested and triggered that way).
@MarcoHuebner
Copy link
Collaborator Author

MarcoHuebner commented May 14, 2023

Current issues seem to be related to changes/ issues in urllib3 together with cachecontrol. Working on a fix.

@@ -138,7 +138,6 @@ Distributed under the MIT License. See `LICENSE.txt` for more information.
A few ideas we should implement in the maybe-near future:

- Improve Table parsing. Right now, the parsing is really simple and we should align the cube and table format so that the data frame for tables is more convenient to use.
- Create a source code documentation with Sphinx or similar tools.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Defaults to True.
rename_time_variable (bool, optional): If True, rename the time variable.
Defaults to True.
Defaults to True.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this one but I think Google stylesheet says to intend the line if the string belongs to the previous line so Defaults to True is part of the parameter rename_classifying_variables. But not important and if it works with Sphinx fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative would be to have it (Defaults...) all in one line. At least locally this solution complies with black & pylint. The problem with sphinx is, that the indentations (without clear, return-separated blocks) are "unexpected" (warning, no error).

Copy link
Collaborator

@pmayd pmayd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if it works ;)

@pmayd
Copy link
Collaborator

pmayd commented May 16, 2023

Rohversion einer Sphinx Doku, dementsprechend ebenfalls pyproject.toml dev-dependencies angepasst

tbd:

* (Done) Design (aktuell: Sphinx Standard)

* (Done) Testen des Bauens der Dokumentation in CI/CD (und vllt. lokal)

* "Hosting" z.B. auf [readthedocs](https://docs.readthedocs.io/en/stable/tutorial/index.html) -> CorrelAid Account?
  
  * Automatisches Bauen der Dokumentation bei Code Updates/ [PRs](https://docs.readthedocs.io/en/stable/tutorial/index.html#trigger-a-build-from-a-pull-request)?

* Copyright (CorrelAid...?), Autoren und weitere Metadaten?

yea we could definitely publish to readthedocs, but let's first have the local version working and deployed

@MarcoHuebner
Copy link
Collaborator Author

Should I add more info on sphinx in the ReadMe? Testing whether the build works is already integrated into the CI/CD (afaik/ afai can test), and local deployment - as far as I understand - would be cd docs && make html. That could be clarified/ stated in the ReadMe since I did not do so already.

Opinion/ vision for aforementioned local deployment?

@pmayd
Copy link
Collaborator

pmayd commented May 16, 2023

Yes I think a few sentences or a reference would be helpful to understand what is done here and how to write docu in sphinx.

Regarding local deployment I guess the make command is enough so just mention how to create the docu locally. Should also add a custom pre-commit hook.

And add long as we don't deploy it maybe create an artifact in the workflow, does GitHub support ? In precious projects on work I created docu with tools in cicd and made the final docu available as artifacts so that a push automatically build the latest docu and make it available as artifacts

…e-commit hook and changed to hard-coded version in docs, added built documentation to artifacts, #3
@MarcoHuebner
Copy link
Collaborator Author

  • Updated ReadMe with a "full documentation" subsection
  • Added custom pre-commit hook (but thus had to change the docs package version to a hard-coded one to avoid importing the pystatis package. ReadTheDocs also seems to do it that way... therefore added another version test...
  • Uploaded docs as artifact - are the standard 90 days storage time ok?

TODOs:
- Create `gh-pages` branch
- Add index.html and maybe .nojekyll
- Add deploy SSH Key: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-create-ssh-deploy-key
- setup GitHub Pages in the settings: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-first-deployment-with-github_token
- After that, the documentation should automatically be hosted at http://correlaid.github.io/pystatis
Detailed walkthrough: https://pages.github.com/

Addresses #10
@MarcoHuebner
Copy link
Collaborator Author

MarcoHuebner commented Oct 22, 2023

Detailed walkthrough: https://pages.github.com/

TODOs:

Note: code-quality should be fixed after #9 / feature/T9-update-dependencies branch is addressed

@pmayd
Copy link
Collaborator

pmayd commented Oct 23, 2023

How is this PR related to #4 ?

@MarcoHuebner
Copy link
Collaborator Author

MarcoHuebner commented Oct 24, 2023

How is this PR related to #4 ?

Did I write that in a commit message here? If so sorry, I meant that the T9-branch and #9 have addressed #4 IMO

@pmayd
Copy link
Collaborator

pmayd commented Oct 25, 2023

I updated the dev branch so you can rebase/merge again.

Is this PR ready for merge?

@MarcoHuebner MarcoHuebner changed the title Updated dev-dependencies, added first version of Sphinx documentation (incl. built html files) Add Sphinx documentation (incl. built html files) Oct 28, 2023
@MarcoHuebner MarcoHuebner changed the title Add Sphinx documentation (incl. built html files) Add Sphinx documentation (incl. built html files) and deploy workflow Oct 28, 2023
@MarcoHuebner
Copy link
Collaborator Author

Is this PR ready for merge?

No, since it already has a deploy workflow - which will likely fail without the existence of a gh-pages branch to push the built documentation to. If we want to merge it now and reopen another branch later, we would have to remove at least the deploy-docs.yaml

Also, update the versions in the workflows

Addresses #10
Render parts of the README.md in the respective .rst files
@MarcoHuebner
Copy link
Collaborator Author

Managed to remove manual updating of the .rst files to only having to update the headers and references to the rendered section of the README.md (and package metadata).

One minor flaw remains: Images are not rendered correctly (yet).

@MarcoHuebner
Copy link
Collaborator Author

MarcoHuebner commented Nov 2, 2023

The documentation can already be found under Actions / Workflow Runs / / Artifacts -> docs. This makes the documentation directory downloadable as a .zip which can be viewed locally after unpacking.

Next steps:

  1. Adjust the artifact storage time if necessary
  2. Set up GitHub pages. Steps:
  • Create a gh-pages branch (or any other name)
  • Add an index.html (copy from build/html) and maybe .nojekyll or _config.yml (see here) to the documentation publish (e.g. gh-pages) branch
  • Decide whether to use GitHub Token or deploy SSH Key ->
  • After that, the documentation should automatically be hosted at http://correlaid.github.io/pystatis

@pmayd
Copy link
Collaborator

pmayd commented Nov 3, 2023

I have done the necessary setup steps for the deploy SSH key, you can use it now as it is a repository secret:

- name: Deploy
  uses: peaceiris/actions-gh-pages@v3
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    publish_dir: ./public

@MarcoHuebner
Copy link
Collaborator Author

Alright, I updated the deploy key now. Things to consider - maybe in the next meeting on Tuesday:

  • When should this action be triggered? Only on push/ merge to main? Already on the pull request? What about dev?
  • Should we use force_orphan: true to only keep the newest documents
  • Maybe we'll need enable_jekyll: false if we experience problems with file/ folder names starting with a underscore _

@pmayd
Copy link
Collaborator

pmayd commented Nov 4, 2023

Alright, I updated the deploy key now. Things to consider - maybe in the next meeting on Tuesday:

  • When should this action be triggered? Only on push/ merge to main? Already on the pull request? What about dev?
  • Should we use force_orphan: true to only keep the newest documents
  • Maybe we'll need enable_jekyll: false if we experience problems with file/ folder names starting with a underscore _

Thanks! Have to test it out but it sounds perfect.

No, main is to limited, at least for dev and main you have to check the docu before deploying it to main. However, dev should be enough as a PR against dev already triggers the workflow so I always use PR against dev and main as trigger and I think that is perfect for this, too.

Yes, we should only keep the latest docu, we are nowhere near a first public version and there will be breaking changes all the time ...well I exaggerate but still I don't think we need to keep every version. But we should invest time in a proper release workflow next with proper Git tags etc

@MarcoHuebner
Copy link
Collaborator Author

The first deployment attempt failed with Error: Action failed with "not found deploy key or tokens". If I understand correctly, the SSH Key is personal, so I (and everyone else) would have to set up their own key.
A GITHUB_TOKEN however, should allow to automatically authenticate the runner/ workflow run: "A GitHub Actions runner automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run."

@pmayd
Copy link
Collaborator

pmayd commented Nov 4, 2023

That should not be the case the deploy key is not created under user settings but repo settings and it is a repository secret so no

@MarcoHuebner
Copy link
Collaborator Author

True... any obvious errors I'm making in calling the key? Typos in with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}? 🤔

@pmayd
Copy link
Collaborator

pmayd commented Nov 4, 2023

That should not be the case the deploy key is not created under user settings but repo settings and it is a repository secret so no .

From the docu: If the user who created the deploy key is removed from the repository, the deploy key will still be active as it isn't tied to the specific user, but rather to the repository.

@pmayd
Copy link
Collaborator

pmayd commented Nov 4, 2023

I don't think so, according to the doc it should be fairly simple: create the ssh key as public and the secret as private key and that's it...I will have a look later

@pmayd
Copy link
Collaborator

pmayd commented Nov 4, 2023

I found the problem which is logical if you think about it: you are on your own fork and that does not trigger the REPO secrets, you have to call from a branch in this repo.

Here the docu:
"Anyone with collaborator access to this repository can use these secrets and variables for actions. They are not passed to workflows that are triggered by a pull request from a fork."

@MarcoHuebner
Copy link
Collaborator Author

Moved this to #27

MarcoHuebner added a commit that referenced this pull request Dec 3, 2023
* Updated dev-dependencies, added first version of Sphinx documentation, including built html documentation.

* Added Logo, updated theme, updated GitHub workflow, fixed docstrings in cache and cube. Hosting on ReadTheDocs has to be done by Owner/ CorrelAid (but can be requested and triggered that way).

* Updated urllib3 version, but everything <2.0.0 (deprecating `strict`) should be fine...

* Updated poetry as recommended in cachecontrol issue report.

* Fixed black formatting, fixed make docs (is now ran by poetry).

* Fixed linting issue, updated packages, updated make docs.

* Updated ReadMe, added developer sphinx documentation, added custom pre-commit hook and changed to hard-coded version in docs, added built documentation to artifacts, #3

* Add deployment workflow, needs Repo updates

* Update depencies for Sphinx documentation #10

* Remove redundant docu information #10

Render parts of the README.md in the respective .rst files

* Remove unused mdinclude, fix run-test py version, update pre-commit #10

* Fix dependency group for SPhinx workflow #10

* Fix docstring parameter rendering in Sphinx #10

* Fix image rendering by mimicking folder structure #10

* Add comment on warnings related to ext.napoleon #10

* Rename deploy-docs #10

* Fix black format issue in conf.py #10

* Update deploy key, add deploy trigger comment #10

* Update documentation deploy workflow #10

* Switch to matrix.os definition #10

* Fix pull_request target in deploy workflow #10

* Update poetry.lock #10

* Import package version to Sphinx docu #10

* Manually fix black formatting issue #10

* With auto-deploy working, decrease retention days #10

* Update readme and Sphinx header references #10

* Fix deploy to update files on the remote #10
pmayd pushed a commit that referenced this pull request Jan 29, 2024
* Updated dev-dependencies, added first version of Sphinx documentation, including built html documentation.

* Added Logo, updated theme, updated GitHub workflow, fixed docstrings in cache and cube. Hosting on ReadTheDocs has to be done by Owner/ CorrelAid (but can be requested and triggered that way).

* Updated urllib3 version, but everything <2.0.0 (deprecating `strict`) should be fine...

* Updated poetry as recommended in cachecontrol issue report.

* Fixed black formatting, fixed make docs (is now ran by poetry).

* Fixed linting issue, updated packages, updated make docs.

* Updated ReadMe, added developer sphinx documentation, added custom pre-commit hook and changed to hard-coded version in docs, added built documentation to artifacts, #3

* Add deployment workflow, needs Repo updates

* Update depencies for Sphinx documentation #10

* Remove redundant docu information #10

Render parts of the README.md in the respective .rst files

* Remove unused mdinclude, fix run-test py version, update pre-commit #10

* Fix dependency group for SPhinx workflow #10

* Fix docstring parameter rendering in Sphinx #10

* Fix image rendering by mimicking folder structure #10

* Add comment on warnings related to ext.napoleon #10

* Rename deploy-docs #10

* Fix black format issue in conf.py #10

* Update deploy key, add deploy trigger comment #10

* Update documentation deploy workflow #10

* Switch to matrix.os definition #10

* Fix pull_request target in deploy workflow #10

* Update poetry.lock #10

* Import package version to Sphinx docu #10

* Manually fix black formatting issue #10

* With auto-deploy working, decrease retention days #10

* Update readme and Sphinx header references #10

* Fix deploy to update files on the remote #10
pmayd added a commit that referenced this pull request Feb 20, 2024
* Bump version to next major version #9

* Revert flake8 to ^3.0 for docstrings #9

* add a notebook that shows how to run init_config

* Make dev dependencies optional, update lock and README #9

* Update workflow install --with dev, add matrix poetry version #9

* Fix python and poetry version definition #9

* Fix python and poetry version definition #9

* fix lock file

* update dev dependencies and add python-dotenv to dev

* improve readme

* update readme

* Feat/8 handle multiple databases and users (#20)

* change config module to handle multiple databases

* finalize work on config module to handle multiple databases; significantly reduced lines of code by getting rid of the settings.ini

* add a new db module that serves as a layer between the user and the config. Can set the current active database and get the settings from the config

* simplify config module

* refactor code to implement new config; correct tests

* fix all remaining tests

* fix all text issues

* update notebooks according to latest changes in config

* drop support for Python 3.9 due to pipe operator for types and set supported versions to 3.10 and 3.11

* fix problem with config dir creation during setup

* fix isort

* Improve clear_cache output for full wipe, remove unused import

* Address all non global-related pylint issues #20

* because of complexity get rid of the current support of custom config dir and always use the default config dir under user home.

* fix all tests; get rid of settings.ini and functionality for user to define own config path; pystatis supports only default config path but custom data cache path

* fix all tests; get rid of settings.ini and functionality for user to define own config path; pystatis supports only default config path but custom data cache path

* refactor config module to work with a ConfigParser global config object instead of overwriting the config variable within the functions using global (bad style according to pylint)

* address pylint issues

* fix mypy issues

* fix pylint issues

---------

Co-authored-by: MarcoHuebner <marco_huebner1@gmx.de>

* update README to the latest changes of multi database support

* Added lists of all available statistics and tables

* Feat/10 update and auto deploy sphinx (#27)

* Updated dev-dependencies, added first version of Sphinx documentation, including built html documentation.

* Added Logo, updated theme, updated GitHub workflow, fixed docstrings in cache and cube. Hosting on ReadTheDocs has to be done by Owner/ CorrelAid (but can be requested and triggered that way).

* Updated urllib3 version, but everything <2.0.0 (deprecating `strict`) should be fine...

* Updated poetry as recommended in cachecontrol issue report.

* Fixed black formatting, fixed make docs (is now ran by poetry).

* Fixed linting issue, updated packages, updated make docs.

* Updated ReadMe, added developer sphinx documentation, added custom pre-commit hook and changed to hard-coded version in docs, added built documentation to artifacts, #3

* Add deployment workflow, needs Repo updates

* Update depencies for Sphinx documentation #10

* Remove redundant docu information #10

Render parts of the README.md in the respective .rst files

* Remove unused mdinclude, fix run-test py version, update pre-commit #10

* Fix dependency group for SPhinx workflow #10

* Fix docstring parameter rendering in Sphinx #10

* Fix image rendering by mimicking folder structure #10

* Add comment on warnings related to ext.napoleon #10

* Rename deploy-docs #10

* Fix black format issue in conf.py #10

* Update deploy key, add deploy trigger comment #10

* Update documentation deploy workflow #10

* Switch to matrix.os definition #10

* Fix pull_request target in deploy workflow #10

* Update poetry.lock #10

* Import package version to Sphinx docu #10

* Manually fix black formatting issue #10

* With auto-deploy working, decrease retention days #10

* Update readme and Sphinx header references #10

* Fix deploy to update files on the remote #10

* fix cube functionality: it seems like structure of QEI header part was changed as well as DQA no longer has information about axis so we assume that the order is preserved (#43)

* add jupytext and new nb for presentation

* Feat/35 implement regex matching (#44)

* Implemented regex matching, initial commit

* Added credentials check for cubes and removed all references to set_db()

* Implemented regex matching, initial commit

* Added credentials check for cubes and removed all references to set_db()

* fix tests

* refactoring Find and Result class to work with new database detection logic; because find does not use names like Table and Cube, use has to specify the database

* fix tests
---------

Co-authored-by: Michael Aydinbas <michael.aydinbas@gmail.com>
Co-authored-by: Michael Aydinbas <michael.aydinbas@new-work.se>

* add presentation nb

* remove presentation nb for now

* Feat/19 improve readability of the table format (#42)

* Reformatting the raw data tables for readability

* Adding comments

* Applied suggested changes and run code formatting

* add tests for Table

---------

Co-authored-by: Michael Aydinbas <michael.aydinbas@new-work.se>

* prepare Table so it can parse data from three different sources

* Added description and examples of Find

* implement parse logic for prettify zensus tables

* fix pylint issues

* edits on Find section

* fixing overwritten changes

* update presentation nb

* add genesis parse code for regio, too, for the moment.

* Feat/34 visualization examples (#48)

* Add 02_Geo_visualization_example.ipynb

* changed '-' to 0 instead of nan --> reproduce Simons result

* new case study in visualization notebook, integration to presentation notebook

* catch NA-values in read_csv and added Auspraegung_Code to table.py to have the unique region identifiers

---------

Co-authored-by: jkrause <jkrause123@users.noreply.github.com>

* final presentation nb and shape data; omit file check in pre-commit

* fixed typo and beautified plots in presentation.ipynb /.py

* add a first workaround for the new Zensus zip content type

* fix all tests; separate Find and Results classes into own modules

* update dependencies

* update README

* set version to 0.2

* remove Cubes from package for now; we no longer support cubes until they are requested

* fix all tests; fix all relevant nb;

* fix pylint issues

* fix mypy issues

* add documentation key

* update changelog

---------

Co-authored-by: MarcoHuebner <marco_huebner1@gmx.de>
Co-authored-by: Pia <45008571+PiaSchroeder@users.noreply.github.com>
Co-authored-by: MarcoHuebner <57489799+MarcoHuebner@users.noreply.github.com>
Co-authored-by: zosiaboro <50183305+zosiaboro@users.noreply.github.com>
Co-authored-by: Zosia Borowska <zofia.anna.borowska@gmail.com>
Co-authored-by: jkrause123 <89632018+jkrause123@users.noreply.github.com>
Co-authored-by: jkrause <jkrause123@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Sphinx Documentation: Docstring Inheritance Fix and Auto-Deployment
2 participants