I like the idea. In particular, it would be very helpful in implementing an idea I had some time ago: deployment of Jupyter Notebooks as actions! (Here I refer to Python based notebooks mostly)
Normally you have some code in it that you develop (and test) interactively, but the problem is: what is the entry point? Of course, it would be a "main" action defined in it but it would be limiting. In this way, I could pass the entire notebook to the initialization of the action and then invoke the various functions defined in it. -- Michele Sciabarra [email protected] ----- Original message ----- From: Rodric Rabbah <[email protected]> To: [email protected] Subject: override main on activation? Date: Friday, March 15, 2019 5:58 AM When one creates an action today, they can specify the main entry point at creation time. For example: wsk action create myfn f.js --main foo This allows a single file with multiple functions to be used as different actions. But this is wasteful - one has to create multiple actions this way and we're paying the cost in the backend by replicating the code (in the database, and multiple code fetches). What if the main was specified on invoke instead? For example, take a web action from this file hello.js function niam(args) { return { 'greetings': 'Hello from a non-standard entrypoint.' } } function main(args) { return { 'greetings': 'Hello from a standard entrypoint.' } } We could allow main to be set on the action activation. > curl -k https://guest.localhost/default/hello.json { "greetings": "Hello from a standard entrypoint." } And now with an override to "main", using @<new main> as the new entry point. > curl -k https://guest.localhost/default/hello.json@niam { "greetings": "Hello from a non-standard entrypoint." } I created an issue to discuss the idea [1]. I'm thinking primarily to restrict this to web actions initially, although there are some extensions that are also reasonable to consider subsequently: 1. we could also make it work for POST invoke, namely wsk action invoke --main. 2. we can extend it to sequences so that you can create a sequence from fn@main1, fn@main2 3. we can further extend it to conductor continuations [1] https://github.com/apache/incubator-openwhisk/issues/4349
