rigetti / rpcq

The RPC framework and message specification for @rigetti Quantum Cloud Services.
Apache License 2.0
75 stars 29 forks source link

Coerce *args to a VECTOR in PREPARE-RPC-CALL-ARGS #112

Closed appleby closed 4 years ago

appleby commented 4 years ago

Coerce positional args to a VECTOR in PREPARE-RPC-CALL-ARGS to ensure they are encoded as an array. This makes no difference when positional args exist since both non-empty LISTs and ARRAYs get encoded to messagepack array formats; if args is NIL, however, CL-MESSAGEPACK encodes NIL to a messagepack NIL format 0xc0, which gets decoded as None on the Python side. This results in an Exception being raised in RPCSpec.run_handler when attempting to decode the args since it expects *args to be an Iterable, not None.

The RPCQ lisp server was unaffected by this since messagepack NIL is decode to lisp NIL, and the lisp server only calls generic SEQUENCE processing functions (CONCATENATE) on the deserialized value, and hence doesn't distinguish between an empty LIST or ARRAY.

appleby commented 4 years ago

The upshot of this is that you can rpcq:rpc-call a nullary rpc method from a lisp client to a python server, whereas before this would result in an exception being raised on the python side.

I think it would also work to omit the *args key from hash-table entirely if there are no required args, but haven't tested it. I went with coercing NIL to #() since it seemed like a smaller change.

stylewarning commented 4 years ago

Won't merge until there's at least one other review.

notmgsk commented 4 years ago

So you're saying lisp is better than python?

                             A P P R O V E D