conduit icon indicating copy to clipboard operation
conduit copied to clipboard

mesh bp index selection util

Open cyrush opened this issue 5 years ago • 1 comments

place holder for grand ideas.

@mclarsen had a use case where we wanted to re-write a blueprint index to only identify a subset of the data. we hacked together a python script, a standard utility might be helpful

cyrush avatar Mar 11 '20 23:03 cyrush

Here is the hack-ish python script:

import conduit
import conduit.relay
import conduit.blueprint
import sys


def go(input_root_name, domain_id, protocol = "json"):
    n_root = conduit.Node()
    conduit.relay.io.load(n_root, input_root_name, protocol);
    print(n_root.to_yaml())
    hacked_root = conduit.Node()
    hacked_root.set(n_root)
    hacked_root["blueprint_index"][0]["state/number_of_domains"] = 1
    hacked_root["num_trees"] = 1
    hacked_root["num_files"] = 1
    if "%0" in hacked_root["file_pattern"]:
        hacked_root["file_pattern"] = hacked_root["file_pattern"] % domain_id
    if "%0" in hacked_root["tree_pattern"]:
        hacked_root["tree_pattern"] = hacked_root["tree_pattern"] % domain_id
    print(hacked_root.to_yaml())
    conduit.relay.io.save(hacked_root,"the_one.blueprint_root","json")


if __name__ == "__main__":
    print(sys.argv)
    input_root_name = sys.argv[1]
    domain_id  = int(sys.argv[2])
    go(input_root_name,domain_id)

cyrush avatar Mar 12 '20 18:03 cyrush