Created
December 13, 2020 18:59
-
-
Save davaymne/eeecfcb27fc34e2766f7c7442e4abfc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script for bulk costmodel provisioning. | |
# Require: tsv file (fields tab separated) | |
# File format: 4 fields: name, id, full path to costmodel, variable string | |
# How to use: python3 set-bulk-costmodel.py my-costmodels.tsv | |
import sys | |
import subprocess | |
with open(sys.argv[1], 'r') as f: | |
for line in f: | |
print(line) | |
name, id, model, variables = line.split('\t') | |
cmd = ['graph', 'indexer', 'cost', 'set', 'model', id, model] | |
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE) | |
stdout, stderr = p.communicate() | |
print(stdout.decode('utf-8'), stderr.decode('utf-8')) | |
cmd = ['graph', 'indexer', 'cost', 'set', 'variables', id, variables] | |
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE) | |
stdout, stderr = p.communicate() | |
print(stdout.decode('utf-8'), stderr.decode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment