I'm trying to reuse some of the existing code in other experiments, which are simply the combination of the existing experiments in a row, possibly with extra channels to be added in parallel. The straightforward idea that comes to my mind is class inheritance. For example, I implement all the experiment sequences that may be used in an experient as a method in a base class Base
which is the child class of EnvExperiment
.
class Base(EnvExperiment):
def build(self):
...
def seq1(self):
...
def seq2(self):
...
def seq3(self):
...
...
Then once I need to implement a new experiment, I simply inherit it like
from artiq.experiment import *
from Base import Base
class SampleExperiment(Base):
def run(self):
self.seq1()
delay(1*ms)
self.seq3()
However, it seems that the management system of ARTIQ won't allow me to do so. If I run the experiment via artiq_run
, it returns ValueError: More than one experiment found in module
.
I wonder if there exists any simple way to realize the elegant reuse. I know I can combine sequences in a single class, but as more than one people in my lab need to write experiment code, it's not a good idea to modify the same class. It's obviously not elegant either to copy the code since the parameters in a single sequence may change and I won't be bothered to mind the detail when I just need to combine them.
Thanks in advance.