Add support for Concraft-pl RTS options
This commit is contained in:
@@ -14,9 +14,8 @@ from conmorfeusz.server import StandaloneApplication
|
|||||||
@click.option('--ccpl-port', default=3000, help='Port which internal concraft-pl server will be listening on.')
|
@click.option('--ccpl-port', default=3000, help='Port which internal concraft-pl server will be listening on.')
|
||||||
@click.option('--ccpl-model', default=None, help='Model used by concraft-pl. It will fallback to CONCRAFT_PL_MODEL envvar if not specified.')
|
@click.option('--ccpl-model', default=None, help='Model used by concraft-pl. It will fallback to CONCRAFT_PL_MODEL envvar if not specified.')
|
||||||
@click.option('--ccpl-bin', default=None, help='Concraft-pl binary file. It will fallback to CONCRAFT_PL_BIN envvar if not specified.')
|
@click.option('--ccpl-bin', default=None, help='Concraft-pl binary file. It will fallback to CONCRAFT_PL_BIN envvar if not specified.')
|
||||||
@click.option('--ccpl-core-num', default=1, help='Number of cores used to run Concraft-pl logic.')
|
@click.option("--ccpl-rts", default="-A4M -N4", help='Runtime system configuration for Concraft-pl VM.')
|
||||||
@click.option('--ccpl-alloc-size', default=64, help='Allocation size for Concraft-pl.')
|
def run(host, port, workers, ccpl_port, ccpl_model, ccpl_bin, ccpl_rts):
|
||||||
def run(host, port, workers, ccpl_port, ccpl_model, ccpl_bin, ccpl_core_num, ccpl_alloc_size):
|
|
||||||
"""
|
"""
|
||||||
Glues all services together and starts the holistic app.
|
Glues all services together and starts the holistic app.
|
||||||
"""
|
"""
|
||||||
@@ -30,7 +29,7 @@ def run(host, port, workers, ccpl_port, ccpl_model, ccpl_bin, ccpl_core_num, ccp
|
|||||||
if ccpl_bin is None:
|
if ccpl_bin is None:
|
||||||
raise Exception("Concraft-pl binary file must be specified either by --ccpl-bin option or by CONCRAFT_PL_BIN environment variable")
|
raise Exception("Concraft-pl binary file must be specified either by --ccpl-bin option or by CONCRAFT_PL_BIN environment variable")
|
||||||
|
|
||||||
concraft_cfg = (ccpl_model, ccpl_bin, ccpl_port, ccpl_core_num, ccpl_alloc_size)
|
concraft_cfg = (ccpl_model, ccpl_bin, ccpl_port, ccpl_rts.split())
|
||||||
|
|
||||||
with ccpl.start_server(*concraft_cfg):
|
with ccpl.start_server(*concraft_cfg):
|
||||||
options = {
|
options = {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Concraft(object):
|
|||||||
|
|
||||||
class Server(object):
|
class Server(object):
|
||||||
def __init__(self, model_path, concraft_path="concraft-pl", port=3000,
|
def __init__(self, model_path, concraft_path="concraft-pl", port=3000,
|
||||||
core_num=1, allocation_size=64):
|
runtimeArgs=[]):
|
||||||
"""
|
"""
|
||||||
Start a Concraft-pl server instance in the background.
|
Start a Concraft-pl server instance in the background.
|
||||||
|
|
||||||
@@ -105,8 +105,7 @@ class Server(object):
|
|||||||
"""
|
"""
|
||||||
self.port = port
|
self.port = port
|
||||||
self.concraft_server = Popen([concraft_path, 'server',
|
self.concraft_server = Popen([concraft_path, 'server',
|
||||||
'--port={}'.format(port), '-i', model_path, '+RTS',
|
'--port={}'.format(port), '-i', model_path, '+RTS', *runtimeArgs],
|
||||||
'-N{}'.format(core_num), '-A{}M'.format(allocation_size),],
|
|
||||||
stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
# print(u"Concraft model " + model_path + u" loading...")
|
# print(u"Concraft model " + model_path + u" loading...")
|
||||||
loaded = False
|
loaded = False
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ self: {
|
|||||||
# { host = "0.0.0.0"; port = 8888; } -> "--host '0.0.0.0' --port '8888'"
|
# { host = "0.0.0.0"; port = 8888; } -> "--host '0.0.0.0' --port '8888'"
|
||||||
attrsToArgs = attrs:
|
attrsToArgs = attrs:
|
||||||
lib.concatStringsSep " " (
|
lib.concatStringsSep " " (
|
||||||
lib.mapAttrsToList (name: value: "--${name} ${lib.escapeShellArg (toString value)}") attrs
|
lib.mapAttrsToList (name: value: "--${name} '${lib.escapeShellArg (toString value)}'") attrs
|
||||||
);
|
);
|
||||||
|
|
||||||
# Helper function to convert attrset to CLI arguments with prefix
|
# Helper function to convert attrset to CLI arguments with prefix
|
||||||
# { port = 3000; bin = "..."; } -> "--ccpl-port '3000' --ccpl-bin '...'"
|
# { port = 3000; bin = "..."; } -> "--ccpl-port '3000' --ccpl-bin '...'"
|
||||||
attrsToArgsWithPrefix = prefix: attrs:
|
attrsToArgsWithPrefix = prefix: attrs:
|
||||||
lib.concatStringsSep " " (
|
lib.concatStringsSep " " (
|
||||||
lib.mapAttrsToList (name: value: "--${prefix}-${name} ${lib.escapeShellArg (toString value)}") attrs
|
lib.mapAttrsToList (name: value: "--${prefix}-${name} '${lib.escapeShellArg (toString value)}'") attrs
|
||||||
);
|
);
|
||||||
in {
|
in {
|
||||||
options.services.conmorfeusz = {
|
options.services.conmorfeusz = {
|
||||||
|
|||||||
Reference in New Issue
Block a user