-
Notifications
You must be signed in to change notification settings - Fork 101
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
Tutorials are largely outdated #86
Comments
I think maybe it would help to 1) add separate environments for different tutorials (so people can reproduce it even though it is based on an older version of some package) and 2) use CI tests and builds for the tutorials. |
100%. But for (2), we likely have to move away from Jupyter notebooks, right? Which, honestly, would be it's own benefit. |
And regarding (1), I would say that ideally we'll always have the tutorials work with the most recent release of Turing, since people will look to this for inspiration when writing their own code. Maybe we should run |
That's how it is done in SciML: https://github.com/SciML/SciMLTutorials.jl An appendix is added automatically to every tutorial which shows the packages and Julia version that was used to run it |
Nice 👍 And they use |
Yes. And then notebook, HTML, and PDF files are generated with Weave. |
Super-dope. Would it be a good idea to just try and duplicate their approach? |
Yes, I think that would be great. In particular also thinking about https://github.com/SciML/RebuildAction which we use over at SciML to rebuild tutorials automatically (together with CompatHelper for individual environments this helps to figure out any possible issues). |
Yeah I just noticed that; awesome stuff! Cool, well I'm very down for doing that. |
All of this is a great idea. I hate the way the tutorials currently work -- they're difficult to write in, difficult to automate, and often out-of-date. Switching to a more general |
Super cool idea. |
I've now updated all the tutorials to work with the new system (which is in a separate branch Do have a look:) We also need an updated script to publish the tutorials. One approach could be to just generate the markdown from the |
Yes, I think that's what we should do (at least initially). IMO we should not update too many things in one step 🙂 |
@cpfiffer I might have some questions for you about the documentation setup later, because right now I'm trying to run it locally but using a different branch of TuringTutorials, and I swear I'm loosing hair as I type. It for some reason refuses to render the the pages, despite the markdown files being available in julia --project -e "using Pkg; Pkg.instantiate(); using TuringTutorials; TuringTutorials.weave_folder(\"introduction\", (:github, ))" while in the project folder. |
Do the rendered markdown files have YAML headers? Because otherwise they won't render. The old tutorials code would handle this automatically: |
Aaah, that might be it |
Btw, a small update: I can get the tutorials to render but the formatting is completely broken. Honestly don't understand why, as the output is standard markdown. |
Do you have a reproducible example? |
Well, it's quite annoying to replicate but here it is:
|
Should it be |
Nah, EDIT: I think you should use |
I finally managed to obtain a local preview of the docs, and formatting seems to be fine? It took me a while to figure out that the new setup (or maybe just my weird way of changing |
Regular code output works fine though. |
Really? On my end it looks super-strange. Hmm, well, that's good news! Yeah, I think we have to change where the figures are outputed. |
Btw, I realized I had a mistake in the step-by-step guide above. You also need to make sure that the files are "lifted" to the top-level in function copy_tutorial(tutorial_path)
isdir(tutorial_path) || mkpath(tutorial_path)
# Clone TuringTurorials
tmp_path = tempname()
mkdir(tmp_path)
# clone("https://github.com/TuringLang/TuringTutorials", tmp_path)
# Move to markdown folder.
md_path = joinpath("/home/tor/.julia/dev/TuringTutorials/", "markdown")
# Copy the .md versions of all examples.
try
@debug(md_path)
# recursively find files and copy to top-level in `tutorial_path`
for (curr_dir, dirs, files) in walkdir(md_path)
for file in files
full_path = joinpath(md_path, curr_dir, file)
target_path = joinpath(tutorial_path, file)
println("Copying $full_path to $target_path")
cp(full_path, target_path, force=true)
if endswith(target_path, ".md")
# remove_yaml(target_path, "permalink")
fix_header_1(target_path)
fix_image_path(target_path)
end
end
end
index = joinpath(@__DIR__, "src/tutorials/index.md")
cp(index, tutorial_path * "/index.md", force=true)
catch e
rethrow(e)
finally
rm(tmp_path, recursive=true)
end
end But now it works nicely for me to! A couple of issues:
|
"Fixed" (2) and (3) locally, but (1) I can't seem to be able to fix. Even tried using what's supposed to be GFM markdown parsers in Jekyll, but none of them actually handle |
To bounce back on this, we could add a little warning at the beginning of each tutorial saying "Check that you are using the correct version of Turing for this tutorial (see end of Tutorial), if it does not work with the latest version of Turing please open an issue" |
Sorry, I haven't been looking at this for ages now. It first got postponed because the computer I had access to here back in Norway had very limited RAM, and so it was a hassle to do any development on this. I wanted to wait until I got back to Cambridge where I don't have this issue but the pandemic had other ideas. Got an upgrade recently though, so I'll have a look again 👍
If I remember correctly, the following issues remain:
But I figured out a fix to (1) this morning, so now I'll address (2) and try to generate everything; hopefully I'll have a working PR today! |
By the way, why don't we use Literate.jl instead of Weave.jl, Literate handles plots nicely I think. |
Hey @theogf! Yeah you, you who are now suggesting that we use Literate.jl instead of Weave.jl after I've gone through hell to get this stuff working. Shut your face. |
Hahaha can't argue with that! 😆😆😆 (although it would be easier to switch now 👀 ) |
No but on a serious note, Weave.jl handles plots nicely too. But Weave.jl respects the MIME-type, and that is messed up for gifs for some reason, and so Weave.jl treats it as text rather than a file. I would argue this is not to be completely blamed on Weave.jl. And more generally, I think both Weave.jl and Literate.jl are very much the same when it comes to features but Weave.jl is more mature, is under JunoLabs and thus we'd expect it to me maintained, and finally, and this is the main reason why we went with Weave.jl in the first place, jmd is a super-straightforward conversion from our current setup since we can just take the markdown files and convert to jmd while Literate.jl is a completely different approach AFAIK. |
So right now I think the PRs #102 and #103 should be good to get things working. The next step is to make sure that everything renders correctly on the website (@cpfiffer pls halp). I have a working branch of Turing that manages to do this locally, but need to ensure that this is also the case for the actual website. After all that, I think we should really just go through the tutorials to:
|
Oh ok so the idea is to work on |
Exactly 👍 |
I wouldn't worry too much about correct rendering at the outset, we can fix it as we go along. |
Plus the changes need to happen elsewhere. |
So the only thing that remains now is making sure that all tutorials actually work. There are some that are just failing, e.g. regression tutorial fails because of JuliaStats/RDatasets.jl#117. I'll go through, fix the ones I can and list the ones that are still todo, then I'll make another PR. |
I will make a new PR for the BNN tutorial (I will try to include GPU support for vi this time) |
Another issue I'm currently running into is that the footer thingy we have at the end of the tutorials suddenly stopped working. When I do: julia --project -e "using TuringTutorials; TuringTutorials.weave_folder(\"00-introduction\", (:github, ))" it complains that |
So seems like it actually does: https://github.com/JunoLab/Weave.jl/blob/196d4ca7ce80e65f7365642218c43a8c94d5f286/src/run.jl#L41-L42. But how about changing using TuringTutorials
TuringTutorials.tutorial_footer(WEAVE_ARGS[:folder],WEAVE_ARGS[:file]) to if isdefined(Main, :TuringTutorials)
Main.TuringTutorials.tutorial_footer(WEAVE_ARGS[:folder], WEAVE_ARGS[:file])
end ? This way one can still |
Yeah, I love it! |
Wow, I don't think I've ever seen anyone that enthusiastic about changing footers before! I guess it makes sense, eh Mr. Footman? |
Could you maybe have a check that everything is fine @cpfiffer ? Just checkout the |
Don't need to check every tutorial, but mainly that the setup makes sense |
Looks fine to me. We can test it live by pushing the |
Sounds good! |
Aight, so now it's ready to go! Need to merge #109 and then #111 for TuringTutorials, and then finally TuringLang/turinglang.github.io#7 over at |
Is there anything remaining for us to completely move over to jmd staging at this point? |
Yeah, that sounds about right. I'll try to fit in the time this week to get the turing.ml stuff ready to go. |
A lot of the tutorials are unfortunately outdated due to recent improvements in MCMCChains, e.g. TuringLang/Turing.jl#1411.
I'm opening an issue here so as to bring attention to the, well, issue.
The text was updated successfully, but these errors were encountered: