Closed louislefevre closed 3 years ago
Hey Louis,
Great work on the script
node, thank you!
Very happy about how simple the 'saving' feature is!
However, I have a concern about the script
node.
I never thought about using it as a debug feature by connecting it to various nodes in the circuit but I think that is a great idea, good initiative!
The issue with this design is the fact that we cannot expect a certain number of qubits before running the script code because the node could be connected to any number of nodes, depending on what the user is debugging...
To illustrate the issue, if the node sits at the end of the circuit to output the full script, it will output the script as soon as it receives the 1st qubit, while the rest of the qubits could still have a few more gates to flow through... In this situation, the user will never be able to output the full script, except if he works out the last qubit to arrive and connects the node to this specific qubit, but I don't think this is user-friendly at all.
At the beginning of the simulator
node, there is a whole code block that's quite complex, just for this purpose of 'waiting' for all the qubits in the circuit. This code could be copy-pasted to the script
node and should work there.
That would mean losing the debug feature... Not sure if we can include both features at the same time...
Purpose
A simple node for outputting the state of the Python script at the time of execution. This node can be particularly useful for debugging, as it makes it easy to view the script at various points throughout a flow.
A script node can be hooked up at various points in a flow and it will output the state of the script at the time the input node finishes. As in, when a node finishes executing it will trigger the script node, which then returns the script as output.
As shown in the image below, a script node is linked to the hadamard and measure nodes. As each node finishes executing the script node is triggered, which displays the state of the script at that point in the flow. As seen, the first output is the script with only hadamard gates, whereas the second also has the measurements.
The second script node (at the end of the flow) shows how the script can be sent to a file. In this example the script is sent to the file node, which saves the script to a file of the users choosing. This is one of the standard nodes for Node-RED, so all users will be able to easily save the script by default without needing to install nodes from other libraries.
Changes