Dynamic reloading of Objects using Revise or Cassette?

Hello all,

I need help to find a strategy to speed up my development process. I have written a framework in Julia, which I use for writing conversational agents.

Whenever I am working on the framework code, everything is painless and automatic, thanks to Revise (execpt the ocassional struct redefinition).

However, when I am working on client-code, I have to reload everything, which can be very expensive (an agent potentially includes a lot of modules, read some TOML files and transform this into objects). I will try to put an abstract example:

agent_x = AgentXModule.agent
agent_y = AgentXModule.agent
agent_z = AgentXModule.agent

agent_selector = Framework.AgentSelector(
 agentX = agent_x,
 agentY = agent_Y,
 agentZ = agent_Z,
)

And then:

answer(agent_selector, input) 

Each agent has a structure similar to this:

/agent_x
  /scenarios/
   |_ scenario_1.toml
  /modules/
   |_ scenario_1.jl

And is defined in a module like this:

module AgentX
using Framework
include("agents/x/modules/scenario_1.jl")

agent = Framework.AgentXExpensiveInstantiation(...)

end

What I would like to do is to observer those modules and scenarios folder so when one changes, the corresponding Agent is partially updated as wells as AgentSelector with the new Agent version.

Is this feasible with Revise.jl or Cassette.jl? Does someone have any experience with a similar problem or can provide any guidance?

Thanks in advance.

1 Like

IIUC Revise.entr could help you there (see also the paragraph about “Other Revise workflows” in the documentation).

So you’d have something like

entr(["agent_x/scenarios/scenario_1.toml"], # Watch for changes in scenarios
     [AgentX]) do                           # or in the code defining package AgentX (including scenario_1.jl)
    AgentX.update()           # Put in this function anything that AgentX needs to do
    Framework.update(:AgentX) # maybe the Framework needs some updating too...
end
2 Likes

Hey, @ffevotte, thank you for your answer and sorry for the late reply, how rude of me. Some other things took priority at work and I completely forgot about this.

I had taken a look to Revise.entr, but hand’t found a workable solution. I think what you propose could be already an improvement. However, ideally Revise.entr would be able to detect which specific file changed (I would watch not only an scenario but probably a dozen or two) and make more granular uupdates. I don’t know if this is possible, though.

I will be working on this today and see if I find something that works. Thank you for your help!

Actually, it seems like the Revise.entr approach doesn’t work for me (because I would need to include modules inside the loop to make the update, and that doesn’t seem to work).

Fortunately, I found a performance bottleneck that was causing very slow instantiation and that I can ignore while in development. Time went down like 90+%.