I have a package I am working on and currently my workflow is a bit of a hassle. I want to develop my package a bit more interactively, but currently my workflow is:
Do changes
Commit changes to Github and push
Remove previous install of package
Reinstall package
Run and test code
Which is quite of a hassle and does not feel to interactive. I am sure I have missed something basic, would anyone kindly give me a step in the right direction?
Install packages for general use in global namespace, such as Revise, BenchmarkTools etc.
In your run script (NOT module!) put using Revise
Restart Julia
Now, if you are in the project folder and have activated environment, by ] activate . or similar, then when you do changes in a submodule of your using MyPackage, these are propagated through the using Revise and you do not have to restart Julia terminal.
You need to make sure the project name matches using MyPackage I think, not sure.
Now I don’t have to do that really annoying workflow above
Note that there is a Revise.includet that allows you to reload a file when it changes. The final t is not a typo. This is usually useful when you are trying to develop code outside of the context of a package. Otherwise, it seems like you mostly figured it out.
It is because I am working on my package and in the test script I do; using MyPackage - then now because I have using Revise at the top of the test script, when I do changes inside of MyPackage in the local code it propagates correctly and I do not need to restart Julia.
Wish I had understood earlier that Revise also works with packages, hopefully it helps someone in the future
This will work, but personally I don’t like the idea of putting using Revise in your run script (ideally your run script should only be using packages that are in its Project.toml). I would recommend doing one of the following:
Simply write using Revise in the REPL before the first time that you include your run script in every new Julia session
Add the line using Revise to your ~/.julia/config/startup.jl file
Do like me, add the following line to your ~/.bashrc or similar:
alias j='julia -i -e "using Revise"'
which will start Julia with Revise preloaded when you use the command j on the command line. If you use Windows, then I think that you would need to write a .bat script to achieve something like this.
Finally, I just want to make sure that you are aware of Julias built in Unit test framework which would normally be a good supplement or replacement for your run script.
I might have to look into this, since my workflow seems to have broken again…
The unit test framework looks great for testing out smaller components of functionality, thanks! Currently I am just developing and it is nice to do so through a script for me.