-
Notifications
You must be signed in to change notification settings - Fork 36
Run examples with separate processes #314
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments. Would be helpful for others to review as well, as they've spent more time looking at this than I.
examples/svm/script.jl
Outdated
|
||
# Optimal prediction: | ||
function f(x, X, k, λ) | ||
return kernelmatrix(k, x, X) / (kernelmatrix(k, X) + exp(λ) * I) * y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this not just kernel ridge regression, rather than support vector regression? Possibly I'm forgetting something basic here, because I've not looked at SVM stuff for many years...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha yes I had the exact same comment on Slack 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha yeah I just copied and fixed the existing example to show that the setup works without thinking about the content at all 😄 Maybe we should just remove the example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why we we switched from SVM to kernel ridge regression on the other PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Therefore my suggestion would be to just completely remove the SVM example (and also not to keep the current version). The current version showed that the setup works and other examples can then be updated in separate PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♀️ happy to delete it as well and only put it back once we've done it properly. I would just not get too hung up on the contents of the example notebooks, let's get the doc build in order, and then we can rescue the actual content from #234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the updated version back to examples/svm.jl
since it is still an improvement even though it's not actually SVM 😄
- name: "Run CompatHelper" | ||
run: | | ||
import CompatHelper | ||
subdirs = ["", "test", "docs"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the empty ""
do here? If it's referring to the repo base directory, why would it need to be passed to _sub_dirs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise the base directory is not updated anymore. The default setting is subdirs = [""]
: https://juliaregistries.github.io/CompatHelper.jl/dev/options/#Packages-in-subdirectories
run: | | ||
import Pkg | ||
name = "CompatHelper" | ||
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to change to pinning CompatHelper? is there any reason not to want the latest version (with potential bugfixes etc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UUID is just an additional guarantee that it is the correct package but does not fix the version. The version is only pinned to 2.x.x but no specific version, i.e., it has to be updated only if there is a breaking release of CompatHelper.
In general, this is just copied from the documentation of CompatHelper: https://juliaregistries.github.io/CompatHelper.jl/dev/
docs/make.jl
Outdated
|
||
# Check that all examples were run successfully | ||
if !all(success, processes) | ||
error("some examples were not run successfully") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be any way of indicating which script failed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I redirected stderr of the processes to the default stderr, and hence errors of the individual processes are printed in the terminal regardless of success
. The check here mainly ensures that all processes are done and that the script errors if a process failed.
map(filter!(filename -> endswith(filename, ".md"), readdir(EXAMPLES_OUT))) do x | ||
return joinpath("examples", x) | ||
end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice:) much easier to read than the other version
|
||
# Activate environment | ||
using Pkg: Pkg | ||
Pkg.activate(dirname(SCRIPTJL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring the examples scripts to include Literate in their dependencies when they don't actually use it seems weird; maybe that's the best we can do (and of course we can then clarify that in the examples/README.md), but why not add them here as well:
Pkg.activate(dirname(SCRIPTJL)) | |
Pkg.activate(dirname(SCRIPTJL)) | |
Pkg.add("Literate") |
this should add it to the correct Project.toml (e.g. when I write a new examples script and locally run make.jl), but be a no-op if it's already there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this as well and I am still not sure what's the best approach. The advantage of adding them to the Project.toml + Manifest.toml is that it is correctly tracked and updated by CompatHelper and that it is guaranteed that the installation of Literate does not downgrade any other packages or mess with the package setup which would impact reproducibility if it is not part of Project.toml + Manifest.toml (otherwise it might only be installed when the CI tests are run).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
Pkg.activate(dirname(SCRIPTJL)) | |
Pkg.activate(dirname(SCRIPTJL)) | |
Pkg.add("Literate"; preserve=PRESERVE_ALL) |
or similar (Pkg.add docs) not satisfy that?
Co-authored-by: st-- <st--@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me now.
Perhaps renaming the svm file to kernel_ridge_regression.jl
or something would make sense while we're here though 🤷
edit: sorry, just understood what you're saying about the other example of ridge regression. Perhaps just replace that with this one? As you say, it's much cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me; I would still move the Literate dependency from examples scripts themselves into the literate.jl script, but happy to propose that change in #303 after rebasing and continuing the discussion there:)
Following #314, this PR adds READMEs for how to build & add to the docs and examples, as well as tidying the workflow up a bit more. It makes all current examples run (with a warning to say they're under construction).
This is an (arguably) simpler alternative to #309 and (partially) #303.
Examples are run asynchronously with different processes and no load path trickery is needed. CompatHelper is updated such that example environment are updated as well. I also updated and fixed the SVM example to demonstrate that the pipeline works as expected (the other examples are not blacklisted but since they are not moved to a separate folder they are not run currently).
Edit: I did not base this PR on #303 intentionally since in this way there are no changes hidden in the other PR and no major unrelated rewriting is needed. The PR is self-contained and as minimal as possible. I assumed that the other examples would be fixed in separate PRs, e.g., by rebasing #303.