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

Prevent multiple runs for examples #183

Open
chaithyagr opened this issue Aug 28, 2024 · 2 comments
Open

Prevent multiple runs for examples #183

chaithyagr opened this issue Aug 28, 2024 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@chaithyagr
Copy link
Member

Currently we run examples once with sphinx gallery and once with test-examples. This is mainly done to ensure our coverage is rightly reported.
However, in practice the 2 can be done together.

A simple case:

import os
import coverage

# Start coverage collection
cov = coverage.Coverage()
cov.start()

# Sphinx configuration
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx_gallery.gen_gallery',
]

# Sphinx Gallery configuration
sphinx_gallery_conf = {
    'examples_dirs': 'examples',   # path to your example scripts
    'gallery_dirs': 'auto_examples',  # path where to save gallery generated output
    'filename_pattern': r'\.py',
    'run_stale_examples': True,  # Execute all examples even if they haven't changed
}

# Add a build-finished event to stop coverage and generate a report
def coverage_report(app, exception):
    cov.stop()
    cov.save()
    print("\nCoverage Summary:\n")
    cov.report()

def setup(app):
    app.connect('build-finished', coverage_report)

However, this is not trivial when we run examples in parallel. Some attempts was done in #181 but spawing an issue to track it separately,.

@chaithyagr chaithyagr self-assigned this Aug 28, 2024
@paquiteau
Copy link
Member

this was done in #181

@chaithyagr
Copy link
Member Author

Umm, no it wasnt. In fact, as I told, attempts were made, but some issues occurred...

@chaithyagr chaithyagr reopened this Sep 13, 2024
@paquiteau paquiteau added the documentation Improvements or additions to documentation label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants