research-virtualfortknox / msb-client-websocket-python Goto Github PK
View Code? Open in Web Editor NEWThe python client library to connect to the websocket interface of the MSB (Manufacturing Service Bus)
License: Apache License 2.0
The python client library to connect to the websocket interface of the MSB (Manufacturing Service Bus)
License: Apache License 2.0
Describe the bug
Tutorial project template in docs is not working.
Should be updated. Maybe use the app_sample.py.
To Reproduce
Try to execute the tutorial in the docs.
Expected behavior
Runnable MSB-Client.
Is your feature request related to a problem? Please describe.
Allowing the user to use a dataclass as event payload would allow reusability of code and simplification.
Describe the solution you'd like
The library should use reflection to parse the dataclasses provided by the user and generate its internal ComplexDataFormat on its own. This would allow a more streamlined usage as in the java client implementation.
I'm submitting a ...
Current behavior:
we can't publish an event directly after the register function:
myMsbClient.register()
myMsbClient.publish(
"E1",
'Test Event',
2)
unless we define a timeout before publishing the event like below:
myMsbClient.register()
time.sleep(10)
myMsbClient.publish(
"E1",
'Test Event',
2)
Expected behavior:
we should be able to publish a defined event immediately after registering our client with MSB.
myMsbClient.register()
myMsbClient.publish(
"E1",
'Test Event',
2
)
Steps to reproduce:
I defined a MSB client and set EventCache atrribute to False value as below:
myMsbClient.disableEventCache(False)
myMsbClient.connect(msb_url)
myMsbClient.register()
and after defining an event and a responding function we want to publish an event, but we notcied that publishing the event directly after the register function is not working at all and we don't get a IO_PUBLISHED response from the MSB. therefore we had to set a time out in order to publish the event after registering the client.
The code below shows an example:
myMsbClient.register()
time.sleep(10) # without this instruction we don't get IO_PUBLISHED response
event_id = "E1"
event_value = 'Rawad Test Event'
event_priority = 2
myMsbClient.publish(
"E1",
'Rawad Test Event',
2
)
MSB client version: x.y.z
MSB server version: x.y.z-RELEASE
Anything else:
I'm submitting a ...
Current behavior:
The msb client crashes at getSelfDescription() when a function callback is bound to a object instance instead of a global method. Hence no registration to the MSB is possible.
Expected behavior:
There should be no difference using static methods as callbacks or methods bound to an object (non-static).
Steps to reproduce:
SERVICE_TYPE = "SmartObject"
SO_UUID = str(uuid.uuid1())
SO_NAME = "MSBClientPythonAppSample" + SO_UUID[-6:]
SO_DESCRIPTION = "MSBClientPythonAppSample description"
SO_TOKEN = SO_UUID[-6:]
myMsbClient = MsbClient(
SERVICE_TYPE,
SO_UUID,
SO_NAME,
SO_DESCRIPTION,
SO_TOKEN,
)
class myClass():
def myMethod(self,msg):
print(str(msg))
myMsbClient = MsbClient(SERVICE_TYPE, SO_UUID,SO_NAME,SO_DESCRIPTION,SO_TOKEN,)
myInstance = myClass()
myFunction = Function("FUNCTION2",
"Function2",
"Function2_description",
DataType.STRING,
myInstance.myMethod,)
myMsbClient.addFunction(myFunction)
print(myMsbClient.objectToJson(myMsbClient.getSelfDescription()))
# Or call myMsbClient.register() to call getSelfDescription indirectly
File "c:\Users\xx\Downloads\msb-client-websocket-python\test.py", line 56, in <module>
print(myMsbClient.objectToJson(myMsbClient.getSelfDescription()))
File "c:\Users\xx\Downloads\msb-client-websocket-python\msb_client\MsbClient.py", line 819, in getSelfDescription
del f["implementation"]
KeyError: 'implementation'
MSB client version: 1.0.2
Anything else:
The issue is related to the jsonpickle library, especially jsonpickle.encode(). Static method delegates get added to the json-tree with the value "None" whilst object bound methods don't get added to the json tree at all. The key error occurs since the "implementation" (= method delegate) is not found in the json tree when using object bound methods. The following example illustrates the behaviour that only the static method delegate gets pickled:
class myClass():
def myMethod(self,msg):
print(str(msg))
@staticmethod
def myStaticMethod(parameter_list):
pass
def __init__(self):
self.myMethodDelegate = self.myMethod
self.myMethodStaticDelegate = myClass.myStaticMethod
myInstance = myClass()
print(jsonpickle.encode(myInstance, unpicklable=False))
# prints { "myMethodStaticDelegate": null }
Possible fix: Check for the existence of the "implementation" key in the cloned object and remove the key only when its present.
Additional remark: Bound methods work out of the box in python with the msb client. This can be seen when calling the implementation directly (usually gets called from the websocket callback):
myMsbClient.functions["FUNCTION2"].implementation("test")
The MSB supports, besides the two service types offered by this project (SmartObject, Application), the service type Gateway. This allows to register a service with sub services managed by it and to handle their communication.
This feature is already supported by the msb-client-websocket-java lib.
I'm submitting a ...
Current behavior:
The application.properties is loaded from the current working directory:
config = open("application.properties", "r")
This works in most cases, but in edge cases like ROS the working directory is not set properly for the current node.
Expected behavior:
The user should be able to provide a path where the application.properties are stored. Otherwise the file should be searched in the working directory.
MSB client version: 1.0.2
I'm submitting a ...
Current behavior:
Client crashed for msb 1.5.0 - 1.5.3 due to missing correlation id support
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\site-packages\msb_client\MsbClient.py", line 157, in on_message
jmsg["functionParameters"]["correlationId"] = jmsg["correlationId"]
Expected behavior:
If server does not send a correlationId, do not add it to function params.
MSB client version: 1.0.4
MSB server version: x1.5.0-RELEASE
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.