Skip to content

Instantly share code, notes, and snippets.

@davaymne
Created December 13, 2020 18:59
Show Gist options
  • Save davaymne/eeecfcb27fc34e2766f7c7442e4abfc9 to your computer and use it in GitHub Desktop.
Save davaymne/eeecfcb27fc34e2766f7c7442e4abfc9 to your computer and use it in GitHub Desktop.
# 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