Skip to content

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

Merged
merged 12 commits into from
Jun 29, 2021
Merged

Run examples with separate processes #314

merged 12 commits into from
Jun 29, 2021

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Jun 28, 2021

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.

@devmotion
Copy link
Member Author

@devmotion devmotion requested review from theogf, willtebbutt and st-- June 28, 2021 16:18
Copy link
Member

@willtebbutt willtebbutt left a 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.


# Optimal prediction:
function f(x, X, k, λ)
return kernelmatrix(k, x, X) / (kernelmatrix(k, X) + exp(λ) * I) * y
Copy link
Member

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...

Copy link
Member

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 😅

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This "SVM" example is also part of #303 (which is less optimized/updated than the version here). There exists another kernel ridge regression and a deep kernel learning example that are also updated in #303.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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"]
Copy link
Member

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?

Copy link
Member Author

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"
Copy link
Member

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)?

Copy link
Member Author

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")
Copy link
Member

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 ?

Copy link
Member Author

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.

Comment on lines +65 to +67
map(filter!(filename -> endswith(filename, ".md"), readdir(EXAMPLES_OUT))) do x
return joinpath("examples", x)
end,
Copy link
Member

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))
Copy link
Member

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:

Suggested change
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.

Copy link
Member Author

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).

Copy link
Member

Choose a reason for hiding this comment

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

Would

Suggested change
Pkg.activate(dirname(SCRIPTJL))
Pkg.activate(dirname(SCRIPTJL))
Pkg.add("Literate"; preserve=PRESERVE_ALL)

or similar (Pkg.add docs) not satisfy that?

@devmotion devmotion requested review from st-- and willtebbutt June 29, 2021 08:46
Copy link
Member

@willtebbutt willtebbutt left a 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.

Copy link
Member

@st-- st-- left a 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:)

@st-- st-- merged commit 69ea829 into master Jun 29, 2021
@st-- st-- deleted the dw/examples branch June 29, 2021 09:42
@st-- st-- mentioned this pull request Jun 30, 2021
st-- added a commit that referenced this pull request Jun 30, 2021
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).
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.

4 participants