From fbe4d96572372836b7c7a47e2c8d99275ac54bf7 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 14:48:58 -0700 Subject: [PATCH 1/9] artiq: move namespace artiq.* -> artiq.language.* perl -i -pe 's/^from artiq import \*$/from artiq.language import */' your_experiments/*.py --- artiq/__init__.py | 10 ---------- artiq/language/__init__.py | 6 ++++-- artiq/test/coredevice/portability.py | 2 +- artiq/test/scheduler.py | 2 +- artiq/test/worker.py | 2 +- doc/manual/core_language_reference.rst | 2 +- doc/manual/getting_started_core.rst | 4 ++-- doc/manual/getting_started_mgmt.rst | 2 +- examples/master/repository/arguments_demo.py | 2 +- .../repository/coredevice_examples/photon_histogram.py | 2 +- .../coredevice_examples/simple/blink_forever.py | 2 +- .../repository/coredevice_examples/simple/dds_test.py | 2 +- .../repository/coredevice_examples/simple/handover.py | 2 +- .../coredevice_examples/simple/mandelbrot.py | 2 +- examples/master/repository/coredevice_examples/tdr.py | 2 +- .../master/repository/coredevice_examples/transport.py | 2 +- examples/master/repository/flopping_f_simulation.py | 2 +- examples/master/repository/run_forever.py | 2 +- examples/master/repository/speed_benchmark.py | 2 +- examples/master/repository/utilities/dds_setter.py | 2 +- examples/master/repository/utilities/terminate_all.py | 2 +- examples/sim/al_spectroscopy.py | 2 +- examples/sim/simple_simulation.py | 2 +- 23 files changed, 26 insertions(+), 34 deletions(-) diff --git a/artiq/__init__.py b/artiq/__init__.py index b7f5db75d..e44e9d156 100644 --- a/artiq/__init__.py +++ b/artiq/__init__.py @@ -1,13 +1,3 @@ -from artiq import language -from artiq.language import * -from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE, - PHASE_MODE_TRACKING) - -__all__ = [] -__all__.extend(language.__all__) -__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE", - "PHASE_MODE_TRACKING"] - from ._version import get_versions __version__ = get_versions()['version'] del get_versions diff --git a/artiq/language/__init__.py b/artiq/language/__init__.py index 763babfbd..e3d9df9e0 100644 --- a/artiq/language/__init__.py +++ b/artiq/language/__init__.py @@ -1,5 +1,3 @@ -# Copyright (C) 2014, 2015 Robert Jordens - from artiq.language import core, types, environment, units, scan from artiq.language.core import * from artiq.language.types import * @@ -7,6 +5,8 @@ from artiq.language.environment import * from artiq.language.units import * from artiq.language.scan import * +from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE, + PHASE_MODE_TRACKING) __all__ = [] __all__.extend(core.__all__) @@ -14,3 +14,5 @@ __all__.extend(types.__all__) __all__.extend(environment.__all__) __all__.extend(units.__all__) __all__.extend(scan.__all__) +__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE", + "PHASE_MODE_TRACKING"] diff --git a/artiq/test/coredevice/portability.py b/artiq/test/coredevice/portability.py index 546ef3d84..752ded674 100644 --- a/artiq/test/coredevice/portability.py +++ b/artiq/test/coredevice/portability.py @@ -1,7 +1,7 @@ from operator import itemgetter from fractions import Fraction -from artiq import * +from artiq.language import * from artiq.sim import devices as sim_devices from artiq.test.hardware_testbench import ExperimentCase diff --git a/artiq/test/scheduler.py b/artiq/test/scheduler.py index f6a029ee5..75522ad21 100644 --- a/artiq/test/scheduler.py +++ b/artiq/test/scheduler.py @@ -5,7 +5,7 @@ import sys import os from time import time, sleep -from artiq import * +from artiq.language import * from artiq.master.scheduler import Scheduler diff --git a/artiq/test/worker.py b/artiq/test/worker.py index bd69d03b8..8a02907c0 100644 --- a/artiq/test/worker.py +++ b/artiq/test/worker.py @@ -5,7 +5,7 @@ import sys import os from time import sleep -from artiq import * +from artiq.language import * from artiq.master.worker import * diff --git a/doc/manual/core_language_reference.rst b/doc/manual/core_language_reference.rst index b88b95ade..66fe50411 100644 --- a/doc/manual/core_language_reference.rst +++ b/doc/manual/core_language_reference.rst @@ -1,7 +1,7 @@ Core language reference ======================= -The most commonly used features from those modules can be imported with ``from artiq import *``. +The most commonly used features from those modules can be imported with ``from artiq.language import *``. :mod:`artiq.language.core` module --------------------------------- diff --git a/doc/manual/getting_started_core.rst b/doc/manual/getting_started_core.rst index 81a183c91..85e7d2e24 100644 --- a/doc/manual/getting_started_core.rst +++ b/doc/manual/getting_started_core.rst @@ -8,7 +8,7 @@ Connecting to the core device As a very first step, we will turn on a LED on the core device. Create a file ``led.py`` containing the following: :: - from artiq import * + from artiq.language import * class LED(EnvExperiment): @@ -93,7 +93,7 @@ The point of running code on the core device is the ability to meet demanding re Create a new file ``rtio.py`` containing the following: :: - from artiq import * + from artiq.language import * class Tutorial(EnvExperiment): diff --git a/doc/manual/getting_started_mgmt.rst b/doc/manual/getting_started_mgmt.rst index c030ad69f..41d5305bf 100644 --- a/doc/manual/getting_started_mgmt.rst +++ b/doc/manual/getting_started_mgmt.rst @@ -16,7 +16,7 @@ Then create a ``~/artiq-master/repository`` sub-folder to contain experiments. T Create a very simple experiment in ``~/artiq-master/repository`` and save it as ``mgmt_tutorial.py``: :: - from artiq import * + from artiq.language import * class MgmtTutorial(EnvExperiment): diff --git a/examples/master/repository/arguments_demo.py b/examples/master/repository/arguments_demo.py index 7b65e0bb9..8559383f8 100644 --- a/examples/master/repository/arguments_demo.py +++ b/examples/master/repository/arguments_demo.py @@ -1,6 +1,6 @@ import logging -from artiq import * +from artiq.language import * class SubComponent1(HasEnvironment): diff --git a/examples/master/repository/coredevice_examples/photon_histogram.py b/examples/master/repository/coredevice_examples/photon_histogram.py index 84e6f62c2..9cd574d9f 100644 --- a/examples/master/repository/coredevice_examples/photon_histogram.py +++ b/examples/master/repository/coredevice_examples/photon_histogram.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class PhotonHistogram(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/blink_forever.py b/examples/master/repository/coredevice_examples/simple/blink_forever.py index 9abd3968f..37ed06c03 100644 --- a/examples/master/repository/coredevice_examples/simple/blink_forever.py +++ b/examples/master/repository/coredevice_examples/simple/blink_forever.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class BlinkForever(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/dds_test.py b/examples/master/repository/coredevice_examples/simple/dds_test.py index cc2d4e6db..edcdf265c 100644 --- a/examples/master/repository/coredevice_examples/simple/dds_test.py +++ b/examples/master/repository/coredevice_examples/simple/dds_test.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class DDSTest(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/handover.py b/examples/master/repository/coredevice_examples/simple/handover.py index ef3512bf8..6b63e338d 100644 --- a/examples/master/repository/coredevice_examples/simple/handover.py +++ b/examples/master/repository/coredevice_examples/simple/handover.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class Handover(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/mandelbrot.py b/examples/master/repository/coredevice_examples/simple/mandelbrot.py index 1bd8dabf7..a599823e9 100644 --- a/examples/master/repository/coredevice_examples/simple/mandelbrot.py +++ b/examples/master/repository/coredevice_examples/simple/mandelbrot.py @@ -1,6 +1,6 @@ import sys -from artiq import * +from artiq.language import * class Mandelbrot(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/tdr.py b/examples/master/repository/coredevice_examples/tdr.py index a6ac2b127..41caa0624 100644 --- a/examples/master/repository/coredevice_examples/tdr.py +++ b/examples/master/repository/coredevice_examples/tdr.py @@ -1,6 +1,6 @@ # Copyright (C) 2014, 2015 Robert Jordens -from artiq import * +from artiq.language import * class PulseNotReceivedError(Exception): diff --git a/examples/master/repository/coredevice_examples/transport.py b/examples/master/repository/coredevice_examples/transport.py index 15f94666a..c0eca6e72 100644 --- a/examples/master/repository/coredevice_examples/transport.py +++ b/examples/master/repository/coredevice_examples/transport.py @@ -2,7 +2,7 @@ import numpy as np -from artiq import * +from artiq.language import * from artiq.wavesynth.coefficients import SplineSource diff --git a/examples/master/repository/flopping_f_simulation.py b/examples/master/repository/flopping_f_simulation.py index a2f0f04c9..14b30e203 100644 --- a/examples/master/repository/flopping_f_simulation.py +++ b/examples/master/repository/flopping_f_simulation.py @@ -5,7 +5,7 @@ import random import numpy as np from scipy.optimize import curve_fit -from artiq import * +from artiq.language import * def model(x, F0): diff --git a/examples/master/repository/run_forever.py b/examples/master/repository/run_forever.py index 73f6e2e20..adddfd21d 100644 --- a/examples/master/repository/run_forever.py +++ b/examples/master/repository/run_forever.py @@ -1,7 +1,7 @@ from itertools import count from time import sleep -from artiq import * +from artiq.language import * class RunForever(EnvExperiment): diff --git a/examples/master/repository/speed_benchmark.py b/examples/master/repository/speed_benchmark.py index e546ac854..4b5559700 100644 --- a/examples/master/repository/speed_benchmark.py +++ b/examples/master/repository/speed_benchmark.py @@ -1,6 +1,6 @@ import time -from artiq import * +from artiq.language import * class _PayloadNOP(EnvExperiment): diff --git a/examples/master/repository/utilities/dds_setter.py b/examples/master/repository/utilities/dds_setter.py index a50e242c0..8ba6f18cc 100644 --- a/examples/master/repository/utilities/dds_setter.py +++ b/examples/master/repository/utilities/dds_setter.py @@ -1,6 +1,6 @@ from operator import itemgetter -from artiq import * +from artiq.language import * class DDSSetter(EnvExperiment): diff --git a/examples/master/repository/utilities/terminate_all.py b/examples/master/repository/utilities/terminate_all.py index 9e1f38ff3..c61402fe9 100644 --- a/examples/master/repository/utilities/terminate_all.py +++ b/examples/master/repository/utilities/terminate_all.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class TerminateAll(EnvExperiment): diff --git a/examples/sim/al_spectroscopy.py b/examples/sim/al_spectroscopy.py index 944def945..97a55fb0b 100644 --- a/examples/sim/al_spectroscopy.py +++ b/examples/sim/al_spectroscopy.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class AluminumSpectroscopy(EnvExperiment): diff --git a/examples/sim/simple_simulation.py b/examples/sim/simple_simulation.py index 59c4875e4..5106e06b6 100644 --- a/examples/sim/simple_simulation.py +++ b/examples/sim/simple_simulation.py @@ -1,4 +1,4 @@ -from artiq import * +from artiq.language import * class SimpleSimulation(EnvExperiment): From 765001054dfd714d0a21d2d0033c0aa94e1a6f9e Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 15:49:08 -0700 Subject: [PATCH 2/9] artiq.experiment: merge language and coredevice namespaces perl -i -pe 's/^from artiq import \*$/from artiq.experiment import */' your_experiments/*.py (assuming you skipped the changes form the previous commit) --- artiq/coredevice/__init__.py | 10 ++++++++++ artiq/experiment.py | 7 +++++++ artiq/language/__init__.py | 5 ----- artiq/language/core.py | 5 ++--- artiq/test/coredevice/analyzer.py | 2 +- artiq/test/coredevice/cache.py | 3 +-- artiq/test/coredevice/embedding.py | 2 +- artiq/test/coredevice/portability.py | 2 +- artiq/test/coredevice/rtio.py | 4 +--- artiq/test/hardware_testbench.py | 2 +- artiq/test/scheduler.py | 2 +- artiq/test/worker.py | 2 +- doc/manual/core_language_reference.rst | 2 +- doc/manual/getting_started_core.rst | 4 ++-- doc/manual/getting_started_mgmt.rst | 2 +- 15 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 artiq/experiment.py diff --git a/artiq/coredevice/__init__.py b/artiq/coredevice/__init__.py index e69de29bb..7f0bf3d38 100644 --- a/artiq/coredevice/__init__.py +++ b/artiq/coredevice/__init__.py @@ -0,0 +1,10 @@ +from artiq.coredevice import exceptions, dds +from artiq.coredevice.exceptions import (RTIOUnderflow, RTIOSequenceError, + RTIOCollisionError) +from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE, + PHASE_MODE_TRACKING) + +__all__ = [] +__all__ += ["RTIOUnderflow", "RTIOSequenceError", "RTIOCollisionError"] +__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE", + "PHASE_MODE_TRACKING"] diff --git a/artiq/experiment.py b/artiq/experiment.py new file mode 100644 index 000000000..30138c6e3 --- /dev/null +++ b/artiq/experiment.py @@ -0,0 +1,7 @@ +from artiq import language, coredevice +from artiq.language import * +from artiq.coredevice import * + +__all__ = [] +__all__.extend(language.__all__) +__all__.extend(coredevice.__all__) diff --git a/artiq/language/__init__.py b/artiq/language/__init__.py index e3d9df9e0..e5433d3b0 100644 --- a/artiq/language/__init__.py +++ b/artiq/language/__init__.py @@ -5,14 +5,9 @@ from artiq.language.environment import * from artiq.language.units import * from artiq.language.scan import * -from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE, - PHASE_MODE_TRACKING) - __all__ = [] __all__.extend(core.__all__) __all__.extend(types.__all__) __all__.extend(environment.__all__) __all__.extend(units.__all__) __all__.extend(scan.__all__) -__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE", - "PHASE_MODE_TRACKING"] diff --git a/artiq/language/core.py b/artiq/language/core.py index a374562a9..10eb3dcef 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -6,9 +6,6 @@ import os, linecache, re from collections import namedtuple from functools import wraps -# for runtime files in backtraces -from artiq.coredevice.runtime import source_loader - __all__ = ["host_int", "int", "host_round", "round", "kernel", "portable", "syscall", "host_only", @@ -390,6 +387,8 @@ class ARTIQException: self.traceback = list(traceback) def __str__(self): + # lazy import this + from artiq.coredevice.runtime import source_loader lines = [] lines.append("Core Device Traceback (most recent call last):") for (filename, line, column, function, address) in self.traceback: diff --git a/artiq/test/coredevice/analyzer.py b/artiq/test/coredevice/analyzer.py index fc0650fbe..b607ecc36 100644 --- a/artiq/test/coredevice/analyzer.py +++ b/artiq/test/coredevice/analyzer.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * from artiq.coredevice.analyzer import decode_dump, OutputMessage, InputMessage from artiq.test.hardware_testbench import ExperimentCase diff --git a/artiq/test/coredevice/cache.py b/artiq/test/coredevice/cache.py index 68033b142..a81950e00 100644 --- a/artiq/test/coredevice/cache.py +++ b/artiq/test/coredevice/cache.py @@ -1,5 +1,4 @@ -from artiq.language import * -from artiq.coredevice.exceptions import * +from artiq.experiment import * from artiq.test.hardware_testbench import ExperimentCase diff --git a/artiq/test/coredevice/embedding.py b/artiq/test/coredevice/embedding.py index 190ec23b9..5debdb2cf 100644 --- a/artiq/test/coredevice/embedding.py +++ b/artiq/test/coredevice/embedding.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * from artiq.test.hardware_testbench import ExperimentCase diff --git a/artiq/test/coredevice/portability.py b/artiq/test/coredevice/portability.py index 752ded674..c1bce293b 100644 --- a/artiq/test/coredevice/portability.py +++ b/artiq/test/coredevice/portability.py @@ -1,7 +1,7 @@ from operator import itemgetter from fractions import Fraction -from artiq.language import * +from artiq.experiment import * from artiq.sim import devices as sim_devices from artiq.test.hardware_testbench import ExperimentCase diff --git a/artiq/test/coredevice/rtio.py b/artiq/test/coredevice/rtio.py index 60e059c17..b99a2ecb0 100644 --- a/artiq/test/coredevice/rtio.py +++ b/artiq/test/coredevice/rtio.py @@ -3,10 +3,8 @@ from math import sqrt -from artiq.language import * +from artiq.experiment import * from artiq.test.hardware_testbench import ExperimentCase -from artiq.coredevice.exceptions import (RTIOUnderflow, RTIOSequenceError, - RTIOCollisionError) class RTT(EnvExperiment): diff --git a/artiq/test/hardware_testbench.py b/artiq/test/hardware_testbench.py index 65d35d2e8..aa6c9d39e 100644 --- a/artiq/test/hardware_testbench.py +++ b/artiq/test/hardware_testbench.py @@ -6,7 +6,7 @@ import sys import unittest import logging -from artiq.language import * +from artiq.experiment import * from artiq.master.databases import DeviceDB, DatasetDB from artiq.master.worker_db import DeviceManager, DatasetManager from artiq.coredevice.core import CompileError diff --git a/artiq/test/scheduler.py b/artiq/test/scheduler.py index 75522ad21..4c0f8fa5e 100644 --- a/artiq/test/scheduler.py +++ b/artiq/test/scheduler.py @@ -5,7 +5,7 @@ import sys import os from time import time, sleep -from artiq.language import * +from artiq.experiment import * from artiq.master.scheduler import Scheduler diff --git a/artiq/test/worker.py b/artiq/test/worker.py index 8a02907c0..94c7d8897 100644 --- a/artiq/test/worker.py +++ b/artiq/test/worker.py @@ -5,7 +5,7 @@ import sys import os from time import sleep -from artiq.language import * +from artiq.experiment import * from artiq.master.worker import * diff --git a/doc/manual/core_language_reference.rst b/doc/manual/core_language_reference.rst index 66fe50411..8982f9231 100644 --- a/doc/manual/core_language_reference.rst +++ b/doc/manual/core_language_reference.rst @@ -1,7 +1,7 @@ Core language reference ======================= -The most commonly used features from those modules can be imported with ``from artiq.language import *``. +The most commonly used features from the ARTIQ language modules and from the core device modules are bundled together in ``artiq.experiment`` and can be imported with ``from artiq.experiment import *``. :mod:`artiq.language.core` module --------------------------------- diff --git a/doc/manual/getting_started_core.rst b/doc/manual/getting_started_core.rst index 85e7d2e24..aefc29a5b 100644 --- a/doc/manual/getting_started_core.rst +++ b/doc/manual/getting_started_core.rst @@ -8,7 +8,7 @@ Connecting to the core device As a very first step, we will turn on a LED on the core device. Create a file ``led.py`` containing the following: :: - from artiq.language import * + from artiq.experiment import * class LED(EnvExperiment): @@ -93,7 +93,7 @@ The point of running code on the core device is the ability to meet demanding re Create a new file ``rtio.py`` containing the following: :: - from artiq.language import * + from artiq.experiment import * class Tutorial(EnvExperiment): diff --git a/doc/manual/getting_started_mgmt.rst b/doc/manual/getting_started_mgmt.rst index 41d5305bf..bf31c0e6f 100644 --- a/doc/manual/getting_started_mgmt.rst +++ b/doc/manual/getting_started_mgmt.rst @@ -16,7 +16,7 @@ Then create a ``~/artiq-master/repository`` sub-folder to contain experiments. T Create a very simple experiment in ``~/artiq-master/repository`` and save it as ``mgmt_tutorial.py``: :: - from artiq.language import * + from artiq.experiment import * class MgmtTutorial(EnvExperiment): From 905063c1b198ea225a027a6877c6d1694df365dd Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 16:03:01 -0700 Subject: [PATCH 3/9] artiq.experiment: update examples --- examples/master/repository/arguments_demo.py | 2 +- .../master/repository/coredevice_examples/photon_histogram.py | 2 +- .../repository/coredevice_examples/simple/blink_forever.py | 2 +- .../master/repository/coredevice_examples/simple/dds_test.py | 2 +- .../master/repository/coredevice_examples/simple/handover.py | 2 +- .../master/repository/coredevice_examples/simple/mandelbrot.py | 2 +- examples/master/repository/coredevice_examples/tdr.py | 2 +- examples/master/repository/coredevice_examples/transport.py | 2 +- examples/master/repository/flopping_f_simulation.py | 2 +- examples/master/repository/run_forever.py | 2 +- examples/master/repository/speed_benchmark.py | 2 +- examples/master/repository/utilities/dds_setter.py | 2 +- examples/master/repository/utilities/terminate_all.py | 2 +- examples/sim/al_spectroscopy.py | 2 +- examples/sim/simple_simulation.py | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/master/repository/arguments_demo.py b/examples/master/repository/arguments_demo.py index 8559383f8..c26879c2c 100644 --- a/examples/master/repository/arguments_demo.py +++ b/examples/master/repository/arguments_demo.py @@ -1,6 +1,6 @@ import logging -from artiq.language import * +from artiq.experiment import * class SubComponent1(HasEnvironment): diff --git a/examples/master/repository/coredevice_examples/photon_histogram.py b/examples/master/repository/coredevice_examples/photon_histogram.py index 9cd574d9f..307b3a52e 100644 --- a/examples/master/repository/coredevice_examples/photon_histogram.py +++ b/examples/master/repository/coredevice_examples/photon_histogram.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class PhotonHistogram(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/blink_forever.py b/examples/master/repository/coredevice_examples/simple/blink_forever.py index 37ed06c03..98959c239 100644 --- a/examples/master/repository/coredevice_examples/simple/blink_forever.py +++ b/examples/master/repository/coredevice_examples/simple/blink_forever.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class BlinkForever(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/dds_test.py b/examples/master/repository/coredevice_examples/simple/dds_test.py index edcdf265c..a0b60bf73 100644 --- a/examples/master/repository/coredevice_examples/simple/dds_test.py +++ b/examples/master/repository/coredevice_examples/simple/dds_test.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class DDSTest(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/handover.py b/examples/master/repository/coredevice_examples/simple/handover.py index 6b63e338d..9e3a89747 100644 --- a/examples/master/repository/coredevice_examples/simple/handover.py +++ b/examples/master/repository/coredevice_examples/simple/handover.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class Handover(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/simple/mandelbrot.py b/examples/master/repository/coredevice_examples/simple/mandelbrot.py index a599823e9..81e477548 100644 --- a/examples/master/repository/coredevice_examples/simple/mandelbrot.py +++ b/examples/master/repository/coredevice_examples/simple/mandelbrot.py @@ -1,6 +1,6 @@ import sys -from artiq.language import * +from artiq.experiment import * class Mandelbrot(EnvExperiment): diff --git a/examples/master/repository/coredevice_examples/tdr.py b/examples/master/repository/coredevice_examples/tdr.py index 41caa0624..a71628645 100644 --- a/examples/master/repository/coredevice_examples/tdr.py +++ b/examples/master/repository/coredevice_examples/tdr.py @@ -1,6 +1,6 @@ # Copyright (C) 2014, 2015 Robert Jordens -from artiq.language import * +from artiq.experiment import * class PulseNotReceivedError(Exception): diff --git a/examples/master/repository/coredevice_examples/transport.py b/examples/master/repository/coredevice_examples/transport.py index c0eca6e72..748d3b7f7 100644 --- a/examples/master/repository/coredevice_examples/transport.py +++ b/examples/master/repository/coredevice_examples/transport.py @@ -2,7 +2,7 @@ import numpy as np -from artiq.language import * +from artiq.experiment import * from artiq.wavesynth.coefficients import SplineSource diff --git a/examples/master/repository/flopping_f_simulation.py b/examples/master/repository/flopping_f_simulation.py index 14b30e203..6f60557ac 100644 --- a/examples/master/repository/flopping_f_simulation.py +++ b/examples/master/repository/flopping_f_simulation.py @@ -5,7 +5,7 @@ import random import numpy as np from scipy.optimize import curve_fit -from artiq.language import * +from artiq.experiment import * def model(x, F0): diff --git a/examples/master/repository/run_forever.py b/examples/master/repository/run_forever.py index adddfd21d..553950077 100644 --- a/examples/master/repository/run_forever.py +++ b/examples/master/repository/run_forever.py @@ -1,7 +1,7 @@ from itertools import count from time import sleep -from artiq.language import * +from artiq.experiment import * class RunForever(EnvExperiment): diff --git a/examples/master/repository/speed_benchmark.py b/examples/master/repository/speed_benchmark.py index 4b5559700..e8a40f1bb 100644 --- a/examples/master/repository/speed_benchmark.py +++ b/examples/master/repository/speed_benchmark.py @@ -1,6 +1,6 @@ import time -from artiq.language import * +from artiq.experiment import * class _PayloadNOP(EnvExperiment): diff --git a/examples/master/repository/utilities/dds_setter.py b/examples/master/repository/utilities/dds_setter.py index 8ba6f18cc..1e8f4066d 100644 --- a/examples/master/repository/utilities/dds_setter.py +++ b/examples/master/repository/utilities/dds_setter.py @@ -1,6 +1,6 @@ from operator import itemgetter -from artiq.language import * +from artiq.experiment import * class DDSSetter(EnvExperiment): diff --git a/examples/master/repository/utilities/terminate_all.py b/examples/master/repository/utilities/terminate_all.py index c61402fe9..b48d7a722 100644 --- a/examples/master/repository/utilities/terminate_all.py +++ b/examples/master/repository/utilities/terminate_all.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class TerminateAll(EnvExperiment): diff --git a/examples/sim/al_spectroscopy.py b/examples/sim/al_spectroscopy.py index 97a55fb0b..bfbf1c5c4 100644 --- a/examples/sim/al_spectroscopy.py +++ b/examples/sim/al_spectroscopy.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class AluminumSpectroscopy(EnvExperiment): diff --git a/examples/sim/simple_simulation.py b/examples/sim/simple_simulation.py index 5106e06b6..1b9205825 100644 --- a/examples/sim/simple_simulation.py +++ b/examples/sim/simple_simulation.py @@ -1,4 +1,4 @@ -from artiq.language import * +from artiq.experiment import * class SimpleSimulation(EnvExperiment): From 2beaf23e6c0e6af38ee723fe9fc11f6e2b504dbb Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 15:52:52 -0700 Subject: [PATCH 4/9] language...ARTIQException -> coredevice...CoreException gets rid of a cross import is only used there --- artiq/coredevice/comm_generic.py | 17 ++++++----- artiq/coredevice/exceptions.py | 47 ++++++++++++++++++++++++++++++- artiq/frontend/artiq_run.py | 4 +-- artiq/language/core.py | 48 -------------------------------- 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index b97d13a4d..872b86cc2 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -4,7 +4,6 @@ import traceback from enum import Enum from fractions import Fraction -from artiq.language import core as core_language from artiq.coredevice import exceptions from artiq import __version__ as software_version @@ -458,8 +457,8 @@ class CommGeneric: self._write_header(_H2DMsgType.RPC_EXCEPTION) - if hasattr(exn, 'artiq_exception'): - exn = exn.artiq_exception + if hasattr(exn, 'core_exception'): + exn = exn.core_exception self._write_string(exn.name) self._write_string(exn.message) for index in range(3): @@ -505,16 +504,16 @@ class CommGeneric: traceback = list(reversed(symbolizer(backtrace))) + \ [(filename, line, column, function, None)] - exception = core_language.ARTIQException(name, message, params, traceback) + core_exception = exceptions.CoreException(name, message, params, traceback) - print(exception.id, exception.name) - if exception.id == 0: - python_exn_type = getattr(exceptions, exception.name.split('.')[-1]) + print(core_exception.id, core_exception.name) + if core_exception.id == 0: + python_exn_type = getattr(exceptions, core_exception.name.split('.')[-1]) else: - python_exn_type = object_map.retrieve(exception.id) + python_exn_type = object_map.retrieve(core_exception.id) python_exn = python_exn_type(message.format(*params)) - python_exn.artiq_exception = exception + python_exn.core_exception = core_exception raise python_exn def serve(self, object_map, symbolizer): diff --git a/artiq/coredevice/exceptions.py b/artiq/coredevice/exceptions.py index b0dbf740f..ea74f7a61 100644 --- a/artiq/coredevice/exceptions.py +++ b/artiq/coredevice/exceptions.py @@ -1,5 +1,5 @@ import builtins -from artiq.language.core import ARTIQException +from artiq.coredevice.runtime import source_loader ZeroDivisionError = builtins.ZeroDivisionError @@ -7,6 +7,51 @@ ValueError = builtins.ValueError IndexError = builtins.IndexError +class CoreException: + """Information about an exception raised or passed through the core device.""" + + def __init__(self, name, message, params, traceback): + if ':' in name: + exn_id, self.name = name.split(':', 2) + self.id = int(exn_id) + else: + self.id, self.name = 0, name + self.message, self.params = message, params + self.traceback = list(traceback) + + def __str__(self): + lines = [] + lines.append("Core Device Traceback (most recent call last):") + for (filename, line, column, function, address) in self.traceback: + stub_globals = {"__name__": filename, "__loader__": source_loader} + source_line = linecache.getline(filename, line, stub_globals) + indentation = re.search(r"^\s*", source_line).end() + + if address is None: + formatted_address = "" + else: + formatted_address = " (RA=0x{:x})".format(address) + + filename = filename.replace(os.path.normpath(os.path.join(os.path.dirname(__file__), + "..")), "") + if column == -1: + lines.append(" File \"{file}\", line {line}, in {function}{address}". + format(file=filename, line=line, function=function, + address=formatted_address)) + lines.append(" {}".format(source_line.strip() if source_line else "")) + else: + lines.append(" File \"{file}\", line {line}, column {column}," + " in {function}{address}". + format(file=filename, line=line, column=column + 1, + function=function, address=formatted_address)) + lines.append(" {}".format(source_line.strip() if source_line else "")) + lines.append(" {}^".format(" " * (column - indentation))) + + lines.append("{}({}): {}".format(self.name, self.id, + self.message.format(*self.params))) + return "\n".join(lines) + + class InternalError(Exception): """Raised when the runtime encounters an internal error condition.""" artiq_builtin = True diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index 480114a46..f1697632f 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -132,8 +132,8 @@ def run(with_file=False): except CompileError as error: return except Exception as exn: - if hasattr(exn, 'artiq_exception'): - print(exn.artiq_exception, file=sys.stderr) + if hasattr(exn, 'core_exception'): + print(exn.core_exception, file=sys.stderr) raise exn finally: device_mgr.close_devices() diff --git a/artiq/language/core.py b/artiq/language/core.py index 10eb3dcef..648f0dddd 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -10,7 +10,6 @@ from functools import wraps __all__ = ["host_int", "int", "host_round", "round", "kernel", "portable", "syscall", "host_only", "set_time_manager", "set_watchdog_factory", - "ARTIQException", "TerminationRequested"] # global namespace for kernels @@ -372,50 +371,3 @@ def watchdog(timeout): class TerminationRequested(Exception): """Raised by ``pause`` when the user has requested termination.""" pass - - -class ARTIQException: - """Information about an exception raised or passed through the core device.""" - - def __init__(self, name, message, params, traceback): - if ':' in name: - exn_id, self.name = name.split(':', 2) - self.id = host_int(exn_id) - else: - self.id, self.name = 0, name - self.message, self.params = message, params - self.traceback = list(traceback) - - def __str__(self): - # lazy import this - from artiq.coredevice.runtime import source_loader - lines = [] - lines.append("Core Device Traceback (most recent call last):") - for (filename, line, column, function, address) in self.traceback: - stub_globals = {"__name__": filename, "__loader__": source_loader} - source_line = linecache.getline(filename, line, stub_globals) - indentation = re.search(r"^\s*", source_line).end() - - if address is None: - formatted_address = "" - else: - formatted_address = " (RA=0x{:x})".format(address) - - filename = filename.replace(os.path.normpath(os.path.join(os.path.dirname(__file__), - "..")), "") - if column == -1: - lines.append(" File \"{file}\", line {line}, in {function}{address}". - format(file=filename, line=line, function=function, - address=formatted_address)) - lines.append(" {}".format(source_line.strip() if source_line else "")) - else: - lines.append(" File \"{file}\", line {line}, column {column}," - " in {function}{address}". - format(file=filename, line=line, column=column + 1, - function=function, address=formatted_address)) - lines.append(" {}".format(source_line.strip() if source_line else "")) - lines.append(" {}^".format(" " * (column - indentation))) - - lines.append("{}({}): {}".format(self.name, self.id, - self.message.format(*self.params))) - return "\n".join(lines) From e0f2d94191453534157da68c785ba06cc1c29d0c Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 15:58:32 -0700 Subject: [PATCH 5/9] coredevice: remove some print()s --- artiq/coredevice/comm_generic.py | 1 - artiq/coredevice/runtime.py | 1 - 2 files changed, 2 deletions(-) diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index 872b86cc2..b67b8acec 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -506,7 +506,6 @@ class CommGeneric: [(filename, line, column, function, None)] core_exception = exceptions.CoreException(name, message, params, traceback) - print(core_exception.id, core_exception.name) if core_exception.id == 0: python_exn_type = getattr(exceptions, core_exception.name.split('.')[-1]) else: diff --git a/artiq/coredevice/runtime.py b/artiq/coredevice/runtime.py index a9d74b63d..96df51e0e 100644 --- a/artiq/coredevice/runtime.py +++ b/artiq/coredevice/runtime.py @@ -5,7 +5,6 @@ class SourceLoader: self.runtime_root = runtime_root def get_source(self, filename): - print(os.path.join(self.runtime_root, filename)) with open(os.path.join(self.runtime_root, filename)) as f: return f.read() From 0d7dc7b144505c48533a003f08a7db7821a2678c Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 16:41:27 -0700 Subject: [PATCH 6/9] doc: update Underflow catching example --- doc/manual/getting_started_core.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/getting_started_core.rst b/doc/manual/getting_started_core.rst index aefc29a5b..7bdae5e9a 100644 --- a/doc/manual/getting_started_core.rst +++ b/doc/manual/getting_started_core.rst @@ -114,7 +114,7 @@ Instead, inside the core device, output timing is generated by the gateware and Try reducing the period of the generated waveform until the CPU cannot keep up with the generation of switching events and the underflow exception is raised. Then try catching it: :: - from artiq.coredevice.exceptions import RTIOUnderflow + from artiq.experiment import * def print_underflow(): From f4c7f021277cd5ff5061f983e0a93758655e2475 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 16:48:13 -0700 Subject: [PATCH 7/9] CoreException: store at 'py_exn.artiq_core_exception' ... and fix a few imports --- artiq/coredevice/comm_generic.py | 14 +++++++------- artiq/coredevice/exceptions.py | 4 ++++ artiq/frontend/artiq_run.py | 4 ++-- artiq/language/core.py | 1 - 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index b67b8acec..b4059fdcc 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -457,8 +457,8 @@ class CommGeneric: self._write_header(_H2DMsgType.RPC_EXCEPTION) - if hasattr(exn, 'core_exception'): - exn = exn.core_exception + if hasattr(exn, 'artiq_core_exception'): + exn = exn.artiq_core_exception self._write_string(exn.name) self._write_string(exn.message) for index in range(3): @@ -504,15 +504,15 @@ class CommGeneric: traceback = list(reversed(symbolizer(backtrace))) + \ [(filename, line, column, function, None)] - core_exception = exceptions.CoreException(name, message, params, traceback) + core_exn = exceptions.CoreException(name, message, params, traceback) - if core_exception.id == 0: - python_exn_type = getattr(exceptions, core_exception.name.split('.')[-1]) + if core_exn.id == 0: + python_exn_type = getattr(exceptions, core_exn.name.split('.')[-1]) else: - python_exn_type = object_map.retrieve(core_exception.id) + python_exn_type = object_map.retrieve(core_exn.id) python_exn = python_exn_type(message.format(*params)) - python_exn.core_exception = core_exception + python_exn.artiq_core_exception = core_exn raise python_exn def serve(self, object_map, symbolizer): diff --git a/artiq/coredevice/exceptions.py b/artiq/coredevice/exceptions.py index ea74f7a61..0576b2610 100644 --- a/artiq/coredevice/exceptions.py +++ b/artiq/coredevice/exceptions.py @@ -1,4 +1,8 @@ import builtins +import linecache +import re +import os + from artiq.coredevice.runtime import source_loader diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index f1697632f..5a37e0707 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -132,8 +132,8 @@ def run(with_file=False): except CompileError as error: return except Exception as exn: - if hasattr(exn, 'core_exception'): - print(exn.core_exception, file=sys.stderr) + if hasattr(exn, 'artiq_core_exception'): + print(exn.artiq_core_exception, file=sys.stderr) raise exn finally: device_mgr.close_devices() diff --git a/artiq/language/core.py b/artiq/language/core.py index 648f0dddd..7d6728f61 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -2,7 +2,6 @@ Core ARTIQ extensions to the Python language. """ -import os, linecache, re from collections import namedtuple from functools import wraps From cbb60337ae076b55175bf6e297720dd17a3d7828 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 17:41:51 -0700 Subject: [PATCH 8/9] refactor Analyzer constants to unlink dependencies --- artiq/coredevice/analyzer.py | 22 ++-------------------- artiq/gateware/rtio/analyzer.py | 2 +- artiq/gateware/rtio/analyzer_common.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 artiq/gateware/rtio/analyzer_common.py diff --git a/artiq/coredevice/analyzer.py b/artiq/coredevice/analyzer.py index 16903f5cf..778a3750b 100644 --- a/artiq/coredevice/analyzer.py +++ b/artiq/coredevice/analyzer.py @@ -1,33 +1,15 @@ from operator import itemgetter from collections import namedtuple from itertools import count -from enum import Enum import struct import logging +from artiq.gateware.rtio.analyzer_common import MessageType, ExceptionType + logger = logging.getLogger(__name__) -class MessageType(Enum): - output = 0b00 - input = 0b01 - exception = 0b10 - - -class ExceptionType(Enum): - reset_rising = 0b000000 - reset_falling = 0b000001 - reset_phy_rising = 0b000010 - reset_phy_falling = 0b000011 - - o_underflow_reset = 0b010000 - o_sequence_error_reset = 0b010001 - o_collision_error_reset = 0b010010 - - i_overflow_reset = 0b100000 - - OutputMessage = namedtuple( "OutputMessage", "channel timestamp rtio_counter address data") diff --git a/artiq/gateware/rtio/analyzer.py b/artiq/gateware/rtio/analyzer.py index b775aa14e..e2e196543 100644 --- a/artiq/gateware/rtio/analyzer.py +++ b/artiq/gateware/rtio/analyzer.py @@ -3,7 +3,7 @@ from migen.genlib.record import Record, layout_len from misoc.interconnect.csr import * from misoc.interconnect import stream -from artiq.coredevice.analyzer import MessageType, ExceptionType +from artiq.gateware.rtio.analyzer_common import MessageType, ExceptionType __all__ = ["Analyzer"] diff --git a/artiq/gateware/rtio/analyzer_common.py b/artiq/gateware/rtio/analyzer_common.py new file mode 100644 index 000000000..440c3b593 --- /dev/null +++ b/artiq/gateware/rtio/analyzer_common.py @@ -0,0 +1,20 @@ +from enum import Enum + + +class MessageType(Enum): + output = 0b00 + input = 0b01 + exception = 0b10 + + +class ExceptionType(Enum): + reset_rising = 0b000000 + reset_falling = 0b000001 + reset_phy_rising = 0b000010 + reset_phy_falling = 0b000011 + + o_underflow_reset = 0b010000 + o_sequence_error_reset = 0b010001 + o_collision_error_reset = 0b010010 + + i_overflow_reset = 0b100000 From d1119d77472eba9b05b4a63670765059dda00212 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Mon, 25 Jan 2016 18:04:06 -0700 Subject: [PATCH 9/9] artiq_dir: move out of tools to unlink dependencies --- artiq/__init__.py | 4 ++++ artiq/coredevice/core.py | 4 +++- artiq/coredevice/exceptions.py | 4 ++-- artiq/coredevice/runtime.py | 6 ++++-- artiq/frontend/artiq_flash.py | 3 ++- artiq/frontend/artiq_gui.py | 1 + artiq/gateware/targets/kc705.py | 2 +- artiq/gateware/targets/pipistrello.py | 2 +- artiq/tools.py | 4 +--- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/artiq/__init__.py b/artiq/__init__.py index e44e9d156..6bbf35eec 100644 --- a/artiq/__init__.py +++ b/artiq/__init__.py @@ -1,3 +1,7 @@ from ._version import get_versions __version__ = get_versions()['version'] del get_versions + +import os +__artiq_dir__ = os.path.dirname(os.path.abspath(__file__)) +del os diff --git a/artiq/coredevice/core.py b/artiq/coredevice/core.py index aa1bb8560..0cf49b27c 100644 --- a/artiq/coredevice/core.py +++ b/artiq/coredevice/core.py @@ -2,6 +2,8 @@ import os, sys from pythonparser import diagnostic +from artiq import __artiq_dir__ as artiq_dir + from artiq.language.core import * from artiq.language.types import * from artiq.language.units import * @@ -16,7 +18,7 @@ from artiq.coredevice import exceptions def _render_diagnostic(diagnostic, colored): def shorten_path(path): - return path.replace(os.path.normpath(os.path.join(__file__, "..", "..")), "") + return path.replace(artiq_dir, "") lines = [shorten_path(path) for path in diagnostic.render(colored)] return "\n".join(lines) diff --git a/artiq/coredevice/exceptions.py b/artiq/coredevice/exceptions.py index 0576b2610..62d4c147a 100644 --- a/artiq/coredevice/exceptions.py +++ b/artiq/coredevice/exceptions.py @@ -3,6 +3,7 @@ import linecache import re import os +from artiq import __artiq_dir__ as artiq_dir from artiq.coredevice.runtime import source_loader @@ -36,8 +37,7 @@ class CoreException: else: formatted_address = " (RA=0x{:x})".format(address) - filename = filename.replace(os.path.normpath(os.path.join(os.path.dirname(__file__), - "..")), "") + filename = filename.replace(artiq_dir, "") if column == -1: lines.append(" File \"{file}\", line {line}, in {function}{address}". format(file=filename, line=line, function=function, diff --git a/artiq/coredevice/runtime.py b/artiq/coredevice/runtime.py index 96df51e0e..4d65e86d8 100644 --- a/artiq/coredevice/runtime.py +++ b/artiq/coredevice/runtime.py @@ -1,5 +1,8 @@ import os +from artiq import __artiq_dir__ as artiq_dir + + class SourceLoader: def __init__(self, runtime_root): self.runtime_root = runtime_root @@ -8,5 +11,4 @@ class SourceLoader: with open(os.path.join(self.runtime_root, filename)) as f: return f.read() -artiq_root = os.path.join(os.path.dirname(__file__), "..", "..") -source_loader = SourceLoader(os.path.join(artiq_root, "soc", "runtime")) +source_loader = SourceLoader(os.path.join(artiq_dir, "soc", "runtime")) diff --git a/artiq/frontend/artiq_flash.py b/artiq/frontend/artiq_flash.py index df3b330a0..8d484cc41 100755 --- a/artiq/frontend/artiq_flash.py +++ b/artiq/frontend/artiq_flash.py @@ -7,6 +7,7 @@ import subprocess import tempfile import artiq +from artiq import __artiq_dir__ as artiq_dir from artiq.frontend.bit2bin import bit2bin @@ -70,7 +71,7 @@ def main(): }[opts.target] if opts.dir is None: - opts.dir = os.path.join(os.path.dirname(artiq.__file__), "binaries", + opts.dir = os.path.join(artiq_dir, "binaries", "{}-{}".format(opts.target, opts.adapter)) conv = False diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 9ce3aa151..615b503fb 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -10,6 +10,7 @@ import os from quamash import QEventLoop, QtGui, QtCore from pyqtgraph import dockarea +from artiq import __artiq_dir__ as artiq_dir from artiq.tools import * from artiq.protocols.pc_rpc import AsyncioClient from artiq.gui.models import ModelSubscriber diff --git a/artiq/gateware/targets/kc705.py b/artiq/gateware/targets/kc705.py index e288dde71..fda69e95b 100755 --- a/artiq/gateware/targets/kc705.py +++ b/artiq/gateware/targets/kc705.py @@ -20,7 +20,7 @@ from misoc.targets.kc705 import MiniSoC, soc_kc705_args, soc_kc705_argdict from artiq.gateware.soc import AMPSoC from artiq.gateware import rtio, nist_qc1, nist_clock, nist_qc2 from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_7series, dds -from artiq.tools import artiq_dir +from artiq import __artiq_dir__ as artiq_dir from artiq import __version__ as artiq_version diff --git a/artiq/gateware/targets/pipistrello.py b/artiq/gateware/targets/pipistrello.py index c6290d2ac..288a7b3c8 100755 --- a/artiq/gateware/targets/pipistrello.py +++ b/artiq/gateware/targets/pipistrello.py @@ -20,7 +20,7 @@ from misoc.targets.pipistrello import * from artiq.gateware.soc import AMPSoC from artiq.gateware import rtio, nist_qc1 from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_spartan6, dds -from artiq.tools import artiq_dir +from artiq import __artiq_dir__ as artiq_dir from artiq import __version__ as artiq_version diff --git a/artiq/tools.py b/artiq/tools.py index d589afadf..addd5d55c 100644 --- a/artiq/tools.py +++ b/artiq/tools.py @@ -16,7 +16,7 @@ from artiq.language.environment import is_experiment from artiq.protocols import pyon -__all__ = ["artiq_dir", "parse_arguments", "elide", "short_format", "file_import", +__all__ = ["parse_arguments", "elide", "short_format", "file_import", "get_experiment", "verbosity_args", "simple_network_args", "init_logger", "bind_address_from_args", "atexit_register_coroutine", "exc_to_warning", "asyncio_wait_or_cancel", @@ -25,8 +25,6 @@ __all__ = ["artiq_dir", "parse_arguments", "elide", "short_format", "file_import logger = logging.getLogger(__name__) -artiq_dir = os.path.join(os.path.abspath(os.path.dirname(__file__))) - def parse_arguments(arguments): d = {}