Critique my workflow for small models in Julia

In the process of iterating through lots of toy economic models and writing small scripts to analyze them (make plots, etc.).

I’ve gotten into the following workflow, and I’m wondering if (a) it’s reasonable (b) Other people share it and (c) if other people have formalized it into a package.

The workflow attempts to balance the ease of running a script at the REPL with

  1. use ] generate MyModel because ultimately I will want things in a package
  2. ] add a bunch of packages
  3. Write my functions inside the MyModel module
  4. Write a main function inside MyModel
  5. In the REPL, run using Revise; using MyModel; exportall(MyModel). The last command sends all names to Main
  6. Make main look like this
function main()
@eval Main begin # everything available at the REPL
...
end
end
  1. Go to src/MyModel.jl and copy and paste all the using statements into the REPL so that everything is available at the REPL.
  2. Run main() at the REPL. Everything inside main is visible.
  3. Use @infiltrate extensively while debugging.

The reason for main with @eval is so that I can take things inside main and easily spit them out into helper functions that are also in the MyModel module.

This gives me the best balance of having a package and having stuff accessible at the REPL.

Anyone else do this? I use Sublime Text and a terminal, btw.

Honestly, I have been using Pluto to do all of my prototyping. I think it strikes an alright balance between interactivity and composition of features.

3 Likes

Aside from my preference for the terminal (I like window pop-ups, its snappier, consistency across languages), I feel like Pluto wouldn’t work since I want my code to basically be a package, with the exception of main, which is like a script.

1 Like

Since I started using the contextual module REPL feature I feel less need to export stuff to Main.

Thanks! Yeah that might be the solution here, to prevent the annoying copying and pasting the using statements into the REPL.