Skip to content

QST: pytask-parallel with sphinx #35

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

Closed
hildebrandecon opened this issue Feb 9, 2022 · 2 comments
Closed

QST: pytask-parallel with sphinx #35

hildebrandecon opened this issue Feb 9, 2022 · 2 comments
Labels
question Further information is requested

Comments

@hildebrandecon
Copy link

Good morning Tobi,

I thought about using pytask-parallel for a project where I also use sphinx to compile a documentation of my code. There seems to be an issue with that, however. Say, I have the .rst documentation files in the folder src/00_documentation. The task in that folder is the following:

"""
Build the pdf and html documentation using Sphinx.

`task_build_documentation` executes Sphinx via pytask-latex and stores the output in
*bld/00_documentation*.
"""
import subprocess
from pathlib import Path

import pytask

from src.config import BLD
from src.config import SRC


@pytask.mark.depends_on(
    list(Path(__file__).resolve().parent.glob("*.rst"))
    + [SRC / "00_documentation" / "conf.py"]
)
@pytask.mark.parametrize(
    "builder, produces",
    [
        ("latexpdf", BLD / "00_documentation" / "latex" / "project_documentation.pdf"),
        ("html", (BLD / "00_documentation" / "html").rglob("*.*")),
    ],
)
def task_build_documentation(builder, produces):
    subprocess.run(
        [
            "sphinx-build",
            "-M",
            builder,
            SRC.joinpath("00_documentation").as_posix(),
            BLD.joinpath("00_documentation").as_posix(),
        ]
    )

Now, I am running:

pytask -n auto src/00_documentation/

I get the following error:

image
image
image

If you need further details for reproducing the error, I can share an example project with you! I hope this helps to improve the tool even further.

Best,
Sebastian

@hildebrandecon hildebrandecon added the question Further information is requested label Feb 9, 2022
@tobiasraabe
Copy link
Member

tobiasraabe commented Feb 9, 2022

The only generator I can see is (BLD / "00_documentation" / "html").rglob("*.*"). Try list((BLD / "00_documentation" / "html").rglob("*.*"))

@hildebrandecon
Copy link
Author

Great, that works! Thanks a lot. However, even better is BLD / "00_documentation" / "html" / "00_index.html" as it fixes the issue of running in parallel as well as the issue of pytask not recognising whether the html output was created at all. This will be fixed in future version of the templates of HMG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants