def handle(options, args): """ `grok GET` handler. """ (endpoint, apikey) = grokcli.getCommonArgs(parser, args) server = "%(scheme)s://%(netloc)s" % urlparse(endpoint)._asdict() grok = GrokSession(server=server, apikey=apikey) response = grok.get(endpoint) if isinstance(response, Response): if hasattr(options, "useYaml"): if options.useYaml: print yaml.safe_dump(yaml.load(response.text), default_flow_style=False) else: print response.text sys.exit(not int(bool(response)))
def handle(options, args): """ `grok GET` handler. """ (endpoint, apikey) = grokcli.getCommonArgs(parser, args) server = "%(scheme)s://%(netloc)s" % urlparse(endpoint)._asdict() grok = GrokSession(server=server, apikey=apikey) response = grok.get(endpoint) if isinstance(response, Response): if hasattr(options, "useYaml"): if options.useYaml: print yaml.safe_dump(yaml.load(response.text), default_flow_style=False) else: print response.text sys.exit(not int(bool(response)))
"metricSpec": { "uid": uid, "resource": "My Resource Name", "unit": "Files Open", }, "modelParams": { "min": 0, "max": 20000, } }) model = models[0] assert model["uid"] == uid assert model["name"] == METRIC_NAME # Get model status for _ in xrange(30): modelResponse = grok.get(grok.server + "/_models/" + uid, auth=grok.auth) models = modelResponse.json() model = models[0] if model["status"] == 1: break time.sleep(10) else: raise Exception('Model did not transition to "ready" status in a ' "reasonable amount of time.") print ('Your model is ready and Grok is actively monitoring the "%s"' " custom metric. You can monitor the progress in the Grok Android" " Client." % METRIC_NAME)
"resource": "My Resource Name", "unit": "Files Open", }, "modelParams": { "min": 0, "max": 20000, } }) model = models[0] assert model["uid"] == uid assert model["name"] == METRIC_NAME # Get model status for _ in xrange(30): modelResponse = grok.get(grok.server + "/_models/" + uid, auth=grok.auth) models = modelResponse.json() model = models[0] if model["status"] == 1: break time.sleep(10) else: raise Exception('Model did not transition to "ready" status in a ' "reasonable amount of time.") print( 'Your model is ready and Grok is actively monitoring the "%s"' " custom metric. You can monitor the progress in the Grok Android" " Client." % METRIC_NAME)