Load a Protocol from Autoprotocol JSON #219
Copy link
Copy link
Open
Description
Activity
Hey Sean, that's a cool idea, it isn't supported in Ap-py. I'd be interested to hear how that could be done?
I spent some time looking at the code and came across some differences between the spec and this package. For example, spec for a container_ref does not include the container type, which is required by autoprotocol-python to generate a Container.
"refs": { String: { "id": Option<String>, "new": Option<String>, "store": Option<{ "where": Option<Enum( "cold_80", "cold_20", "cold_4", "ambient", "warm_30", "warm_37" )> }>, "discard": Option<Boolean>, "cover": Option<String> } } }The missing container type means I can't do this
def from_json(path): """ Load an Autoprotocol formatted JSON. Args: path (str): file path. Returns: [autoprotocol.container.Container], autoprotocol.protocol.Protocol """ containers = [] with open(path, "r") as f: p_dict = json.load(f) p = Protocol() for k,v in p_dict["refs"].items(): ## get storage info storage = v.get("store", None) if storage: storage = v["store"]["where"] ## cont_type is not available in spec unless it is a "new" ## container e.g, ## ## "sample_plate_1": { ## "new": "96-pcr", ## "discard": true ## } cont_type = v.get("new", None) ## create container, this will break without cont_type c = Container(v.get("id", None), cont_type, name = k, storage = storage, cover = v.get("cover", None)) containers.append(c) ## create Ref and add to protocol r = Ref(k, v, c) p.refs[k] = r ## create instructions for i in p_dict["instructions"]: ## insert code here ## p._append_and_return(Instruction) return containers, pI haven't explored rebuilding the instructions yet
Metadata
Metadata
Assignees
Labels
No labels
Hello,
Is there way to load a protocol from a json file?
For example, the protocol can be serialized to JSON using:
How do I go the other way? Ideally, something like: