[ANN] ReferenceRevision

Summary

ReferenceRevision is a Julia package which can automatically check out a copy of your code at a different revision and run it in a subprocess with seamless sharing of variables.

Rationale

Assume you are developing a package and find that the results are no longer looking right. In order to debug this you may need to compare the results, somewhere in the middle of your code, to your latest commit. Now you could stash your changes and start a second Julia running that code, but to compare the results you may need to save those to disk and read them back in the other Julia. Or possibly, with the help of Revise, you could actually stash your changes and run the latest commit in the same session. However, both of these approaches become fiddly if you need to switch back and forth between the code revisions or repeatedly transferring data during your debugging.

With ReferenceRevision you can instead do

using ReferenceRevision
head = open_process(rev = "HEAD")

to automatically extract the head revision in a temporary directory, start a new Julia in a subprocess, and use head as the Main module in the subprocess.
Variables are automatically transferred back and forth to the subprocess. This allows you to easily run the code revisions in parallel and compare results.

Additional Use Cases

  • ReferenceRevision provides a convenient way to set up regression tests against an older revision of the code.
  • ReferenceRevision can also start the subprocess with an arbitrary code environment, which allows you to run code with dependencies that are in conflict with your original environment.

Documentation

How Does it Work?

ReferenceRevision uses git archive to extract the requested version, run to start a new process, pipes for interprocess communication, and the Serialization standard library to serialize and deserialize data,

Limitations

The use of Serialization limits the subprocess to run the same Julia version as the main process. It also imposes some limitations on what data can be transferred. If the two revisions have different definitions of a struct, communication of such data might not work, although a struct created in the subprocess can be handled as an opaque object in the main process and be sent back to the subprocess.

6 Likes

Oh how often have I wished for this! Thank you @GunnarFarneback !