- Edited
Hi All,
I am trying to follow the inheritance discussion here
https://forum.m-labs.hk/d/291-how-to-elegantly-reuse-the-experiment-code/7 but it is a bit old and incomplete.
and here
https://forum.m-labs.hk/d/296-changing-parameters-of-the-experiment
but the discussions are a bit old.
Given a test class (basic task) inside of file (basic_func1.py)
`
from artiq.experiment import *
import numpy as np
class Basic_Task(EnvExperiment):
"""basic things"""
def build(self):
self.delay= 50*us
self.setattr_device("core")
self.setattr_device("sampler0")
self.setattr_argument("n_samples", NumberValue(precision=0,
step=1,scale=1))
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.sampler0.init()
`
I would like to have another file (basic_inherit.py) import this class and then do something
`
from artiq.experiment import *
import numpy as np
import basic_func1
class Inherit_Basic(EnvExperiment):
"""Inherit Tester"""
def build(self):
self.delay= 50*us #The sampling rate/ effective delay rate between commands
# self.integration = 15*ms
self.setattr_argument("integration", NumberValue(unit = "ms"
,step=1))
desired_samples = self.integration / self.delay
self.sample = basic_func1.Basic_Task(self)
self.setattr_device("core")
print(self.n_samples)
print(integration)
@kernel
def run(self):
l=1
`
A basic example would be I want to define an integration time and then let the sampler measure for that integration time with however many samples are appropriate for the sampling rate without having to think about it.
1.) desired_samples = self.integration/self.delay seems to break the basic_inherit.py compatibility with the dashboard. Why? What I mean is that the file will not appear in the repository when scanning the available files unless this is commented out. When I try to ask what type self.integration is it reports back "Class Float" but this is not reported here https://m-labs.hk/artiq/manual/compiler.html as a valid type.
2.) How to pass the desired_samples = self.integration/self.delay into the self.sample instance ? I can do self.sample.n_samples = desired_samples but this feels cobbled together. I can force this to work by adding a build(self,n_samples) to the Basic_Task and then commenting out the setattr but this breaks the base module functionality.
3.) Is there a file where experiment attributes get dumped as a log? I inspected the results files but don't see a parameters file anywhere and I would generally prefer to see this logged as metadata.
Best,
Travis