Skip to content

Conversation

revmischa
Copy link

Because app.cli.main is replaced by click.core.main (I don't know why)

Mischa Spiegelmock added 2 commits June 27, 2019 14:40
@codecov
Copy link

codecov bot commented Jun 27, 2019

Codecov Report

Merging #99 into master will decrease coverage by 0.4%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #99      +/-   ##
==========================================
- Coverage     100%   99.59%   -0.41%     
==========================================
  Files           5        5              
  Lines         492      491       -1     
  Branches       60       60              
==========================================
- Hits          492      489       -3     
- Misses          0        2       +2
Impacted Files Coverage Δ
wsgi_handler.py 96.87% <33.33%> (-3.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d30831...cab200f. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Jun 27, 2019

Codecov Report

Merging #99 into master will decrease coverage by 0.4%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #99      +/-   ##
==========================================
- Coverage     100%   99.59%   -0.41%     
==========================================
  Files           5        5              
  Lines         492      491       -1     
  Branches       60       60              
==========================================
- Hits          492      489       -3     
- Misses          0        2       +2
Impacted Files Coverage Δ
wsgi_handler.py 96.87% <33.33%> (-3.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d30831...cab200f. Read the comment docs.

@revmischa
Copy link
Author

I don't understand the test error here but it doesn't look related to my changes? https://travis-ci.com/jetbridge/serverless-wsgi/jobs/211630464#L717

@logandk logandk merged commit 17d9154 into logandk:master Jul 9, 2019
@logandk
Copy link
Owner

logandk commented Jul 9, 2019

Thanks for the PR! The failing test was fixed in e53c701

@revmischa
Copy link
Author

It's slightly improved but still broken. Need help.

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

I did a few additional changes on master. When testing your PR, it worked fine locally - but when deployed to Lambda, I'd see an error like:

Traceback (most recent call last):
  File "/var/task/wsgi_handler.py", line 95, in handler
    fg.main(shlex.split(meta.get("data", "")), standalone_mode=False)
  File "/var/task/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/var/task/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/var/task/click/core.py", line 1132, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/var/task/click/core.py", line 1188, in resolve_command
    ctx.fail('No such command "%s".' % original_cmd_name)
  File "/var/task/click/core.py", line 496, in fail
    raise UsageError(message, self)
click.exceptions.UsageError: No such command "testcommand".

I added the explicit create_app argument back in, which sorted it out.

Do you see anything else that's not working properly on master?

@revmischa
Copy link
Author

i'll try master now. i was able to get to the point where custom and built-in commands worked on local, but custom didn't work on lambda, i think. something like that.

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

Alright - I tried both custom and built-in commands, locally and remotely. Let me know if it works out for you too.

@revmischa
Copy link
Author

pulled master, linked it, deployed.

sls wsgi flask local -c routes - works

sls wsgi flask -c routes -

  Error --------------------------------------------------
 
  Invoked function failed
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error: Invoked function failed
    at AwsInvoke.log (/Users/cyber/.config/yarn/global/node_modules/serverless/lib/plugins/aws/invoke/index.js:97:31)
From previous event:
    at Object.invoke:invoke [as hook] (/Users/cyber/.config/yarn/global/node_modules/serverless/lib/plugins/aws/invoke/index.js:22:10)
    at /Users/cyber/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:448:55
From previous event:
    at PluginManager.invoke (/Users/cyber/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:448:22)
    at PluginManager.run (/Users/cyber/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:479:17)
    at /Users/cyber/dev/jb/serverless-wsgi/index.js:472:12
    at ServerlessWSGI.invokeHandler (/Users/cyber/dev/jb/serverless-wsgi/index.js:463:12)
    at ServerlessWSGI.flask (/Users/cyber/dev/jb/serverless-wsgi/index.js:531:17)
    at ServerlessWSGI.<anonymous> (/Users/cyber/dev/jb/serverless-wsgi/index.js:749:28)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:126:23)

@revmischa
Copy link
Author

actually this error may be caused by a timeout. stand by

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

Ok, what does sls logs -f yourfunction say?

@revmischa
Copy link
Author

 sls invoke -f app  -c routes 
{
    "errorMessage": "'headers'",
    "errorType": "KeyError",
    "stackTrace": [
        "  File \"/var/task/wsgi_handler.py\", line 108, in handler\n    return serverless_wsgi.handle_request(wsgi_app, event, context)\n",
        "  File \"/var/task/serverless_wsgi.py\", line 94, in handle_request\n    headers = Headers(event[u\"headers\"])\n"
    ]
}

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

You should be doing sls wsgi flask -c routes and sls wsgi flask local -c routes instead of sls invoke?

@revmischa
Copy link
Author

you are completely right sorry lol

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

No worries :)

@revmischa
Copy link
Author

revmischa commented Jul 9, 2019

⇒ sls wsgi flask local -c config
{'API_SPEC_OPTIONS': {'components': {'securitySchemes': {'bearerAuth': {'bearerFormat': 'JWT',
                                                                        'scheme': 'bearer',
                                                                        'type': 'http'}}},
                      'security': [{'bearerAuth': []}]},
 'APPLICATION_ROOT': '/',
 'CAN_SEED_DB': True,
 'DATABASE_URL': '[object Object]',
 'DEBUG': False,
 'ENV': 'production',
....
 ⇒ sls wsgi flask  -c config     
Traceback (most recent call last):
  File "/var/task/wsgi_handler.py", line 96, in handler
    shlex.split(meta.get("data", "")), standalone_mode=False
  File "/var/task/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/var/task/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/var/task/click/core.py", line 1132, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/var/task/click/core.py", line 1188, in resolve_command
    ctx.fail('No such command "%s".' % original_cmd_name)
  File "/var/task/click/core.py", line 496, in fail
    raise UsageError(message, self)
click.exceptions.UsageError: No such command "config".

source is in https://github.com/jetbridge/sls-flask/

@logandk
Copy link
Owner

logandk commented Jul 9, 2019

Ok, I suppose the create_app argument to FlaskGroup is somehow not working with your app which uses the factory pattern. I'll dig a bit further into it later this week

@revmischa
Copy link
Author

I was experimenting with:

                from flask.cli import cli
                cmd = shlex.split(meta.get("data", ""))
                cli.main(cmd)

@logandk
Copy link
Owner

logandk commented Aug 4, 2019

I found the culprit: https://github.com/jetbridge/sls-flask/blob/master/TEMPLATE/commands.py#L6

Remove if app.debug: and everything works 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants