Hi all,
Is there any interest in a RESTful interface to Maya?
The idea would be to facilitate external access of Maya from things like Web Applications or externally running GUIs.
I mocked up a minimal example of how it could look here:
# List all nodes
import requests
print requests.get("http://127.0.0.1:6000/node").text
The Demo includes an externally running QML application.

What would be the benefits of something like this over the native commandPort or ZeroMQ and c/o?
Thoughts?
Best,
Marcus
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODWwbwoQyVE1o_f0LvcC2DF%3Dfv1bCVA8vznHet8wqBy%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA19RLh1KavB%2BLg_CeBaSeR58FwaEXrh9gkQXUiy34Fc%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODNC%2BGV0Qu61aiLB9K5sPqv7en6%3DZbx3Op_o%2B3Dj0rZ1Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACt6Gr%3DxHYeT0P9zudhWi9c9UFDTVXU%2BfVSgjco12AgJ8J0h8w%40mail.gmail.com.
I remember long ago, i maya there where an web interface, where you could pass commands from the
web browser, cant remember well, but was something like mel:// and your command.
That’s interesting! Looks like it’s still going.
Haven’t heard nor tried that, but I’ll have to give it a go.
Is there any easy - open source -tool to do those “screen captures turned into gif” you usually post?
I’m sure Google would have a better answer for you, but if you ain’t got Photoshop to do Save for Web.. then there’s also FFMpeg that can supposedly do similar things; although from what I gather you’ll need to first convert your videos to images and then to .gif.
I have been using redis for my application communications.
Hi Damon, thanks for sharing.
Redis is a message queue/broker much like ZeroMQ and has similar advantages and disadvantages. One of the reasons not to go with ZeroMQ or Redis is their binary requirements - Redis requiring an externally running server and ZeroMQ requiring binaries especially compiled for Maya; per version of Python.
What is nice is that it allows back and forth communications, not just 1-way.. Makes it so I am not completely stuck with just Maya’s versions of python and Qt. I can even execute commands in other open mayas on the network.
That is quite useful, however the same is true for any type of inter-process communication; including HTTP calls. It’s called brokerless messaging.
To summarize; HTTP communication:
Whereas a message queue requires an initial setup, and in the case of Redis, a central broker.
I may even be so bold as to claim that the only real benefit of an MQ is performance; however as Python is only capable of producing a certain amount of information per second, that benefit may never actually surface. Thoughts?
It sounds like the RESTful interface would serve a very specific purpose as opposed to a more open solution.
I’d love for you to elaborate on this. What does “open” mean, if not standardized HTTP calls following a widely used architectural pattern like REST? And in what way does it strike you as specific?
Thanks again!
Best,
Marcus
Runs natively in any language that supports HTML
Sorry, I meant HTTP.
On Tue, 4 Nov 2014 7:13 AM Marcus Ottosson <konstr...@gmail.com> wrote:
I remember long ago, i maya there where an web interface, where you could pass commands from the
web browser, cant remember well, but was something like mel:// and your command.
That’s interesting! Looks like it’s still going.Haven’t heard nor tried that, but I’ll have to give it a go.
Is there any easy - open source -tool to do those “screen captures turned into gif” you usually post?
I’m sure Google would have a better answer for you, but if you ain’t got Photoshop to do Save for Web.. then there’s also FFMpeg that can supposedly do similar things; although from what I gather you’ll need to first convert your videos to images and then to .gif.
I have been using redis for my application communications.
Hi Damon, thanks for sharing.Redis is a message queue/broker much like ZeroMQ and has similar advantages and disadvantages. One of the reasons not to go with ZeroMQ or Redis is their binary requirements - Redis requiring an externally running server and ZeroMQ requiring binaries especially compiled for Maya; per version of Python.
Redis is a key-value database. It happens to have messaging added on. It's initial intent is high throughput persistent storage. It also offers a number of data types like sets and maps.
It is also possible to find pure python client libraries for ZeroMQ and Redis.
What is nice is that it allows back and forth communications, not just 1-way.. Makes it so I am not completely stuck with just Maya’s versions of python and Qt. I can even execute commands in other open mayas on the network.
That is quite useful, however the same is true for any type of inter-process communication; including HTTP calls. It’s called brokerless messaging.To summarize; HTTP communication:
Supports bi-directional communicationRuns natively in any language that supports HTML; which includes Python, but also JS and C# and so on.
bi-directional? Is your httpserver making requests to your httpclient? Usually with http, a client makes a requests and waits for a response.
Whereas a message queue requires an initial setup, and in the case of Redis, a central broker.
Yes. Redis is a database, so it allows for persistent storage, regardless of how fast Maya can consume from it
I may even be so bold as to claim that the only real benefit of an MQ is performance; however as Python is only capable of producing a certain amount of information per second, that benefit may never actually surface. Thoughts?
Durability.
Also I don't know what your bold claims are based on. Do you have anything to back up your claim that python cannot produce enough data to see any benefit from a TCP or Unix sockets connection, vs an httpinterface?
It sounds like the RESTful interface would serve a very specific purpose as opposed to a more open solution.
I’d love for you to elaborate on this. What does “open” mean, if not standardized HTTP calls following a widely used architectural pattern like REST? And in what way does it strike you as specific?
What I think is being said here, is the same as what I was stating. While someone may have a specific use case to expose a Restful interface for their application, I don't think it would be as useful to have a completely generic restful implementation of the Maya commands api. It sounds like you were asking if anyone would find that useful. But if you are asking if Restful interfaces into application are useful, then yes.
Thanks again!Best,
Marcus
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA6Lde7ce63zRxLdfF%2BV3O9rfAMnoxmA%3D2Bt65pvuCJ8g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1Rqfbtknyw1i6DaJR%2BLBE9RPKmrmSO2P%3Db%3D73aSasfFA%40mail.gmail.com.
bi-directional? Is your http/server making requests to your http/client? Usually with http, a client makes a requests and waits for a response.
Mhm. The client can also be a server. That way, they both expose interfaces towards each other that they call upon.
It is also possible to find pure python client libraries for ZeroMQ and Redis.
For ZeroMQ, that would be amazing. For Redis, I think you would still need the binary server. Could you share a link for the pure-python ZMQ? Thanks!
Do you have anything to back up your claim that python cannot produce enough data to see any benefit from a TCP or Unix sockets connection, vs an httpinterface?
I take it back!
I don’t think it would be as useful to have a completely generic restful implementation of the Maya commands api
I imagined the interface to lean more towards a general access to Maya; like modifying, creating and deleting nodes, regardless of which API is being used from within Maya - be it maya.cmds or OpenMaya.
But if you are asking if Restful interfaces into application are useful, then yes.
Specifically, a Restful interface into Maya.
Given that it doesn’t look like a popular idea (!) let me elaborate a little further. At the moment, I could share a tool with you that uses PyMEL. Because it uses PyMEL, it’ll work on my version of Maya, but also yours, and everyone elses. The tool is distributable and standalone.
Now, imagine that I built a tool that doesn’t uses maya.cmds, but also ZeroMQ or Redis. For you to use now, you’ll need these libraries too. In the case of Redis, I’d have to ask you to also install a central broker somewhere and configure it, and in the case of ZMQ, I’d ask you to do some compiling.
What I’d imagine for something like RestMEL is for a similar integration as PyMEL, making tools built externally distributable and standalone.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1Rqfbtknyw1i6DaJR%2BLBE9RPKmrmSO2P%3Db%3D73aSasfFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
but not just a set focused entirely on Maya.
The coupling with Maya would be similar to that of maya.cmds. It’s a means for accessing Maya from within Maya. RestMEL would be the very same, but for access from the outside.
In that way, it may make for a better companion in integration with other application, if you do in fact design software to run externally. Rather than utilising maya.cmds or PyMEL, your Maya integrations would use RestMEL.
bi-directional? Is your http/server making requests to your http/client? Usually with http, a client makes a requests and waits for a response.
Mhm. The client can also be a server. That way, they both expose interfaces towards each other that they call upon.
It is also possible to find pure python client libraries for ZeroMQ and Redis.
For ZeroMQ, that would be amazing. For Redis, I think you would still need the binary server. Could you share a link for the pure-python ZMQ? Thanks!
Do you have anything to back up your claim that python cannot produce enough data to see any benefit from a TCP or Unix sockets connection, vs an httpinterface?
I take it back!
I don’t think it would be as useful to have a completely generic restful implementation of the Maya commands api
I imagined the interface to lean more towards a general access to Maya; like modifying, creating and deleting nodes, regardless of which API is being used from within Maya - be it maya.cmds or OpenMaya.
But if you are asking if Restful interfaces into application are useful, then yes.
Specifically, a Restful interface into Maya.
Given that it doesn’t look like a popular idea (!) let me elaborate a little further. At the moment, I could share a tool with you that uses PyMEL. Because it uses PyMEL, it’ll work on my version of Maya, but also yours, and everyone elses. The tool is distributable and standalone.
Now, imagine that I built a tool that doesn’t uses maya.cmds, but also ZeroMQ or Redis. For you to use now, you’ll need these libraries too. In the case of Redis, I’d have to ask you to also install a central broker somewhere and configure it, and in the case of ZMQ, I’d ask you to do some compiling.
What I’d imagine for something like RestMEL is for a similar integration as PyMEL, making tools built externally distributable and standalone.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCGQykA08Bfoyh58ywHoU%2BWTC8nDUfSZ7OkhgUSbNOxTQ%40mail.gmail.com.
That is just two connections, bound on each side with different ports. Not bi-directional communication.
What I meant was, the tool can talk to Maya, and Maya can talk to the tool, with both a message queue and HTTP requests.
I havent researched either of these.
Did you just google those? :)
I still wonder if it would cover the same bases to just have a simple http interface that accepts a predefined json structure and dynamically executes your commands, instead of mapping all of the routes to cover the entire api.
That is true.
Now with the disadvantages at bay, what advantages, if any, can be found?
Best,
Marcus
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0YzW6JsSaCiJ4hVMufLYHfFyDWFsYZmZEspxjsd%2BOGtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo_%3DDDh3%3DGyKz3SR%3D9D8f5LMpdMBFuUm4rxRi%3DgT6b-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
That is just two connections, bound on each side with different ports. Not bi-directional communication.
What I meant was, the tool can talk to Maya, and Maya can talk to the tool, with both a message queue and HTTP requests.
I havent researched either of these.
Did you just google those? :)
I still wonder if it would cover the same bases to just have a simple http interface that accepts a predefined json structure and dynamically executes your commands, instead of mapping all of the routes to cover the entire api.
That is true.
Now with the disadvantages at bay, what advantages, if any, can be found?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo_%3DDDh3%3DGyKz3SR%3D9D8f5LMpdMBFuUm4rxRi%3DgT6b-w%40mail.gmail.com.
Have you tried using Twisted?
This is probably a little off-topic, as it is my understanding that Twisted merely offers an event loop and even though it’s intended for interprocess communication (read “web”) it doesn’t actually offer any of that on it’s own but is instead used together with other solutions, such as websockets like in the case of the article you posted.
Here’s another question.
For communicating with Maya externally, is anyone using the commandPort? Why not?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ddzkN6gzWZ1qkK%3DNF7_E%3DE4SLONcSFXBTBiwhTGQaoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, 6 Nov 2014 2:34 AM Marcus Ottosson <konstr...@gmail.com> wrote:
Have you tried using Twisted?
This is probably a little off-topic, as it is my understanding that Twisted merely offers an event loop and even though it’s intended for interprocess communication (read “web”) it doesn’t actually offer any of that on it’s own but is instead used together with other solutions, such as websockets like in the case of the article you posted.
It's basically an asynchronous framework. So it provides solutions for doing the equivalent of what you might use threads or multiprocessing for in your app, as well as offering "twisted compatible" communication modules like sockets and web stuffs. Big paradigm shift to deal with, and a pain if you have never used it but you have to maintain someone's code that does use it. :-)
Here’s another question.For communicating with Maya externally, is anyone using the commandPort? Why not?
My MayaSublime plugin relies on the commandPort.
--
Marcus Ottosson
konstr...@gmail.com
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB7RH36t3hYaLhD%3D5eqtkL3O6CPfPijajzozT8NiDR59Q%40mail.gmail.com.
Thanks for this!
As it turns out, commandPort is very capable of most of RestMEL’s intended functionality, apart from an apparent security issue of exposing each Maya session to arbitrary and potentially harmful commands being executed; e.g. subprocess.call(["rm", "-r" "/"]), however security is possibly not an important-enough issue for it to be considered when choosing between something like RestMEL and a custom implementation.
More discussion here: http://forums.cgsociety.org/showthread.php?p=7927900
Summary here: https://github.com/abstractfactory/RestMEL/wiki
As such, there will be no further developments of RestMEL.
Best,
Marcus
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3tX5%2BEjeZnuYoAWPevCTE8MCgdDbcS%3DnhbPWNA5ABrZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
About the security issue, reference here:
Care should be taken regarding INET domain sockets as no user identification, or authorization is required to connect to a given socket, and all commands (including “system(…)”) are allowed and executed with the user id and permissions of the Maya user. The prefix flag can be used to reduce this security risk, as only the prefix command is executed. - http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/CommandsPython/commandPort.html
No such thing as pure python redis. It would be extremely slow. Redis-py is just a library which allows to talk to redis server from python. Redis is also gimped under windows.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/01ef5fdf-2046-4b63-9d07-e2f434ad9fb1%40googlegroups.com.