-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion for message types. #56
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through this, I had a lot of question, mainly on the openrpc stuff -- it seems curiously restricted in expressiveness, but probably that's because of lack of familiarity.
::: | ||
|
||
Any Component MAY offer ANY of the following methods. | ||
Components SHOULD offer ``shut_down``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about the optional methods. What happens if some component calls another one's shutdown
, but that is not implemented? Do we need some common fallback method? Do you get a not implemented error back or somesuch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you get a not implemented error back or somesuch?
jsonrpc has a "method not found" error defined.
I'm curious about the optional methods.
My reasoning is: There are some methods necessary, such that a Component fulfills it role (as a component, it has to be pingable), these are necessary.
Some features are nice to have, for example logging is not essential (maybe the Component does not have logging capabilities).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I realise why optional methods can be useful. We should have a clear approach how do deal with that optionality, though -- there are several possibilities (do we error? ignore? publish/discover/supply a list of implemented methods? how should the initiating party deal with that? ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Components MUST adhere to openRPC, therefore they MUST offer a "rpc.discover" methods, which tells about all the implemented methods (the output is exactly that, what is part of this PR).
- Should we include this method in the Components list (together with "pong")?
If you try to call a method, a Component does not have, you get an appropriate error.
So, you (as a user) can either query beforehand and use only methods present, or you can try a method name and handle the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include this method in the Components list (together with "pong")?
IMO, yes.
So, you (as a user) can either query beforehand and use only methods present, or you can try a method name and handle the error.
It's more a LECO implementor that has to deal with that. As we are designing for different implementations to talk to each other, I'm wondering if we should standardise the expectations around what happens with optional methods. The answer might as well be "no", or "use what rpc.discover
gives you as you see fit".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"no", or "use what rpc.discover gives you as you see fit".
That's my stance 😁
One informational note: I generated the json texts by calling the "rpc.discover" method (defined by openrpc) of the different Components, which returns (per definition) the methods of the (python) Components in openrpc json format. If I made mistakes in the pyleco components (type hinting) or if the |
Ah, that makes this clearer! Makes sense. |
In general, this RPC thing sometimes feels a little "inverted" to me somehow.... Coordinator A calls a method If A calls a method of B to tell B about A's details, that method would be something like So, inherently, I sometimes feel this mismatch between the names of commands, and those same names being method names in another object. I think it's an indication that the names or interfaces could be improved 😕 Mind you, this is not always the case -- a Coordinator calling an Actor's |
I agree. The most prominent (and simple) example is "ping": I send a ping message and expect a pong response.
I see your point. The Coordinator messages (regarding the directory) are the least obvious ones and require some collaboration. Maybe we can use names like (these are methods in Coordinator |
To store openRPC links globally, not in discussion:
|
Note to myself:
|
Co-authored-by: Christoph Buchner <[email protected]>
Yeah untangling this could be a bit tiresome, but clear names are worth it. I hope we manage to unify the "command"/"message" character with the "method" being called in most cases.
Maybe moving away from a simple
|
environment.yml
Outdated
@@ -7,3 +7,4 @@ dependencies: | |||
- sphinx=5.3.0 | |||
- sphinxcontrib-mermaid=0.8.1 | |||
- sphinx_rtd_theme=1.1.1 | |||
- sphinx-jsonschema=1.19.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get jsonschema to work. It still shows .. jsonschema:: filename.json
instead of the content...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never used it before. Maybe an unexpected interaction with myst parser?
Is the file path correct? Is the extension really loaded (such that the directive gets acted upon)? no idea otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an unexpected interaction with myst parser?
I commented the myst parser (and mermaid), but to no avail.
Is the file path correct?
Yes
Is the extension really loaded (such that the directive gets acted upon)?
At least it does not show any errors locally or in the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I even used the jsonschema in the rst file from: https://sphinx-jsonschema.readthedocs.io/en/latest/directive.html#usage
It does not work. I don't know 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it to work:
In an markdown file you have to use a colon fence:
:::{jsonschema}
your schema
:::
This does not work, however, for referencing files, only for showing a code snippet.
It does not render our schemata nicely 😭 (it does not render anything at all, as it does not recognize the keywords...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, some progress at least I guess? :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with the data-viewer, that works better (but does not allow examples...).
schemas/component_optional.json
Outdated
"schema": { | ||
"type": "integer", | ||
"multipleOf": 10, | ||
"minimum": 0, | ||
"maximum": 100 | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #56 (comment)
No, I mean the parameter of the method
"name": "level",
"schema": {
"type": "integer" "one-of-info/debug/warning/error/critical"
Idea is to change to a set of possible values. I don't know yet, how to define it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a way to define a set of possible values in json-schema ( "type": "integer", "enum": [1, 5, 9]
).
Now the question is, do we want to have error levels as an integer or as a string?
If an integer, how do we define it (copy and or link to the python definitions at https://docs.python.org/3/library/logging.html#logging-levels)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, for language (and logging-framework) independence, I think a fixed set of level names seems most clear (the python ones seem fine to me).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to strings.
"errors": [ | ||
{ | ||
"code": -32091, | ||
"message": "The name is already taken.", | ||
"data": "Already taken name." | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connect it to the error definition, lest this definition and the error list diverge.
I added examples to the dictionary methods to better understand how they work. |
Different idea to show json: https://github.com/useblocks/sphinx-data-viewer |
6e44556
to
12d4589
Compare
I noticed, that there is a "summary" field for a method, not only description. We should use that instead (in many cases). |
I added message types and error codes.
They are based on the current pyleco implementation pymeasure/pyleco#3
If you prefer looking at messages in python style, have a look here: https://github.com/pymeasure/pyleco/blob/add-core/pyleco/core/leco_protocols.py
As we follow openrpc, I figured, we should define the methods in openrpc style and not as python methods.
Closes #29
ToDo: