From 3044a053e1880282711a6f4017cae8139eaf2f7c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 24 Oct 2015 10:15:20 +0800 Subject: [PATCH] databases: assume empty dataset_db if file not present. Closes #156 --- .gitignore | 2 ++ artiq/master/databases.py | 5 ++++- doc/manual/getting_started_core.rst | 2 +- doc/manual/getting_started_mgmt.rst | 2 +- examples/master/dataset_db.pyon | 1 - examples/sim/dataset_db.pyon | 1 - 6 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 examples/master/dataset_db.pyon delete mode 100644 examples/sim/dataset_db.pyon diff --git a/.gitignore b/.gitignore index ce877f17f..50894b653 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ doc/manual/_build /.coverage artiq/test/results examples/master/results +examples/master/dataset_db.pyon +examples/sim/dataset_db.pyon diff --git a/artiq/master/databases.py b/artiq/master/databases.py index 40549683c..5e2c7d004 100644 --- a/artiq/master/databases.py +++ b/artiq/master/databases.py @@ -32,7 +32,10 @@ class DatasetDB(TaskObject): self.persist_file = persist_file self.autosave_period = autosave_period - file_data = pyon.load_file(self.persist_file) + try: + file_data = pyon.load_file(self.persist_file) + except FileNotFoundError: + file_data = dict() self.data = Notifier({k: (True, v) for k, v in file_data.items()}) def save(self): diff --git a/doc/manual/getting_started_core.rst b/doc/manual/getting_started_core.rst index a9e78518c..1f42d152d 100644 --- a/doc/manual/getting_started_core.rst +++ b/doc/manual/getting_started_core.rst @@ -22,7 +22,7 @@ As a very first step, we will turn on a LED on the core device. Create a file `` The central part of our code is our ``LED`` class, that derives from :class:`artiq.language.environment.EnvExperiment`. Among other features, ``EnvExperiment`` calls our ``build`` method and provides the ``setattr_device`` method that interfaces to the device database to create the appropriate device drivers and make those drivers accessible as ``self.core`` and ``self.led``. The ``@kernel`` decorator tells the system that the ``run`` method must be executed on the core device (instead of the host). The decorator uses ``self.core`` internally, which is why we request the core device using ``setattr_device`` like any other. -Copy the files ``device_db.pyon`` and ``dataset_db.pyon`` (containing the device and dataset databases) from the ``examples/master`` folder of ARTIQ into the same directory as ``led.py`` (alternatively, you can use the ``--device-db`` and ``--dataset-db`` options of ``artiq_run``). You can open the database files using a text editor - their contents are in a human-readable format. You will probably want to set the IP address of the core device in ``device_db.pyon`` so that the computer can connect to it (it is the ``host`` parameter of the ``comm`` entry). See :ref:`device-db` for more information. The example device database is designed for the NIST QC1 hardware on the KC705; see :ref:`board-ports` for RTIO channel assignments if you need to adapt the device database to a different hardware platform. +Copy the file ``device_db.pyon`` (containing the device database) from the ``examples/master`` folder of ARTIQ into the same directory as ``led.py`` (alternatively, you can use the ``--device-db`` option of ``artiq_run``). You can open PYON database files using a text editor - their contents are in a human-readable format. You will probably want to set the IP address of the core device in ``device_db.pyon`` so that the computer can connect to it (it is the ``host`` parameter of the ``comm`` entry). See :ref:`device-db` for more information. The example device database is designed for the NIST QC1 hardware on the KC705; see :ref:`board-ports` for RTIO channel assignments if you need to adapt the device database to a different hardware platform. .. note:: If the ``led`` device is a bidirectional TTL (i.e. ``TTLInOut`` instead of ``TTLOut``), you need to put it in output (driving) mode. Add the following at the beginning of ``run``: :: diff --git a/doc/manual/getting_started_mgmt.rst b/doc/manual/getting_started_mgmt.rst index 9ddf82f1f..c030ad69f 100644 --- a/doc/manual/getting_started_mgmt.rst +++ b/doc/manual/getting_started_mgmt.rst @@ -10,7 +10,7 @@ Starting your first experiment with the master In the previous tutorial, we used the ``artiq_run`` utility to execute our experiments, which is a simple stand-alone tool that bypasses the ARTIQ management system. We will now see how to run an experiment using the master (the central program in the management system that schedules and executes experiments) and the GUI client (that connects to the master and controls it). -First, create a folder ``~/artiq-master`` and copy the ``device_db.pyon`` and ``dataset_db.pyon`` (containing the device and dataset databases) found in the ``examples/master`` directory from the ARTIQ sources. The master uses those files in the same way as ``artiq_run``. +First, create a folder ``~/artiq-master`` and copy the file ``device_db.pyon`` (containing the device database) found in the ``examples/master`` directory from the ARTIQ sources. The master uses those files in the same way as ``artiq_run``. Then create a ``~/artiq-master/repository`` sub-folder to contain experiments. The master scans this ``repository`` folder to determine what experiments are available (the name of the folder can be changed using ``-r``). diff --git a/examples/master/dataset_db.pyon b/examples/master/dataset_db.pyon deleted file mode 100644 index ccee85030..000000000 --- a/examples/master/dataset_db.pyon +++ /dev/null @@ -1 +0,0 @@ -{"flopping_freq": 1499.9977914479744} diff --git a/examples/sim/dataset_db.pyon b/examples/sim/dataset_db.pyon deleted file mode 100644 index 0967ef424..000000000 --- a/examples/sim/dataset_db.pyon +++ /dev/null @@ -1 +0,0 @@ -{}