Hi, I am setting up ARTIQ 5 using nix. I have been following the manual step by step and have been fine. I am now trying to run the led.py program but when I do artiq_run I get the error message.
`[nix-shell:/artiq]$ artiq_run led.py
Traceback (most recent call last):
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/master/worker_db.py", line 78, in get
desc = self.get_desc(name)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/master/worker_db.py", line 69, in get_desc
return self.ddb.get(name, resolve_alias=True)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/master/databases.py", line 29, in get
desc = self.data.raw_view[key]
KeyError: 'led'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/nix/store/5ydzc5dpa5if9ds671fhr4vk0d695cbk-python3.7-artiq-5.7101.8ca1fea1/bin/.artiq_run-wrapped", line 11, in <module>
sys.exit(main())
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/frontend/artiq_run.py", line 225, in main
return run(with_file=True)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/frontend/artiq_run.py", line 211, in run
raise exn
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/frontend/artiq_run.py", line 202, in run
exp_inst = _build_experiment(device_mgr, dataset_mgr, args)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/frontend/artiq_run.py", line 188, in _build_experiment
return get_experiment(module, args.class_name)(managers)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/language/environment.py", line 220, in init
self.build(*args, **kwargs)
File "led.py", line 7, in build
self.setattr_device("led")
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/language/environment.py", line 304, in setattr_device
setattr(self, key, self.get_device(key))
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/language/environment.py", line 297, in get_device
return self.__device_mgr.get(key)
File "/nix/store/7d5jllypjvlw43bd6hrhlwbv7lfiy7fh-python3-3.7.5-env/lib/python3.7/site-packages/artiq/master/worker_db.py", line 81, in get
.format(name)) from e
artiq.master.worker_db.DeviceError: Failed to get description of device 'led'
Here is my device_db.py filecore_addr = "192.168.1.146"

device_db = {
"core": {
"type": "local",
"module": "artiq.coredevice.core",
"class": "Core",
"arguments": {"host": core_addr, "ref_period": 1e-9}
},
"core_log": {
"type": "controller",
"host": "::1",
"port": 1068,
"command": "aqctl_corelog -p {port} --bind {bind} " + core_addr
},
"core_cache": {
"type": "local",
"module": "artiq.coredevice.cache",
"class": "CoreCache"
},
"core_dma": {
"type": "local",
"module": "artiq.coredevice.dma",
"class": "CoreDMA"
},

"i2c_switch0": {
    "type": "local",
    "module": "artiq.coredevice.i2c",
    "class": "PCA9548",
    "arguments": {"address": 0xe0}
},
"i2c_switch1": {
    "type": "local",
    "module": "artiq.coredevice.i2c",
    "class": "PCA9548",
    "arguments": {"address": 0xe2}
},

}

device_db.update({
"ttl" + str(i): {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut" if i < 4 else "TTLOut",
"arguments": {"channel": i},
} for i in range(24)
})

device_db.update({
"spi_sampler0_adc": {
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 24}
},
"spi_sampler0_pgia": {
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 25}
},
"spi_sampler0_cnv": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 26},
},
"sampler0": {
"type": "local",
"module": "artiq.coredevice.sampler",
"class": "Sampler",
"arguments": {
"spi_adc_device": "spi_sampler0_adc",
"spi_pgia_device": "spi_sampler0_pgia",
"cnv_device": "spi_sampler0_cnv"
}
}
})

device_db.update({
"spi_urukul0": {
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 27}
},
"ttl_urukul0_sync": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLClockGen",
"arguments": {"channel": 28, "acc_width": 4}
},
"ttl_urukul0_io_update": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 29}
},
"ttl_urukul0_sw0": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 30}
},
"ttl_urukul0_sw1": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 31}
},
"ttl_urukul0_sw2": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 32}
},
"ttl_urukul0_sw3": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 33}
},
"urukul0_cpld": {
"type": "local",
"module": "artiq.coredevice.urukul",
"class": "CPLD",
"arguments": {
"spi_device": "spi_urukul0",
"io_update_device": "ttl_urukul0_io_update",
"sync_device": "ttl_urukul1_sync",
"refclk": 125e6,
"clk_sel": 2
}
}
})

device_db.update({
"urukul0_ch" + str(i): {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 4 + i,
"cpld_device": "urukul0_cpld",
"sw_device": "ttl_urukul0_sw" + str(i)
}
} for i in range(4)
})

device_db.update({
"spi_urukul1": {
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 34}
},
"ttl_urukul1_sync": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLClockGen",
"arguments": {"channel": 35, "acc_width": 4}
},
"ttl_urukul1_io_update": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 36}
},
"ttl_urukul1_sw0": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 37}
},
"ttl_urukul1_sw1": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 38}
},
"ttl_urukul1_sw2": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 39}
},
"ttl_urukul1_sw3": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 40}
},
"urukul1_cpld": {
"type": "local",
"module": "artiq.coredevice.urukul",
"class": "CPLD",
"arguments": {
"spi_device": "spi_urukul1",
"io_update_device": "ttl_urukul1_io_update",
"refclk": 125e6,
"sync_device": "ttl_urukul1_sync",
"clk_sel": 2
}
}
})

device_db.update({
"urukul1_ch" + str(i): {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 4 + i,
"cpld_device": "urukul1_cpld",
"sw_device": "ttl_urukul1_sw" + str(i)
}
} for i in range(4)
})

device_db.update({
"spi_zotino0": {
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 41}
},
"ttl_zotino0_ldac": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 42}
},
"ttl_zotino0_clr": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 43}
},
"zotino0": {
"type": "local",
"module": "artiq.coredevice.zotino",
"class": "Zotino",
"arguments": {
"spi_device": "spi_zotino0",
"ldac_device": "ttl_zotino0_ldac",
"clr_device": "ttl_zotino0_clr"
}
}
})

device_db.update({
"led0": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 44}
},
"led1": {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 45}
}
}
)
`

9 days later

Sorry I will make sure it is formatted properly next time. I get the same exact error with led0 instead of led when I just the name from led to led0.

You can also edit your posts to fix the formatting after the fact.
What's your full experiment code (led.py)?

a year later

Hello,
I'm having the exact same problem here.
Could you tell me what to do if "led0" doesn't fix the problem.

Here is my "led.py" program.

from artiq.experiment import *

class LED(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("led0")

@kernel
def run(self):
    self.core.reset()
    self.led.on()

Is this Kasli 2.0? Use a TTL instead.