Commit e4ed3804 authored by Valentin Reis's avatar Valentin Reis

[feature] Adds a --filter option to `cmd` for pretty-printing.

The option accepts a message type and prints the values in the csv
format:
msgtype, time, payload if the --filter option is recognized
msgtype, time otherwise
The print is force-flushed on stdout.
This switches CI to the "refactored" CI identifier at argotests/tests
parent a5900178
Pipeline #4887 passed with stages
in 2 minutes and 21 seconds
...@@ -3,5 +3,5 @@ let argotest = ...@@ -3,5 +3,5 @@ let argotest =
"https://xgitlab.cels.anl.gov/argo/argotest/-/archive/master/argotest-master.tar.gz"; "https://xgitlab.cels.anl.gov/argo/argotest/-/archive/master/argotest-master.tar.gz";
in import "${argotest}/test.nix" { in import "${argotest}/test.nix" {
nrm-override = ./..; nrm-override = ./..;
testName = "base"; testName = "refactored";
} }
...@@ -8,6 +8,7 @@ import os ...@@ -8,6 +8,7 @@ import os
import nrm.messaging import nrm.messaging
import uuid import uuid
import sys import sys
import time
import collections import collections
RPC_MSG = nrm.messaging.MSGTYPES['up_rpc_req'] RPC_MSG = nrm.messaging.MSGTYPES['up_rpc_req']
...@@ -59,12 +60,24 @@ class CommandLineInterface(object): ...@@ -59,12 +60,24 @@ class CommandLineInterface(object):
while(True): while(True):
msg = self.pub_client.recvmsg() msg = self.pub_client.recvmsg()
logger.debug("pub message: %s", msg)
def print_if_filter():
if argv.filter:
if argv.filter == msg.type:
print("%s, %s, %s" % (msg.type, time.time(),
msg.payload))
sys.stdout.flush()
else:
print("%s, %s" % (msg.type, time.time()))
sys.stdout.flush()
if argv.uuid: if argv.uuid:
uuid = getattr(msg, 'container_uuid', None) uuid = getattr(msg, 'container_uuid', None)
if argv.uuid == uuid: if argv.uuid == uuid:
logger.info("pub message: %s", msg) print_if_filter()
else: else:
logger.info("pub message: %s", msg) print_if_filter()
def do_run(self, argv): def do_run(self, argv):
""" Connect to the NRM and ask to spawn a container and run a command """ Connect to the NRM and ask to spawn a container and run a command
...@@ -227,6 +240,10 @@ class CommandLineInterface(object): ...@@ -227,6 +240,10 @@ class CommandLineInterface(object):
parser_listen.add_argument("-u", "--uuid", parser_listen.add_argument("-u", "--uuid",
help="container uuid to listen for", help="container uuid to listen for",
default=None) default=None)
parser_listen.add_argument("-f", "--filter",
help="type of message to filter and \
\ prettyprint, in {power,performance}",
default=None)
parser_listen.set_defaults(func=self.do_listen) parser_listen.set_defaults(func=self.do_listen)
# setpowerlimit # setpowerlimit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment