Re: override main on activation?

2019-03-15 Thread Carlos Santana
 and then invoke the various functions defined in it.
> >
> > --
> >   Michele Sciabarra
> >   mich...@sciabarra.com
> >
> > - Original message -
> > From: Rodric Rabbah 
> > To: dev@openwhisk.apache.org
> > 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 @ 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
> >
>
>
> --
> Regards,
> James Thomas
>


-- 
Carlos Santana



Re: override main on activation?

2019-03-15 Thread James Thomas
This is an interesting idea. Lambda has a nice feature of being able to
create functions from an S3 file containing the source zip, which means you
don't have to upload the same code for each different function. Not having
something can make deployments unnecessarily long on OpenWhisk when you
have a large app with dozens of functions and large action packages.

If this was available - I wonder if there's a way to define an "action
clone" which is like a sym-link to another action with a different "main"
parameter (defined at create time)? It would allow us to upload the action
package once and then create sym-links for all the other actions. This
would dramatically speed up deployments and reduce the amount of code
needed to store in the backend.




On Fri, 15 Mar 2019 at 07:45, Michele Sciabarra 
wrote:

> 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
>   mich...@sciabarra.com
>
> - Original message -----
> From: Rodric Rabbah 
> To: dev@openwhisk.apache.org
> 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 @ 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
>


-- 
Regards,
James Thomas


Re: override main on activation?

2019-03-15 Thread Michele Sciabarra
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
  mich...@sciabarra.com

- Original message -
From: Rodric Rabbah 
To: dev@openwhisk.apache.org
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 @ 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


override main on activation?

2019-03-14 Thread Rodric Rabbah
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 @ 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