Stream: helpdesk (published)

Topic: Run code within different environments


view this post on Zulip Timothy (Mar 04 2023 at 11:46):

I've recently given DaemonMode a second look, and realised it's almost what I'd need it to be for use in my own workflows.

One major stumbling block for me, is that it does not support running code in different projects/environments. I'd think this would be akin to how when you do using <module> the module itself is loaded using its own environment. What I'm hoping, is that there's a way I could instantiate different environments and then run the (DaemonMode-constructed) anonymous modules in their appropriate environment.

E.g. something like this (in effect)

env = constructenvfromprojectpath("/path/to/project/folder")
m = anon_module_within(env)
Core.eval(m, :stuff) # executed within the project ^

Is this possible? The docs don't seem to be particularly informative when it comes to this sort of usage.

Ideally, I'd also like to be able to load different versions of the same package within different project environments.

view this post on Zulip Timothy (Mar 06 2023 at 08:07):

The answer I seem to be arriving at is "you can't"

view this post on Zulip c42f (Mar 06 2023 at 08:42):

Yes, you can't. In fact, there's basically no way to do this at all within a given julia process (DaemonMode or not): once you've loaded a library once, you can't load a different version of it. Because the package is identified by its UUID internally when it's loaded, and that UUID is fixed across versions.

(In principle, you could maybe subvert this mechanism in a very dirty way by fooling the system with a new set of UUIDs for each new environment. Which would mean writing a pile of environment management code yourself.)

view this post on Zulip Timothy (Mar 06 2023 at 08:46):

Mmm, since Saturday I've started up a new project that could end up being what I hoped DaemonMode was, with workers started up per environment. I'm currently got a few pieces of it working.


Last updated: Dec 28 2024 at 04:38 UTC