How to pass parameters to cloud code (Triggered by sdk) with `py-skygear --subprocess


Here is the code I’d like to test with py-skygear --subprocess:

def get_all(txt):  
     return {
          "status": txt

So far I’ve been able to get this far:

py-skygear --subprocess op test

But of course it returns an error:

TypeError: get_all() missing 1 required positional argument: 'txt'
{"error": {"message": "get_all() missing 1 required positional argument: 'txt'", "code": 10000, "info": {"trace": "Traceback (most recent call last):\n  File \"/home/clive/.envs/skygear/lib/python3.6/site-packages/skygear/transmitter/\", line 40, in wrapper\n    return dict(result=f(self, *args, **kwargs))\n  File \"/home/clive/.envs/skygear/lib/python3.6/site-packages/skygear/transmitter/\", line 100, in call_func\n    return self.op(obj, param.get('args', {}))\n  File \"/home/clive/.envs/skygear/lib/python3.6/site-packages/skygear/transmitter/\", line 174, in op\n    return func(*args, **kwargs)\nTypeError: get_all() missing 1 required positional argument: 'txt'\n"}}}%


I’ve also asked this on your slack channel and via email


@cmosh Thanks for your question. I’m sorry the documents you found about using exec to run lambda / other Cloud Functions are obsoleted. You should set up both skygear-server and py-skygear to test it from end to end.

We will have a new skycli sub-commands coming for the purpose of testing lambda functions.


That’s okay I’ve been testing end to end for a while now and it’s extremely tedious, I just thought it would be faster and simpler before needing to starting up multiple docker images


icic. Sorry about that. In my experience it will definitely help to have a docker-compose file for your project (and share it amongst project team members) to simplify the multiple docker setup.


I’m using docker compose but it’s really clunky because if I crash py-skygear with a syntax error for example, the sky gear server also needs to be restarted, plus adding functions requires restarting the skygear server. So it is not a productive work flow


Understood. I have create an issue for it.


Thank you so much for this, it will make life much easier in the future. I really appreciate you taking your time on this.