xdl.readwrite.json module
- xdl.readwrite.json.VALID_SECTIONS: List[str] = ['steps', 'reagents', 'hardware', 'metadata', 'parameters']
Valid sections for XDL JSON.
- xdl.readwrite.json.validate_json_blueprint(xdl_json: Dict[str, Any]) None [source]
Validate format of XDL JSON Dict containing Blueprints and Synthesis is correct.
- Parameters
xdl_json (Dict[str, Any]) – XDL JSON loaded into dict, containing the keys “Bluprints” and “Synthesis”.
- Raises
XDLJSONError – Raises various subclasses of this error if the XDL JSON is not in the correct format.
- xdl.readwrite.json.validate_xdl_element_json(xdl_element_json: Dict[str, Any]) None [source]
Validate given xdl element from XDL JSON.
- Parameters
xdl_element_json (Dict[str, Any]) – XDL element dict from XDL JSON.
- Raises
XDLJSONMissingPropertiesError – XDL element JSON is missing “properties” parameter.
- xdl.readwrite.json.validate_xdl_json(xdl_json: Dict[str, Any]) None [source]
Validate XDL JSON Dict is correct format.
- Parameters
xdl_json (Dict[str, Any]) – XDL JSON loaded into dict.
- Raises
XDLJSONError – Raises various subclasses of this error if the XDL JSON is not in the correct format.
- xdl.readwrite.json.validate_xdl_step_json(step_json: Dict[str, Any]) None [source]
Validate given step from XDL JSON, recursively validating any child steps.
- Parameters
step_json (Dict[str, Any]) – Step dict from XDL JSON.
- Raises
XDLJSONMissingStepNameError – Step JSON is missing “name” parameter.
XDLJSONMissingPropertiesError – Step JSON is missing “properties” parameter.
- xdl.readwrite.json.xdl_element_from_json(xdl_element_json: Dict[str, Any], xdl_element_type: type) Union[xdl.reagents.Reagent, xdl.hardware.Component] [source]
Convert JSON XDL element dict to object of given type.
- Parameters
xdl_element_json (Dict[str, Any]) – XDL element dict from XDL JSON.
xdl_element_type (type) – Reagent or Component.
- Raises
XDLInvalidPropError – Invalid prop given to instantiate xdl element with.
- Returns
Instantiated Reagent or Component object.
- Return type
- xdl.readwrite.json.xdl_element_to_json(xdl_step: Union[xdl.reagents.Reagent, xdl.hardware.Component, xdl.parameters.Parameter]) Dict[str, Any] [source]
Convert XDL element to JSON format immediately useable by ChemIDE.
- Parameters
- Returns
XDL JSON format dict representing
xdl_step
.- Return type
Dict[str, Any]
- xdl.readwrite.json.xdl_from_json(xdl_json: Dict[str, Any], platform: xdl.platforms.abstract_platform.AbstractPlatform, context: xdl.context.Context) Dict[str, Any] [source]
Convert JSON XDL format dict to dict containing all data necessary for initialising XDL object.
- Parameters
xdl_json (Dict[str, Any]) – XDL JSON loaded into dict.
platform (AbstractPlatform) – Platform to use when constructing XDL object.
- Returns
- Dict containing all data necessary for instantiating
XDL object. Format is the following:
{ "steps": steps, "reagents": reagents, "hardware": hardware, "parameters": parameters, }
- Return type
Dict[str, Any]
- xdl.readwrite.json.xdl_from_json_file(xdl_json_file: str, platform: xdl.platforms.abstract_platform.AbstractPlatform, context: xdl.context.Context) Dict[str, Any] [source]
Convert .json file with JSON XDL format to dict containing all information necessary to initialise a XDL object.
- Parameters
xdl_json_file (str) – Path to XDL JSON file.
platform (AbstractPlatform) – Platform to use when constructing XDL object.
- Returns
- Dict containing all information necessary to initialise
a XDL object. Format is the following:
{ "steps": steps, "reagents": reagents, "hardware": hardware, }
- Return type
Dict[str, Any]
- xdl.readwrite.json.xdl_step_from_json(step_json: Dict[str, Any], platform: xdl.platforms.abstract_platform.AbstractPlatform, context: xdl.context.Context, blueprints: Dict[str, Any]) xdl.steps.core.step.Step [source]
Convert JSON XDL format step Dict to Step object.
- Parameters
step_json (Dict[str, Any]) – Step dict from XDL JSON to convert to Step object.
platform (AbstractPlatform) – Platform to use when finding step class to initialise.
- Raises
XDLInvalidPropError – Invalid prop used in
step_json
.XDLInvalidStepTypeError – Invalid step type in
step_json
.
- Returns
Step object loaded from XDL JSON step.
- Return type
- xdl.readwrite.json.xdl_step_to_json(xdl_step: xdl.steps.core.step.Step, full_properties: bool = False) Dict[str, Any] [source]
Convert XDL Step to JSON format immediately useable by ChemIDE.
- Parameters
xdl_step (Step) – XDL step to convert to XDL JSON format.
full_properties (bool) – If
True
include all properties regardless of whether they are internal properties or the same as the default properties.
- Returns
XDL JSON format dict representing
xdl_step
.- Return type
Dict[str, Any]
- xdl.readwrite.json.xdl_to_json(xdl_obj: XDL, full_properties: bool = False) Dict[str, Any] [source]
Convert XDL object to JSON format immediately useable by ChemIDE.
- Parameters
xdl_obj (XDL) – XDL object to convert to XDL JSON.
full_properties (bool) – If True include all properties regardless of whether they are internal properties or the same as the default properties.
- Returns
XDL JSON dict produced from
xdl_obj
.- Return type
Dict[str, Any]