IPython kernel development: kernel_info_reply is ineffective on code highlighting - ipython

When I was testing a custom IPython kernel for Spark (https://github.com/tribbloid/ISpark)
The code highlighting and comment line shortcut don't work despite that both block metadata and websocket communication shows that kernel_info_reply is received:
metadata:
{
"kernelspec": {
"name": "spark",
"display_name": "ISpark",
"language": "Scala"
},
"language_info": {
"mimetype": "text/x-scala",
"file_extension": "scala",
"version": "2.10.4",
"name": "Scala",
"codemirror_mode": "Scala"
}
}
websocket message received:
{"parent_header": {"username": "username", "session": "1E1A0C0BD7B848D5874427164D5A6407", "version": "5.0", "msg_id": "393B1AED65C34EDA9DB6B0CACAB1DA03", "msg_type": "kernel_info_request"}, "msg_type": "kernel_info_reply", "msg_id": "44558c0a-5a49-469a-b55a-9032fa10ee5b", "content": {"implementation": "iSpark", "protocol_version": "5.0", "language_info": {"mimetype": "text/x-scala", "file_extension": "scala", "version": "2.10.4", "name": "Scala", "codemirror_mode": "Scala"}, "implementation_version": "0.2.0", "banner": "welcome to Spark version 1.3.1"}, "header": {"username": "username", "session": "1E1A0C0BD7B848D5874427164D5A6407", "version": "5.0", "msg_id": "44558c0a-5a49-469a-b55a-9032fa10ee5b", "msg_type": "kernel_info_reply"}, "channel": "shell", "buffers": [], "metadata": {}}
I also notice an anomaly that used to be harmless, a warning was logged when the kernel is launching:
[W 15:07:03.310 NotebookApp] Timeout waiting for kernel_info reply from 9ce0a466-2bbb-48c6-99a1-5211a207f81a
It may be related to https://github.com/ipython/ipython/pull/6793, but according to the issue tracker such problem won't exist as long as the metadata is correct.
What are the likely causes of this error and how to fix it?

Related

VSCode problemmatcher regex not matching my error output

I am trying to match errors of this format for the VSCode ProblemMatcher...
C:\projects\folder\main.cpp(6) : Error[AA000]: identifier "level2" is undefined
C:\projects\folder\main.cpp(7) : Error[AA000]: identifier "level3" is undefined
With regex101.com I am able to match what I need with this regex...
^([][{} \t#%$~A-Za-z0-9_:+\.-\\]+)\(([0-9]+)\) (:) (Warning|Error)(.*)$
Alas, when put into my tasks.json file with the (hopefully) correct escape slashes I don't receive any output in the Problems tab after running the task that will generate these errors in the terminal of VSCode.
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build simple regex",
"type": "shell",
"command": "iarbuild iar_ewb_build_timer.ewp -make Debug -log errors -parallel 8",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"fileLocation": "absolute",
"pattern": {
"regexp": "^([][{} \\t#%$~A-Za-z0-9_:+\\.-\\\\]+)\\(([0-9]+)\\) (:) (Warning|Error)(.*)$",
"file": 1,
"line": 2,
"severity": 4,
"message": 5
}
}
},
]
}
Perhaps there is a problem with my Regex. Any help?
I was able to get this working for example error codes in my original post. Thank you for the replies!
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build simple regex",
"type": "shell",
"command": "iarbuild iar_ewb_build_timer.ewp -make Debug -log errors -parallel 8",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"fileLocation": "absolute",
"pattern": {
"regexp": "^([#%$~A-Za-z0-9_:+-\\\\]+)[(]([0-9]+)[)] (:) (Warning|Error)(.*)$",
"file": 1,
"line": 2,
"severity": 4,
"message": 5
}
}
},
]
}

Require build to Contain Unit tests VSTS

I have 1 question
We use VSTS in our company. Now I want to require my developers to write unit tests to each project
My question is: If I can to build in Team Service Web Portal to require contain Unit tests, and if project doesn't has any unit tests - set build fail?
Thank you.
You can add a PowerShell task to check if the build project contains unit tests. Detail steps as below:
Add a PowerShell task after VS test task, and get VS test build log by timeline REST API. For TFS the rest api format should be:
GET http://{tsserver}:8080/tfs/{collection}/{project}/_apis/build/builds/{buildId}/timeline?api-version=3.0
Then search the log for VS test task, and you can get the detail VS test build log by the url. Such as below example, VS test task build log can be find in http://wxv-xindo-12r2:8080/tfs/DefaultCollection/5dfb8b33-9949-4187-9d09-474c8fe87238/_apis/build/builds/1477/logs/5.
{
"id": "c43e4f8f-3db9-4fdc-90c0-1153f165b9a9",
"parentId": "39d66172-979a-46e8-a04d-fe8e4e77da43",
"type": "Task",
"name": "Test Assemblies",
"startTime": "2018-05-25T02:31:11.177Z",
"finishTime": "2018-05-25T02:31:17.133Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 17,
"lastModified": "0001-01-01T00:00:00",
"workerName": "mypc",
"order": 5,
"details": null,
"errorCount": 0,
"warningCount": 2,
"url": null,
"log": {
"id": 5,
"type": "Container",
"url": "http://tfsserver:8080/tfs/DefaultCollection/5dfb8b33-9949-4187-9d09-474c8fe87238/_apis/build/builds/1477/logs/5"
},
"task": {
"id": "ef087383-ee5e-42c7-9a53-ab56c98420f9",
"name": "VSTest",
"version": "2.0.55"
},
"issues": [
{
"type": "warning",
"category": "General",
"message": "",
"data": {
"type": "warning",
"code": "002004"
}
},
{
"type": "warning",
"category": "General",
"message": "No test assemblies found matching the pattern: **\\release\\*test*.dll,!**\\obj\\**.",
"data": {
"type": "warning"
}
}
]
}
Then check if the VS test task has the warning:
[warning]No test assemblies found matching the pattern: '**\*test*.dll;-:**\obj\**'
If the VS test build log contains above warning, fail the PowerShell task by exit 1.

Multiple VMExtensions per handler not supported for OS type 'Linux

I have created Azure VM using ARM template. Now I want to install Java and Mongodb on Azure VM.
When I try to use Multiple CustomScript, I get the following error.
Multiple VMExtensions per handler not supported for OS type 'Linux
Below are my configuration:-
parameters:-
"javaPackageName": {
"type": "string",
"defaultValue": "openjdk-7-jdk",
"allowedValues": [
"openjdk-6-jdk",
"openjdk-7-jdk",
"openjdk-8-jdk"
]
},
"tomcatPackageName": {
"type": "string",
"defaultValue": "tomcat7",
"allowedValues": [
"tomcat6",
"tomcat7",
"tomcat8"
]
}
variables:-
"mongoInstallCentos": "https:/..install-mongo.json"
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('virtualMachineName'),'/javainstall')]",
"apiVersion": "2015-05-01-preview",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": ["https://..java-tomcat-install.sh"],
"commandToExecute": "[concat('sh java-tomcat-install.sh',' ',parameters('javaPackageName'),' ',parameters('tomcatPackageName'))]"
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('virtualMachineName'),'/mongoinstall')]",
"apiVersion": "2015-05-01-preview",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": ["https://..mongo-install.sh"],
"commandToExecute": "sh mongo-install.sh"
}
}
},
Is there any solution use Multiple CustomScript in ARM template? Kindly help me to solve this.
Multiple VMExtensions per handler not supported for OS type 'Linux
Currently , it is not possible to run Multiple CustomScript Extensions at the deployment time.
According to your scenario, you can author an entry point script that calls the dependent scripts, then upload the entry point script, dependent scripts and any other dependent binaries to the script location(Azure storage blob or GitHub). More information please refer to this link.
Also, you could refer to this similar question.

"Error getting chaincode package bytes" when deploying chaincode on hyperledger via REST

I'm trying to deploy chaincode on hyperledger (Bluemix service) via POST/REST to
/chaincode
QuerySpec
{ "jsonrpc": "2.0", "method": "deploy", "params": { "type": 1,
"chaincodeID": { "path":
"https://github.com/romeokienzler/learn-chaincode/tree/master/finished"
}, "ctorMsg": { "function": "init", "args": [ "hi there" ] },
"secureContext": "user_type1_0" }, "id": 1 }
I've also tried those links
https://github.com/romeokienzler/learn-chaincode/blob/master/finished/chaincode_finished?raw=true
https://raw.githubusercontent.com/romeokienzler/learn-chaincode/master/finished/chaincode_finished.go
I always get
{ "jsonrpc": "2.0", "error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit
status 1'\npackage
github.com/romeokienzler/learn-chaincode/tree/master/finished: cannot
find package
'github.com/romeokienzler/learn-chaincode/tree/master/finished' in any
of:\n\t/usr/local/go/src/github.com/romeokienzler/learn-chaincode/tree/master/finished
(from
$GOROOT)\n\t/go/usercode/552962906/src/github.com/romeokienzler/learn-chaincode/tree/master/finished
(from
$GOPATH)\n\t/go/src/github.com/romeokienzler/learn-chaincode/tree/master/finished\n"
}, "id": 1 }
Any idea?
Considering that you are playing with Bluemix service, I assume you are following "Implementing your first chain code tutorial"
If your forked repository you will see instructions to use branch v1.0 for Bluemix Blockchain Services (link) IBM BMX Service is (still) using Fabric v0.5.
Once you have Registered with one of the available Enroll ID you should be able to deploy your chaincode using DeploySpec (note the path: "https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished")
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished"
},
"ctorMsg": {
"function": "init",
"args": [
"hi there"
]
},
"secureContext": "user_type1_0"
},
"id": 1
}
First of all deploy command should be changed to ( the value for path variable was changed):
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/romeokienzler/learn-chaincode/finished"
},
"ctorMsg": {
"function": "init",
"args": ["hi there"]
},
"secureContext": "user_type1_0"
},
"id": 1
}
P.S. As #Mil4n correctly mentioned, IBM Bluemix still works with Fabric v0.5. Chaincode romeokienzler/learn-chaincode/finished should be adopted to this version.
For example shim.ChaincodeStubInterface is not available yet and should be replaced with *shim.ChaincodeStub.

Watson Conversation+TTS

I am trying to develop a web application using Watson Conversation service and Watson TTS service. The conversation output is sent to the TTS service for conversion. I am doing this in NodeRED and also i have put a function node between conversation node and TTS node which assigns the payload. After deployment I am only getting the conversational dialog chatbot but not the speech as I am suppose to. Please help me figure out what am I missing?
*PS: I am using HTTP post and HTTP get for this.
I built a flow that works and you will need to install a node that can play audio. The text to speech node does not actually play any sound. It creates an audio file.
Go to the hamburger in the upper right of the node red editor. Look for Palette Manager. look for node-red-contrib-play-audio and install it. I assume you have node-red-bluemix-nodes already.
you will need a node to retrieve the input, I used an inject node for the test.
connect it to your conversation node. Double click it and put the Workspace ID. (it is on the workspace under the three dots in the upper right of each one. Copy that long string into your node. I used the default car tutorial.
connect that to a function node. I then have to move the response from the conversation from msg.payload.output.text[0] to msg.payload like so:
msg.payload = msg.payload.output.text[0];
return msg;
connect that to a text to speech node. Fill in any credentials, pick a voice and click the output to msg.payload. If you forget to do this then the audio node will actually read the text instead of using the text to speech node's voice. The audio node's voice is not great.
connect the play audio node.
That is it. You should have a working voice.
A good way to see what is going on is to use a debug node. This lets you see where content is flowing and drop in functions to redirect the output appropriately for each node.
Copy the code below and go into the hamburger and do an import from clipboard to a new flow. You will need to fill in appropriate passwords and workspace ids but this shows how it is working.
[{
"id": "b7b6d9fc.1997f8",
"type": "tab",
"label": "Flow 2"
}, {
"id": "d0ed4492.045c18",
"type": "inject",
"z": "b7b6d9fc.1997f8",
"name": "",
"topic": "",
"payload": "play the radio",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 159.5,
"y": 122,
"wires": [
["dc33249.3227bd8"]
]
}, {
"id": "dc33249.3227bd8",
"type": "watson-conversation-v1",
"z": "b7b6d9fc.1997f8",
"name": "",
"workspaceid": "",
"multiuser": false,
"context": true,
"default-endpoint": true,
"service-endpoint": "https://gateway.watsonplatform.net/conversation/api",
"x": 383.5,
"y": 121,
"wires": [
["d3c07b87.22f9c8"]
]
}, {
"id": "711b8067.a1c7",
"type": "debug",
"z": "b7b6d9fc.1997f8",
"name": "",
"active": true,
"console": "false",
"complete": "true",
"x": 751.5,
"y": 200,
"wires": []
}, {
"id": "9826b891.eb02b8",
"type": "watson-text-to-speech",
"z": "b7b6d9fc.1997f8",
"name": "",
"lang": "en-US",
"langhidden": "en-US",
"langcustom": "NoCustomisationSetting",
"langcustomhidden": "",
"voice": "en-US_MichaelVoice",
"voicehidden": "",
"format": "audio/wav",
"password": "",
"payload-response": true,
"default-endpoint": true,
"service-endpoint": "https://stream.watsonplatform.net/text-to-speech/api",
"x": 757.5,
"y": 64,
"wires": [
["ccf6f5a7.700508"]
]
}, {
"id": "d3c07b87.22f9c8",
"type": "function",
"z": "b7b6d9fc.1997f8",
"name": "",
"func": "msg.payload = msg.payload.output.text[0];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 561.5,
"y": 120,
"wires": [
["9826b891.eb02b8", "711b8067.a1c7"]
]
}, {
"id": "ccf6f5a7.700508",
"type": "play audio",
"z": "b7b6d9fc.1997f8",
"name": "",
"voice": "0",
"x": 963.5,
"y": 64,
"wires": []
}]
Here is a link to a sample flow that uses Text to Speech on an HTML page. Take that as your starter, and add in Conversation.
https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/text_to_speech
you need to provide more information about your problem.
anyway, one thing I've noticed is that text to speech generates a 44khz audio file. If you're running it locally in a RPI using some USB dongle, for example, it may not be able to play because it support by default 22Khz audio. So being able to play it locally also depends on the hardware and how the sound is configured in it.