Any recommended ways to update the executor of a pre-defined or imported Electron
object?
#1646
Replies: 1 comment 6 replies
-
hey @arosen93 , this is a long backlogged item on our plate. Ideally the best UX is to have something like UX1from my_package import energy_electron # imports a direct electron object
energy_electron.executor=MyExecutor() Could @kessler-frost confirm if using Meanwhile I am just curious if using a UX2 would be a good fit for creating custom electron packages. UX2from my_package import energy_electron
small_cell=energy_electron(**parameters,executor=MyExecutor(num_cpu=2)) # Returns an electron function
super_cell=energy_electron(**parameters,executor=MyExecutor(num_cpu=45)) # Returns an electron function
@ct.lattice
def workflow():
energy_supercell=super_cell("NaCl") #different resource electron
energy_smallcell=small_cell("NaCl") #different resource electron In certain scenarios, UX2 may be more suitable as it allows for the creation of multiple electron instances with unique parameters through a factory pattern. This is not achievable in UX1, which is designed to return a singleton electron instance with a specific tied instance. Infact our initial interest in UX1 was coming in from a perspective of changing executor inside an interactive notebook after electrons have been defined. LMK your thoughts. |
Beta Was this translation helpful? Give feedback.
-
Is there a convenience function in Covalent to update the executor of a pre-defined Electron? If there's not, would it be worth it to make one?
I know that, for an electron named
myelectron
, you can do something likemyelectron.electron_object.metadata["executor"] = "local"
, but I wasn't sure if that sets all the necessary variables (and if it's recommended).The reason I'm asking is that I'm developing a library of pre-defined workflows that users will import into their own codes. I'd like to ensure that if a user imports an
Electron
object from my package, they can set the executor to whatever they like. The alternative is for me to define functions and have the user wrap each function in act.electron()
"manually" so they can set the executor when they define theElectron
, but that's slightly less preferred for my use case.This is somewhat related to #1586 and #1587, but I've modified the scope of my question a bit.
Beta Was this translation helpful? Give feedback.
All reactions