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

Render on a separate directory #20

Merged
merged 13 commits into from
Feb 7, 2025
Merged

Render on a separate directory #20

merged 13 commits into from
Feb 7, 2025

Conversation

llrs-roche
Copy link
Collaborator

This works around the issue of rendering the file on the package installation directory. I think this could be the issue seen on the CI.

Note that there are two options&environmental variables to control where to copy the files and where to render the template. I hope this makes it easier on the CI than just a temporary directory for each package (my initial idea).

@llrs-roche llrs-roche requested a review from Gotfrid January 31, 2025 08:59
@Gotfrid
Copy link
Contributor

Gotfrid commented Jan 31, 2025

Hi, I installed this in a devcontainer via pak::pak('pharmar/riskreports@fix_workarounds') and now report generation fails altogether with the following error:

ERROR: NotFound: No such file or directory (os error 2): readfile '../../workspaces/pharmapkgs/_pkg_template_files/libs/quarto-html/quarto.js'
Path: ../../workspaces/pharmapkgs/_pkg_template_files/libs/quarto-html/quarto.js

Stack trace:
Path: ../../workspaces/pharmapkgs/_pkg_template_files/libs/quarto-html/quarto.js
    at readTextFileSync (ext:deno_fs/30_fs.js:864:10)
    at Object.Deno.readTextFileSync (file:///opt/quarto/bin/quarto.js:5225:25)
    at bundleModules (file:///opt/quarto/bin/quarto.js:78339:56)
    at pandocIngestSelfContainedContent (file:///opt/quarto/bin/quarto.js:78350:11)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async file:///opt/quarto/bin/quarto.js:78511:21
    at async withTimingAsync (file:///opt/quarto/bin/quarto.js:16980:25)
    at async Object.complete (file:///opt/quarto/bin/quarto.js:78506:13)
    at async Object.onPostProcess (file:///opt/quarto/bin/quarto.js:85977:36)
    at async renderFileInternal (file:///opt/quarto/bin/quarto.js:85961:5)
Warning message:
In quarto::quarto_render(template, output_format = "all", execute_params = params,  :Error running quarto cli.
Caused by error:
! System command 'quarto' failed

I think it would be beneficial if you could write tests that run on a github runner to check if the issue is resolved. Without some kind of CI it is impossible to distinguish general problem fix from your specific environment changes (specific version of quarto, certain env variables, etc). Alternatively, please consider using a devcontainer for reproducible development.

@llrs-roche
Copy link
Collaborator Author

@Gotfrid I setup github actions and they pass. Let me know if it works for you now.

@llrs-roche
Copy link
Collaborator Author

Template is copied now to the rendering directory. I also provided more informative message on each step that moved or deleted files, sorry for not thinking on adding this before.

# https://github.com/quarto-dev/quarto-r/issues/81#issuecomment-1375691267
# quarto rendering happens in the same place as the file/project
# To avoid issues copy to a different place and render there.
render_dir <- output_dir()
Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow output_dir() defaults to the root of my project, where I already have index.qmd to render the website. For this reason, length(template) condition fails down the line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can use options(riskreports_output_dir = "/path/output/dir") to set it.
I will document that function and export it.

Copy link
Contributor

Choose a reason for hiding this comment

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

With the most recent change I can see that the report is rendered, but in the very end quarto moves it to _site on its own accord - like we discussed on the call it's probably due to _quarto.yml config file. Do you think it something that we should accept and work around in {pharmapkgs}?

See the video attached, sorry for the quality, had to compress it to upload to gh.

CleanShot.2025-02-07.at.11.48.46.mp4

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From the point of view of riskreports, yes we should accept this behavior.

For the project, I doubt dealing with the CI will end up in an R package. But I think you can configure the project to specify the output directory of some files within the project. For example in the future the website might need to document the PACAKAGES files generation on a website so it will end up on a different menu and page. I know this is possible to organize with quarto.

@llrs-roche llrs-roche mentioned this pull request Feb 7, 2025
@Gotfrid Gotfrid self-requested a review February 7, 2025 13:30
Copy link
Contributor

@Gotfrid Gotfrid left a comment

Choose a reason for hiding this comment

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

Thank you for all the work, let's merge it and see it in action 🚀

On my end, I will address _site issue in the corresponding PR.

@llrs-roche llrs-roche merged commit d4b290f into main Feb 7, 2025
2 checks passed
@llrs-roche llrs-roche deleted the fix_workarounds branch February 7, 2025 13:55
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.

3 participants