Skip to content

Generate api docs for EESSI test suite #319

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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

xinan1911
Copy link
Collaborator

@xinan1911 xinan1911 commented Oct 10, 2024

A dependency of this PR is on EESSI/test-suite#192 as PR 192 resolves the build error for API docs

@xinan1911
Copy link
Collaborator Author

@casparvl Adjusted the deploy and schedule. This is ready for test

@casparvl
Copy link
Collaborator

Just to log for myself: to test this, one needs to

  • Git clone this feature branch
  • Clone the test suite in an src subdir: mkdir src && cd src && git clone https://github.com/EESSI/test-suite.git
  • Run mkdocs serve -a localhost:<someport>
  • Create a reverse tunnel to that node using ssh -L <someport>:localhost:<someport> <host_running_mkdocs_serve>
  • Go to localhost:<someport> in your browser.

uses: actions/checkout@v4
with:
repository: eessi/test-suite
path: src
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we just do this without path, i.e. in the current workdir? It will still clone into a subidr test-suite by default right? No need to nest that further inside a src I'd think.

# need to adjust to the test suite hook
#root = Path(__file__).parent.parent

TEST_SUITE = "src/test-suite"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, this would then just be `"test-suite"


import mkdocs_gen_files

# need to adjust to the test suite hook
Copy link
Collaborator

Choose a reason for hiding this comment

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

There seem to be quite some comments that are no longer relevant in this gen_ref_pages.py. Would be good to clean those up.

mkdocs.yml Outdated
@@ -43,7 +43,6 @@ nav:
- Set up environment: using_eessi/setting_up_environment.md
- Basic commands: using_eessi/basic_commands.md
- Demos: using_eessi/eessi_demos.md
- EESSI in CI: using_eessi/eessi_in_ci.md
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 why this was removed here, but this has a conflict with upstream that needs to be resolved anyway. I guess that'll sort this out too.

mkdocs.yml Outdated
default_handler: python
handlers:
python:
paths: [src/test-suite]
Copy link
Collaborator

@casparvl casparvl Nov 13, 2024

Choose a reason for hiding this comment

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

This could also be shortened to paths: [test-suite], see the above changes.

uses: actions/checkout@v4
with:
repository: eessi/test-suite
path: src
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we just do this without path, i.e. in the current workdir? It will still clone into a subidr test-suite by default right? No need to nest that further inside a src I'd think.

@@ -1,6 +1,9 @@
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: deploy documentation (only on push to main branch)
on:
schedule:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I don't think we want this in the regular deploy.yml. Having a cronjob that directly deploys the API docs means we have no human in the loop to check the changes to the API docs, and whether they make sense. I think the way this was implemented for the software overview in https://github.com/EESSI/docs/blob/main/.github/workflows/update_available_software.yml makes more sense for now: do a build of the docs, then create a PR based on that. It means the auto-generated docs will actually be part of this repo, i.e. the physical *.md files will be files within the EESSI/docs repo. That'll allow us to do a check on them before they get deployed.

Long term, we might want to do this fully automatically, without human in the loop. But to start with, I think the human in the loop would be a good thing (even if someone needs to keep an eye on those PRs and merge them).

Copy link
Collaborator

@casparvl casparvl left a comment

Choose a reason for hiding this comment

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

I think the main change I'd suggest here is to not do the API docs generation as part of the deploy.yml, but in a way similar to how the update_available_software.yml workflow works (i.e. copy that workflow, and adapt it to generate the API docs instead of the available software list). This workflow creates a PR to EESSI/docs every X time (on a cronjob), which allows us to have a human in the loop to check what was generated and if that makes sense.

In the future, we could even see if the workflow could be triggered on push to the main branch of EESSI/test-suite. It seems something like that should be possible https://medium.com/hostspaceng/triggering-workflows-in-another-repository-with-github-actions-4f581f8e0ceb but that's no priority right now.

@boegel boegel changed the title Generate api docs Generate api docs for EESSI test suite Nov 13, 2024
@@ -0,0 +1,50 @@
"""
Copy link
Collaborator

@laraPPr laraPPr May 6, 2025

Choose a reason for hiding this comment

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

This file should be added to ´scripts/generate_eessi_test-suite_api_docs´ with a README.md and a seperate requiremnets.txt file to stay consistent with what we did for the software_overview page.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You also mentioned this on slack

Yes, but you'll need to create a subdir test-suite, then clone the test suite in there (yes, that gives you a test-suite/test-suite dir...)

Can you also add that to the README.md

Copy link
Collaborator

Choose a reason for hiding this comment

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

And if we need to create a subdir with test-suite we should also add test-suite to .gitignore

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think there's some misunderstanding here. I'm not doing the same as the software overview page. I was planning to do that, but it turns out that is fundamentally impossible, because the way mkdocs autogenerates API docs is not by creating *.md files in the source directory (i.e. docs/docs), but by directly creating files in the site directory. I.e. those are not (and should not be) part of the sources - they are what you get after you 'build' the docs.

So, integrating the requirements for this into the regular requirements file is completely valid: the API docs are now an integral part of the docs. As soon as you generate the documentation with an mkdocs serve or similar command, it will create the API docs.

Can you also add that to the README.md

That's actually not a bad idea, but should probably be in the README.md of the main docs repo.

And if we need to create a subdir with test-suite we should also add test-suite to .gitignore

We could. I wouldn't consider it super essential, since you'd only checkout the test-suite when building the docs - and all of that happens in a CI workflow anyway - but sure, if you'd build it locally and don't want to see the test-suite if you doe git status... why not :)

nav = mkdocs_gen_files.Nav()

# Loop through all python files in test-suite/eessi
for path in sorted(Path(f"{TEST_SUITE}/eessi/").rglob("*.py")):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like some logging and error reporting because I had not added the subdir test-suite and the script was just ran doing nothing. But I believe it should error out when it cannot find the test-suite subdir.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point, I'll look at that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like some logging and error reporting because I had not added the subdir test-suite and the script was just ran doing nothing. But I believe it should error out when it cannot find the test-suite subdir.

@casparvl will you still return to this comment? Or should we just merge and leave this for later?

@laraPPr
Copy link
Collaborator

laraPPr commented May 6, 2025

I tried but I'm getting this error

INFO    -  DeprecationWarning: The `get_logger` function is deprecated.

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/agents/nodes/runtime.py",

           line 17, in <module>

               _logger = get_logger("griffe.agents.nodes._runtime")

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/logger.py",

           line 117, in get_logger

               warnings.warn("The `get_logger` function is deprecated.",

           DeprecationWarning, stacklevel=1)

INFO    -  DeprecationWarning: The `name` parameter is deprecated.

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/docstrings/google.py",

           line 49, in <module>

               _warn = docstring_warning("griffe.docstrings.google")

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/docstrings/utils.py",

           line 83, in docstring_warning

               warnings.warn("The `name` parameter is deprecated.",

           DeprecationWarning, stacklevel=1)

INFO    -  DeprecationWarning: invalid escape sequence \S

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/agents/visitor.py",

           line 203, in get_module

               top_node = compile(self.code, mode="exec",

           filename=str(self.filepath), flags=ast.PyCF_ONLY_AST, optimize=1)

             File

           "/home/lara/Documents/EESSI/docs/test-suite/test-suite/eessi/testsuite/tests/apps/tensorflow/tensorflow.py",

           line 55, in

               accuracy = sn.extractsingle('^Final accuracy: (?P<accuracy>\S+)',

           self.stdout, 'accuracy', float)  # noqa: W605

WARNING -  griffe: test-suite/test-suite/eessi/testsuite/common_config.py:76:

           Failed to parse field directive from ':param: prefix: prefix for the

           report_file'

I was running with python 3.9.21

@laraPPr
Copy link
Collaborator

laraPPr commented May 6, 2025

I tried but I'm getting this error

INFO    -  DeprecationWarning: The `get_logger` function is deprecated.

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/agents/nodes/runtime.py",

           line 17, in <module>

               _logger = get_logger("griffe.agents.nodes._runtime")

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/logger.py",

           line 117, in get_logger

               warnings.warn("The `get_logger` function is deprecated.",

           DeprecationWarning, stacklevel=1)

INFO    -  DeprecationWarning: The `name` parameter is deprecated.

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/docstrings/google.py",

           line 49, in <module>

               _warn = docstring_warning("griffe.docstrings.google")

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/docstrings/utils.py",

           line 83, in docstring_warning

               warnings.warn("The `name` parameter is deprecated.",

           DeprecationWarning, stacklevel=1)

INFO    -  DeprecationWarning: invalid escape sequence \S

             File

           "/home/lara/.local/lib/python3.9/site-packages/_griffe/agents/visitor.py",

           line 203, in get_module

               top_node = compile(self.code, mode="exec",

           filename=str(self.filepath), flags=ast.PyCF_ONLY_AST, optimize=1)

             File

           "/home/lara/Documents/EESSI/docs/test-suite/test-suite/eessi/testsuite/tests/apps/tensorflow/tensorflow.py",

           line 55, in

               accuracy = sn.extractsingle('^Final accuracy: (?P<accuracy>\S+)',

           self.stdout, 'accuracy', float)  # noqa: W605

WARNING -  griffe: test-suite/test-suite/eessi/testsuite/common_config.py:76:

           Failed to parse field directive from ':param: prefix: prefix for the

           report_file'

I was running with python 3.9.21

My mistake it was working it is just not very intuitive how to navigate the pages right now. Because you have so many empty pages might it be possible to add urls to the empty pages to the pages that are underneat it?

@casparvl
Copy link
Collaborator

casparvl commented May 7, 2025

Ah yeah,

WARNING -  griffe: test-suite/test-suite/eessi/testsuite/common_config.py:76:

           Failed to parse field directive from ':param: prefix: prefix for the

           report_file'

Is actually a bug we had in the test suite (incorrect docstring, because we have the :param: prefix:, which is not correct.

casparvl pushed a commit to casparvl/test-suite that referenced this pull request May 15, 2025
satishskamath added a commit to EESSI/test-suite that referenced this pull request May 15, 2025
Signed-off-by: laraPPr <lara.peeters@ugent.be>
@laraPPr
Copy link
Collaborator

laraPPr commented Jun 25, 2025

Ok I wanted to get this one over the finish line so made the updates that I wanted.
but now it is failing with

ERROR   -  mkdocstrings: eessi.testsuite.tests.apps.openfoam.openfoam could

           not be found

ERROR   -  Error reading page

           'testsuite_api/eessi/testsuite/tests/apps/openfoam/openfoam.md':

ERROR   -  Could not collect 'eessi.testsuite.tests.apps.openfoam.openfoam'

@laraPPr
Copy link
Collaborator

laraPPr commented Jun 25, 2025

Ok I wanted to get this one over the finish line so made the updates that I wanted. but now it is failing with

ERROR   -  mkdocstrings: eessi.testsuite.tests.apps.openfoam.openfoam could

           not be found

ERROR   -  Error reading page

           'testsuite_api/eessi/testsuite/tests/apps/openfoam/openfoam.md':

ERROR   -  Could not collect 'eessi.testsuite.tests.apps.openfoam.openfoam'

@satishskamath Can you look into those missing docstrings?

@laraPPr
Copy link
Collaborator

laraPPr commented Jun 25, 2025

I'll also try to resolve the merge conflicts

@satishskamath
Copy link

Ok I wanted to get this one over the finish line so made the updates that I wanted. but now it is failing with

ERROR   -  mkdocstrings: eessi.testsuite.tests.apps.openfoam.openfoam could

           not be found

ERROR   -  Error reading page

           'testsuite_api/eessi/testsuite/tests/apps/openfoam/openfoam.md':

ERROR   -  Could not collect 'eessi.testsuite.tests.apps.openfoam.openfoam'

@satishskamath Can you look into those missing docstrings?

Will take a look into it.

Signed-off-by: laraPPr <lara.peeters@ugent.be>
satishskamath added a commit to EESSI/test-suite that referenced this pull request Jun 26, 2025
This file added for generation of docs. Refer to the following PR:
EESSI/docs#319
@satishskamath
Copy link

@laraPPr Created EESSI/test-suite#271 to fix the openfoam ERRORs here. Can you merge it?


# If something is an __init__, use the directory name as the name of the python module instead of the filename
parts = list(module_path.parts)
if parts[-1] == "__init__":

Choose a reason for hiding this comment

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

I think the OpenFOAM PATH was not created properly because of this if condition, it does not have an else.

laraPPr added 5 commits June 26, 2025 15:08
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
laraPPr added 6 commits June 26, 2025 15:28
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
Signed-off-by: laraPPr <lara.peeters@ugent.be>
…test-suite

Signed-off-by: laraPPr <lara.peeters@ugent.be>
…ain branch

Signed-off-by: laraPPr <lara.peeters@ugent.be>
@laraPPr
Copy link
Collaborator

laraPPr commented Jun 26, 2025

@casparvl we are gonna need a new release of the test-suite but than this pr should be ready to merge

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.

6 participants