Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow artiq_compile to use an ARTIQ master #2636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions artiq/frontend/artiq_compile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3

import os, sys, io, tarfile, logging, argparse
import os, io, tarfile, logging, contextlib, argparse

from sipyco import common_args
from sipyco.pc_rpc import Client

from artiq import __version__ as artiq_version
from artiq.master.databases import DeviceDB, DatasetDB
Expand All @@ -26,6 +27,10 @@ def get_argparser():
help="device database file (default: '%(default)s')")
parser.add_argument("--dataset-db", default="dataset_db.mdb",
help="dataset file (default: '%(default)s')")
parser.add_argument("-s", "--server",
help="hostname or IP of the master to connect to")
parser.add_argument("--port", default=3251, type=int,
help="TCP port to use to connect to the master")

parser.add_argument("-c", "--class-name", default=None,
help="name of the class to compile")
Expand All @@ -44,9 +49,19 @@ def main():
args = get_argparser().parse_args()
common_args.init_logger_from_args(args)

device_mgr = DeviceManager(DeviceDB(args.device_db))
dataset_db = DatasetDB(args.dataset_db)
try:
with contextlib.ExitStack() as cleanup:
if args.server is not None:
devices = Client(args.server, args.port, "device_db")
cleanup.callback(devices.close_rpc)

dataset_db = Client(args.server, args.port, "dataset_db")
cleanup.callback(dataset_db.close_rpc)
else:
devices = DeviceDB(args.device_db)
dataset_db = DatasetDB(args.dataset_db)
cleanup.callback(dataset_db.close_db)

device_mgr = DeviceManager(devices)
dataset_mgr = DatasetManager(dataset_db)

try:
Expand Down Expand Up @@ -86,8 +101,6 @@ def main():
return
finally:
device_mgr.close_devices()
finally:
dataset_db.close_db()

if object_map.has_rpc():
raise ValueError("Experiment must not use RPC")
Expand Down