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

Download meshes for tutorials #1037

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Download meshes for tutorials #1037

wants to merge 5 commits into from

Conversation

KnutAM
Copy link
Member

@KnutAM KnutAM commented Aug 2, 2024

Solve #1033

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.61%. Comparing base (7262272) to head (ad17cd4).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1037   +/-   ##
=======================================
  Coverage   93.61%   93.61%           
=======================================
  Files          39       39           
  Lines        5893     5893           
=======================================
  Hits         5517     5517           
  Misses        376      376           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +201 to +210
import Downloads #hide
meshfile = "periodic-rve.msh" #src
#jl meshfile = "periodic-rve.msh"
#md meshfile = "periodic-rve-coarse.msh" #hide
#nb meshfile = "periodic-rve-coarse.msh"
isfile(meshfile) || Downloads.download( #hide
string("https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/", meshfile), #hide
meshfile) #hide
grid = togrid(meshfile) #src
#nb grid = togrid(meshfile)
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be easier to add docs for the download file (i.e. docs/download_resources) instead of moving the download logic into the tutorial files? I think having a central point where the external resources are defined for the download is easier to maintain in the long run than splitting it apart like this,.

Copy link
Member Author

@KnutAM KnutAM Aug 2, 2024

Choose a reason for hiding this comment

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

I was thinking about it, but for a user who copies the tutorial, it is nice to be able to copy the code and run directly I suppose?

Or did you mean to include via literate, so that the shown case (in cases we actually show the downloads in the docs) will include (part of) the code in docs/download_resources? (ref)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think having a central point where the external resources are defined for the download is easier to maintain in the long run than splitting it apart like this,.

These are tutorials that should be able to be runnable by someone reading them so whatever is done it should be visible from the source code itself.

Copy link
Member Author

@KnutAM KnutAM Aug 2, 2024

Choose a reason for hiding this comment

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

One solution would be to add a non-exported function

asset_url(file) = string("https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/", file)

to Ferrite itself, which would at least allow using

isfile(meshfile) || Downloads.download(Ferrite.asset_url(meshfile), meshfile)

above, which looks prettier at least, and would allow changing the location of the assets easily in the future. But feels ugly to add such things to the base package?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, this is only used in two places, so I suggest to do it this "distributed" way for now, to solve #1033. Would be great with a nice solution including a "central point" in the future though.

@KnutAM KnutAM marked this pull request as ready for review August 3, 2024 16:30
@KnutAM KnutAM requested a review from KristofferC August 3, 2024 16:30
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.

Having mesh files in the example be downloaded as a part of building the docs is surprising
3 participants