Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking release/workbench-alpha branch to support the workbench #399

Merged

Conversation

davemfish
Copy link
Contributor

@davemfish davemfish commented Nov 30, 2020

I just created the new branch release/workbench-alpha - branched from release/3.9. This PR includes the changes needed to support the python side of the invest-workbench. Those changes are listed in #341 and amount to a small flask app that now lives under natcap.invest.web_api natcap.invest.ui_server (thoughts on this name?) and a new invest serve CLI entry-point to start the flask dev server and run the app.

There is a test here to cover the new invest serve subcommand. It imports the new module natcap.invest.ui_server, but so far there are no tests here to cover the flask app's endpoints. We do have tests for those endpoints in the workbench's test suite. And right now the workbench is the only use-case for the natcap.invest.ui_server module. I'm interested to hear opinions about whether those tests should live here in this repo instead.

Fixes #341

Checklist

  • Updated HISTORY.rst - Technically this is a user-facing change, with the new CLI entry-point. But we don't exactly expect anyone to use that except us for the workbench. Thoughts?

dcdenu4 and others added 30 commits October 15, 2020 10:18
Fixed a couple models that were pointing to the wrong html name.
…nload independent from the windows installer, mac dmg.
… made are unclear, unverified, and untested. RE#384
Copy link
Member

@emlys emlys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I tried out the new invest serve command. Love how you can exit it with ctrl+C 😀 My only comment is about the output of serve:

$ invest serve
 * Serving Flask app "natcap.invest.ui_server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:56789/ (Press CTRL+C to quit)

What is the 'Environment' setting and if this is a development server, should we change it to say 'Development'?

@davemfish
Copy link
Contributor Author

Looks good to me! I tried out the new invest serve command. Love how you can exit it with ctrl+C 😀 My only comment is about the output of serve:

$ invest serve
 * Serving Flask app "natcap.invest.ui_server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:56789/ (Press CTRL+C to quit)

What is the 'Environment' setting and if this is a development server, should we change it to say 'Development'?

Hey @emlys , thanks for bringing this up. By default, flask starts up in production mode. I haven't read about all the implications of that, but one implication is the subsequent WARNING about using the dev server in production. So the options seem to be:

  1. leave as-is on the grounds that it's appropriate to warn the user that ran invest serve
  2. use a production WSGI server. If this were a "real" webserver that needed to handle concurrent client requests, we would for sure need to do this. And maybe it's a good idea anyway?
  3. leave as-is, but on the workbench side we can launch invest serve after setting an env variable to set "Environment: development" as you suggest. That should suppress the WARNING.

Comment on lines +394 to +398
serve_subparser = subparsers.add_parser(
'serve', help=('Start the flask app on the localhost.'))
serve_subparser.add_argument(
'--port', type=int, default=56789,
help='Port number for the Flask server')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

@dcdenu4 dcdenu4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @davemfish this looks good to me. I'd be fine with punting the production vs development issue Emily brought up into a separate issue. Off the top of my head I'd say number 1 or 3 would be the way to go.

Also, did you add a comment to History? I know James had mentioned maybe adding something.

@emlys
Copy link
Member

emlys commented Jan 4, 2021

I agree it's fine to go in a separate issue

@davemfish
Copy link
Contributor Author

Okay we have passing builds now! Well, except for Mac.

Since you all last looked at this, Doug & I added the optional subargument to specify a port when starting the flask app. e.g. invest serve --port 54321. And there's a new test for that.

Also brought this branch up-to-date with main.

numpy>=1.11.0,!=1.16.0
Rtree>=0.8.2,!=0.9.1
Rtree>=0.8.2,!=0.9.1,<=0.9.4 # rtree/pyinstaller compatibility
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment!

Copy link
Member

@dcdenu4 dcdenu4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave!

Copy link
Member

@phargogh phargogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Dave!

I agree with the other comments about discussing the use of a webserver in a separate thread as well.

@phargogh
Copy link
Member

phargogh commented Jan 8, 2021

Looks like I'm the last one to submit an approval and all of the builds are passing (except RTD, which is currently an expected failure), so I'll merge this.

@phargogh phargogh merged commit 53803eb into natcap:release/workbench-alpha Jan 8, 2021
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.

5 participants