How to create a jupyter-lab extension that interacts with a running kernel - jupyter

I am trying to create an extension for jupyter-lab that interacts with a running ipython kernel, running either in a console or a notebook.
As a minimal example I am trying to get two "hello world" type programs. The first should print a message to stdout of the running kernel that is input in the extension. The second should log a message to the console of the extension that is input in the running ipython kernel.
To understand jupyter-lab extension I started with the astronomy picture of the day! tutorial. Although this covers the basics of extensions this does not address interacting with a running kernel.
From "really confused with jupyter notebook lab extensions and ipywidgets"! it seems I should be looking at the Comms module however this is documentation for Jupyter-notebook and not for Jupyter-lab. As far as I understand, Jupyter-lab is sufficiently different under the hood that this should not work.
Could someone explain to me how to create an extension that interacts with a running kernel and what the appropriate documentation/tutorial is to look at if it exists?

Related

Debugging Azure IoT Edge modules using Visual Studio Code

I can't get local debug of IoT Edge modules working on VS Code, but part of the problem could be that I don't understand what I'm doing in the steps.
I'm following the Microsoft guide here. Can anyone explain to me when I run the command "Azure IoT Edge: Start IoT Edge Hub Simulator for Single Module" in VS Code, why do I need to pass an "input name"? Why doesn the simulator need to know this. I've got multiple input commands on my edge module and the fact I need to pass it is making me question what the simulator actually does. I want to be able to debug multiple inputs.
Also on the same documentation, I can't see how it defines which module I want to run in the simulator. Am I missing something or is the process confusing?
When you Start the IoT Edge Hub Simulator for a Single Module, you spawn two Docker containers. One is the edgeHub and the other is a testing utility. The testing utility acts as a server that you can send HTTP requests to, the requests specify the input name and the data. You can use this to send messages to various inputs on your module. Just looking at that, I understand why it is confusing to supply the input name to the simulator. But when you inspect the edgeHub container, you'll see the following environment values being passed:
"routes__output=FROM /messages/modules/target/outputs/* INTO BrokeredEndpoint(\"/modules/input/inputs/print\")",
"routes__r1=FROM /messages/modules/input/outputs/input2 INTO BrokeredEndpoint(\"/modules/target/inputs/input2\")",
"routes__r2=FROM /messages/modules/input/outputs/foo INTO BrokeredEndpoint(\"/modules/target/inputs/foo\")",
"routes__r3=FROM /messages/modules/input/outputs/input1 INTO BrokeredEndpoint(\"/modules/target/inputs/input1\")"
Just like on a real device, you need routes to talk to your module. The edgeHub container registers these routes with the values you supplied during the starting of the simulator. That input can be a comma-separated list. So if you are using more inputs, feel free to supply them when you start the simulator. Under the covers, that command runs:
iotedgehubdev start -i "input1,input2,foo"
Note: when I was testing this with the latest VS Code Extension, the first time I ran it, the textbox contained: "input1,input2".

Can't launch gazebo simulation with my python code

I am using ROS Melodic in Ubuntu 16.04.
I am working with turtlebot 3 burger and trying out simulations on gazebo.
I have written a simple code to make the turtlebot move in a circle.
The code works perfectly as everything was working a couple of days ago.
Now when I try to launch it using
roslaunch assignment3_ws move.launch code:=circle
I get the following error:
ERROR: could not contact master [https://localhost:11311]
The traceback for the exception was written to the log file
I tried running it in every possible way.
With roscore, without roscore.
Even the network is setup properly in the bash file.
Can anyone provide a solution?
Have you changed the ROS_MASTER_URI environment variable to 192.168.1.162 ?
if you are using simulation and you need to set your ROS_MASTER_URI to localhost.
you only change ROS_MASTER_URI if you are trying to connect to remote ROS systems(Servers, other PCs, etc).

How do I get Robotframework (in Eclipse) to respond to terminal prompt

I'm currently running Robotframework in Eclipse on Windows 10 OS. I'm using an external python library that allows students and teachers to use this extracted library to connect to our hardware devices. I'm automating the extractions from the main site package made by our developers. If more than one device is plugged into the USB ports on the PC, then the code does the following:
x = input("Select one device:")
selected = int(x)
This causes a terminal prompt so the user has to type in a 0, or 1 for example, then hit the ENTER key. User response will allow the code to further process a connect to the selected device. Note, this prompt is not a GUI. So when I run Robotframework, it will execute the steps up to the point where it's prompting.
It seems like this should be pretty easy, but I can't seem to figure it out. Since you're inside a piece of code that's waiting for input, how do you make RobotFramework do something with it?
Edit: It occurs to me that maybe there's a way to execute a delayed Robotframework step that starts an external python command after a specified time, to throw a '0' and a RETURN key response. I had a python file made from an import of pynput.py library which appears to work from the command line execution (prints a 0, or a 1, and a return line feed). There's gotta be an easier way I'd think, but I don't know what it is.
Edit: Can I run a keyword from a listener that watches for the command prompt and the keyword runs another python file to feed the prompt? If I get this to work, then all I have to do is leave the devices on the USB port (or hub for that matter), and select the devices I want to do further testing on. Our devices are supported Blooth tooth as well but I need to run both USB and BLE tests to verify our Python extractions the teachers and students can use.
Edit: The other option is to use a software programmable hub and select the USB with a specific device on it, but I'm trying to avoid that.
OK, I solved it using Robotframework background process. I wrote a small python file that gets executed from the process. It has a 5 second timer (more than I need) and then Robotframework runs the next Test Case step. The Python file then does some keyboard presses, selecting the port and an ENTER key which goes out to the console (feeding the input prompt). It connects the sensor.
So in my Robotframework Test Case I do the following:
*** Test Case ***
smoke_test
Start process . Python . usbportselect
open usb
The Python program called from the process looks like this:
import time
import pynput
from pynput.keyboard import Key, Controller
keyboard = Controller()
def choose_usb(portvalue)
keyboard.press(portvalue)
keyboard.release(portvalue)
keyboard.press(Key.enter)
keyboard.release(Key.enter)
time.sleep(5)
choose_usb('0')
Note: I'm pretty sure this won't fix all the problems with using processes, but it's at least a start and a way to feed input to a prompt resulted from a future Test Case step

When an ipython console connect to an existing kernel linked to a notebook, %load magic can not load code into console

I learned this trick from Using IPython console along side IPython notebook . But when I connect this kernel using console, the %load magic will load file into a pager (like you you do 'man thecodefile.py' in console), not to the input line.
Anyone know how to change these behavior back to default?
You ask two question here, please ask them separately.
As for !su ausername there is no way to forward stdin through subprocess.

Start service in kernel mode (Vista)

I'd like to start service before user mode is loaded (in kernel mode).
The reason is I wanna run several system applications(asm code to write data to BIOS) that are not allowed in user mode (privileges problem).
That's why I got an idea: 1. Write windows service 2. Start and run it in kernel mode
Is it possible?
Are there any other ways to solve the problem?
I don't usually use Vista (use linux instead), that's why I'm asking.
Windows services are user-mode applications. To run in kernel-mode you should write a driver. (So-called "legacy" driver will be enough, see Driver Development Part 1: Introduction to Drivers).