Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e20b26011743
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f836465585be
Choose a head ref
  • 7 commits
  • 18 files changed
  • 1 contributor

Commits on Jul 14, 2015

  1. Copy the full SHA
    a07f247 View commit details
  2. worker: factor timeouts

    sbourdeauducq committed Jul 14, 2015
    Copy the full SHA
    7770ab6 View commit details

Commits on Jul 15, 2015

  1. Copy the full SHA
    9ed4dcd View commit details
  2. Copy the full SHA
    7de5666 View commit details
  3. Copy the full SHA
    255aba9 View commit details
  4. Copy the full SHA
    84de2fb View commit details
  5. Copy the full SHA
    f836465 View commit details
14 changes: 0 additions & 14 deletions artiq/coredevice/comm_dummy.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
from operator import itemgetter

from artiq.language.units import ms
from artiq.coredevice.runtime import LinkInterface


class _RuntimeEnvironment(LinkInterface):
def __init__(self):
self.warmup_time = 1*ms

def emit_object(self):
return str(self.llvm_module)


class Comm:
def __init__(self, dmgr):
pass

def get_runtime_env(self):
return _RuntimeEnvironment()

def switch_clock(self, external):
pass

6 changes: 3 additions & 3 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
from artiq.transforms.lower_time import lower_time
from artiq.transforms.unparse import unparse

from artiq.coredevice.runtime import Environment
from artiq.coredevice.runtime import Runtime

from artiq.py2llvm import get_runtime_binary

@@ -54,7 +54,7 @@ def __init__(self, dmgr, ref_period=8*ns, external_clock=False):
self.first_run = True
self.core = self
self.comm.core = self
self.runtime_env = Environment()
self.runtime = Runtime()

def transform_stack(self, func_def, rpc_map, exception_map,
debug_unparse=_no_debug_unparse):
@@ -102,7 +102,7 @@ def compile(self, k_function, k_args, k_kwargs, with_attr_writeback=True):
debug_unparse("inline", func_def)
self.transform_stack(func_def, rpc_map, exception_map, debug_unparse)

binary = get_runtime_binary(self.runtime_env, func_def)
binary = get_runtime_binary(self.runtime, func_def)

return binary, rpc_map, exception_map

4 changes: 2 additions & 2 deletions artiq/coredevice/runtime.py
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ def _debug_dump_obj(obj):
raise IOError


class Environment(LinkInterface):
class Runtime(LinkInterface):
def __init__(self):
self.cpu_type = "or1k"
# allow 1ms for all initial DDS programming
@@ -209,4 +209,4 @@ def emit_object(self):
return obj

def __repr__(self):
return "<Environment {}>".format(self.cpu_type)
return "<Runtime {}>".format(self.cpu_type)
12 changes: 6 additions & 6 deletions artiq/frontend/artiq_client.py
Original file line number Diff line number Diff line change
@@ -43,8 +43,8 @@ def get_argparser():
parser_add.add_argument("-f", "--flush", default=False, action="store_true",
help="flush the pipeline before preparing "
"the experiment")
parser_add.add_argument("-e", "--experiment", default=None,
help="experiment to run")
parser_add.add_argument("-c", "--class-name", default=None,
help="name of the class to run")
parser_add.add_argument("file",
help="file containing the experiment to run")
parser_add.add_argument("arguments", nargs="*",
@@ -102,7 +102,7 @@ def _action_submit(remote, args):

expid = {
"file": args.file,
"experiment": args.experiment,
"class_name": args.class_name,
"arguments": arguments,
}
if args.timed is None:
@@ -142,7 +142,7 @@ def _show_schedule(schedule):
x[1]["due_date"] or 0,
x[0]))
table = PrettyTable(["RID", "Pipeline", " Status ", "Prio",
"Due date", "File", "Experiment", "Arguments"])
"Due date", "File", "Class name", "Arguments"])
for rid, v in l:
row = [rid, v["pipeline"], v["status"], v["priority"]]
if v["due_date"] is None:
@@ -151,10 +151,10 @@ def _show_schedule(schedule):
row.append(time.strftime("%m/%d %H:%M:%S",
time.localtime(v["due_date"])))
row.append(v["expid"]["file"])
if v["expid"]["experiment"] is None:
if v["expid"]["class_name"] is None:
row.append("")
else:
row.append(v["expid"]["experiment"])
row.append(v["expid"]["class_name"])
row.append(format_arguments(v["expid"]["arguments"]))
table.add_row(row)
print(table)
5 changes: 3 additions & 2 deletions artiq/frontend/artiq_master.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ def main():
ddb = FlatFileDB("ddb.pyon")
pdb = FlatFileDB("pdb.pyon")
rtr = Notifier(dict())
repository = Repository()

if os.name == "nt":
loop = asyncio.ProactorEventLoop()
@@ -61,12 +60,14 @@ def main():
"master_ddb": ddb,
"master_pdb": pdb,
"master_schedule": scheduler,
"master_repository": repository,
})
loop.run_until_complete(server_control.start(
args.bind, args.port_control))
atexit.register(lambda: loop.run_until_complete(server_control.stop()))

repository = Repository()
loop.run_until_complete(repository.scan())

server_notify = Publisher({
"schedule": scheduler.notifier,
"devices": ddb.data,
6 changes: 3 additions & 3 deletions artiq/gui/explorer.py
Original file line number Diff line number Diff line change
@@ -85,11 +85,11 @@ def init_explist_model(self, init):
return self.explist_model

@asyncio.coroutine
def submit(self, pipeline_name, file, experiment, arguments,
def submit(self, pipeline_name, file, class_name, arguments,
priority, due_date, flush):
expid = {
"file": file,
"experiment": experiment,
"class_name": class_name,
"arguments": arguments,
}
rid = yield from self.schedule_ctl.submit(pipeline_name, expid,
@@ -107,6 +107,6 @@ def submit_clicked(self):
else:
due_date = None
asyncio.async(self.submit(self.pipeline.text(),
expinfo["file"], expinfo["experiment"],
expinfo["file"], expinfo["class_name"],
dict(), self.priority.value(), due_date,
self.flush.isChecked()))
6 changes: 3 additions & 3 deletions artiq/gui/schedule.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ class _ScheduleModel(DictSyncModel):
def __init__(self, parent, init):
DictSyncModel.__init__(self,
["RID", "Pipeline", "Status", "Prio", "Due date",
"File", "Experiment", "Arguments"],
"File", "Class name", "Arguments"],
parent, init)

def sort_key(self, k, v):
@@ -38,10 +38,10 @@ def convert(self, k, v, column):
elif column == 5:
return v["expid"]["file"]
elif column == 6:
if v["expid"]["experiment"] is None:
if v["expid"]["class_name"] is None:
return ""
else:
return v["expid"]["experiment"]
return v["expid"]["class_name"]
elif column == 7:
return format_arguments(v["expid"]["arguments"])
else:
19 changes: 17 additions & 2 deletions artiq/language/environment.py
Original file line number Diff line number Diff line change
@@ -10,12 +10,20 @@ class NoDefault:
pass


class DefaultMissing(Exception):
"""Raised by the ``default`` method of argument processors when no default
value is available."""
pass


class FreeValue:
def __init__(self, default=NoDefault):
if default is not NoDefault:
self.default_value = default

def default(self):
if not hasattr(self, "default_value"):
raise DefaultMissing
return self.default_value

def process(self, x):
@@ -32,13 +40,14 @@ class HasEnvironment:
"""Provides methods to manage the environment of an experiment (devices,
parameters, results, arguments)."""
def __init__(self, dmgr=None, pdb=None, rdb=None, *,
param_override=dict(), **kwargs):
param_override=dict(), default_arg_none=False, **kwargs):
self.requested_args = dict()

self.__dmgr = dmgr
self.__pdb = pdb
self.__rdb = rdb
self.__param_override = param_override
self.__default_arg_none = default_arg_none

self.__kwargs = kwargs
self.__in_build = True
@@ -65,7 +74,13 @@ def get_argument(self, key, processor=None):
try:
argval = self.__kwargs[key]
except KeyError:
return processor.default()
try:
return processor.default()
except DefaultMissing:
if self.__default_arg_none:
return None
else:
raise
return processor.process(argval)

def attr_argument(self, key, processor=None):
63 changes: 43 additions & 20 deletions artiq/master/repository.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,61 @@
import os
import logging
import asyncio

from artiq.protocols.sync_struct import Notifier
from artiq.tools import file_import
from artiq.language.environment import is_experiment
from artiq.master.worker import Worker


def scan_experiments():
logger = logging.getLogger(__name__)


@asyncio.coroutine
def _scan_experiments():
r = dict()
for f in os.listdir("repository"):
if f.endswith(".py"):
try:
m = file_import(os.path.join("repository", f))
except:
continue
for k, v in m.__dict__.items():
if is_experiment(v):
if v.__doc__ is None:
name = k
else:
name = v.__doc__.splitlines()[0].strip()
if name[-1] == ".":
name = name[:-1]
full_name = os.path.join("repository", f)
worker = Worker()
try:
description = yield from worker.examine(full_name)
finally:
yield from worker.close()
for class_name, class_desc in description.items():
name = class_desc["name"]
arguments = class_desc["arguments"]
if name in r:
logger.warning("Duplicate experiment name: '%s'", name)
basename = name
i = 1
while name in r:
name = basename + str(i)
i += 1
entry = {
"file": os.path.join("repository", f),
"experiment": k
"file": full_name,
"class_name": class_name,
"arguments": arguments
}
r[name] = entry
except:
logger.warning("Skipping file '%s'", f, exc_info=True)
return r


def _sync_explist(target, source):
for k in list(target.read.keys()):
if k not in source:
del target[k]
for k in source.keys():
if k not in target.read or target.read[k] != source[k]:
target[k] = source[k]


class Repository:
def __init__(self):
self.explist = Notifier(scan_experiments())
self.explist = Notifier(dict())

def get_data(self, filename):
with open(os.path.join("repository", filename)) as f:
return f.read()
@asyncio.coroutine
def scan(self):
new_explist = yield from _scan_experiments()
_sync_explist(self.explist, new_explist)
Loading