-
Notifications
You must be signed in to change notification settings - Fork 151
Future of Flask-Script with Flask 1.0 #97
Comments
I use Flask-Script in several projects, so I hope to have a "compatibility-mode" maybe click or Flask-Script could have the ability to transform commands. The best scenario is click having a |
Not clear on all the internals of both click and flask-script but it would be nice to have something in flask-script that can convert from one to the other. I do know however that with flask-script I wrote commands sometimes that took a app factory and would allow for command line parameters/options to be passed to the factory. |
That is supported when you write your own scripts with click and hook them up with your Flask application instead of using the default
A compatibility mode is what I would like to see, but not in Click (since it not specific to Flask) and not in Flask, because then it opens the doors to be compatible to Flask-Actions and i don't know what. It also means that Flask could carry the compatibility burden for every single developer even if they never used Flask-Script. |
@mitsuhiko I looked at your Click integration layer. It seems the code that addresses the two Flask-Script design limitations you mention above is not Click specific at all. In fact, in just a few minutes of hacking I was able to get Flask-Script to work with them as well. All I used from As I mentioned yesterday on reddit, I feel adding yet another dependency does not agree with the lightweight spirit of Flask, so here is my proposal:
If exploring this option is something that interests you I'm happy to help. Thanks. |
You can solve this issue in many different ways. All you need to do is to avoid the app being loaded. Flask's CLI command did not use click initially but the initial version of what I had I could not get to work with Flask-Script at all. Now that I went through a bunch of iterations I would not rule out that you can't use it with Flask-Script. As a general hint: Deprecating Flask-Script is not something that needs to happen, but at present I'm pretty sure Flask will ship click integration of some sort.
But what would it gain from that? Yes, there would be one dependency less but it's non critical dependency really. flask.cli was initially not using Click but then there was a one-trick pony installed with Flask and it was written in a way that Flask-Script could not take advantage of it much and the complexity of that implementation is probably higher than the click integration. At least the initial implementation was not exactly easier: https://github.com/mitsuhiko/flask/blob/1b06c8a41119f8c93078e85f6474cb85d7e30b43/flask/run.py |
In terms of the reloader fix that first version looks pretty similar to what you have in the latest version. To make things work with Flask-Script I had to initialize the I also added a Regardless of what you do with Click, I suggest
Sure, it doesn't need to happen. But you also made the following statement:
So it seems the message you will give is that Flask-Script should be replaced with Click. So the moment Flask 1.0 is out my extension will be perceived as outdated. As an extension developer with dependencies on Flask-Script I think I have three options:
|
Hey guys, just thought I'd share some of my thoughts too if I may. Firstly, I think that click is awesome! I have already used it in a project of my own and will definitely continue to use it over argparse in the future. Congratulations on a great job done there Armin! 😄 The integration of a script interface based on click within Flask is something that I'm personally very excited about, let alone the release of Flask 1.0 which is even more exciting. The management script interface is something that I personally always use on every project anyway so it would be great if it was part of the core. If anything, I'd love to see the Flask-Cache extension also included in the core too 😄 I understand why some may have reservations about including more dependencies in Flask, but imho as long as the ORM stays separate, then Flask is still a very loosely coupled framework in almost all respects. All the best |
As an interested observer, my $.02 is as follows:
IMO, this is essentially your option #2 above, with a project name change, and without all the hassle of worrying about dependencies, legacy users, etc. |
Instead of making a new |
@reubano I think because too many incompatibility. |
@harobed I don't think that's the case. Based on @miguelgrinberg comments above, he says he's been able to port over the fixes. |
@miguelgrinberg: Your comment is a bit old, but I think the proper solution for that problem is to simply drop support for Flask<1.0 in a new version of your extension. That way nothing will break, and nobody can expect newer versions of extensions to keep supporting older versions of Flask. |
@ThiefMaster Yes, that's my #2 option above. What I don't like about that is that I need to create an arbitrary major version change in my project because a dependency is forcing me to. Doable, yes. Do I like it? No. |
@miguelgrinberg how hard would be to have Flask-Script wrap Click so it is completely transparent to the user? |
That would sacrify all the nice things |
@lu-zero it's a non-trivial effort, but in any case, what's the point of doing it? If we are going to make click work exactly like Flask-Script in a transparent way, then why not continue using Flask-Script instead? What a lot of people seem to forget is that we are talking about command line arguments here. It's simple stuff that has been figured out a long time ago. Yes, click has an original way of defining command line arguments that is nice and even fun to use, but at the end of the day, for me command line arguments in a Flask app are a super tiny fraction of my worries, honestly it makes no difference to me if I use click or Flask-Script because both make the task easy, and Flask-Script has the advantage that is compatible with argparse, which click is not. In my view Flask has no say in what command line parser I use, so if it was up to me, I would not make it a dependency. This goes against the no-batteries spirit of Flask, in my opinion. There is a claim that click resolves problems that are hard or impossible to address in Flask-Script (see top of this thread), but I demonstrated long ago that this isn't true, with a few small changes in Werkzeug the reload works with Flask-Script as well as it works with click. |
@miguelgrinberg what versions of flask-script works best with which version of flask? I'm still wondering what your thoughts are now as well as to whether or not old flask users should be migrating over to click as well... what would a flask-script migrate to click look like? maybe a tutorial would help for those who would like to migrate. thanks! Also, I see a new way to migrate db using click as well....your thoughts? |
@rlam3: Flask-Migrate already registers a click subcommand ( |
I never saw incompatibilities, as far as I know Flask-Script continues to work well with Flask, even the releases that use click.
Up to you entirely. Flask-Script still works, so if you have no issues with it, you may very well decide to stick to it. But if you have some free time and would like to migrate, it isn't that difficult, so go for it. The click interface has an old reloader bug fixed. If you tend to write too many typos in your Flask code and that makes your reloader crash, then switching to click addresses that issue. That is the only significant difference between the two, in my opinion.
No need to use that. I have added support for click on my extensions. Flask-Migrate works with both Flask-Script and click at this time. |
Is there a way to find out/debug as to why manage.py when using flask-script server isn't detecting changes in my code? I have tried the following: EnvironmentMac Sierra: 10.12.3 #requirements.txt
alabaster==0.7.9
alembic==0.8.5
amqp==1.4.7
anyjson==0.3.3
apache-libcloud==0.17.0
argh==0.26.1
arpy==1.1.1
Babel==2.3.4
backports.ssl-match-hostname==3.4.0.2
billiard==3.3.0.21
blinker==1.3
boto==2.38.0
celery==3.1.19
certifi==14.5.14
cffi==1.9.1
click==6.6
contextlib2==0.5.4
coverage==3.7.1
decorator==3.4.0
defusedxml==0.4.1
depot==0.0.12
docopt==0.6.2
docutils==0.13.1
ecdsa==0.13
elasticsearch==2.3.0
elasticsearch-dsl==2.0.0
enum34==1.1.6
esengine==0.0.18
Fabric==1.13.1
fabtools==0.19.0
filedepot==0.2.1
Flask==0.12
Flask-Babel==0.9
Flask-CDN==1.4.0
Flask-Celery-Helper==1.1.0
Flask-DebugToolbar==0.10.0
Flask-JSGlue==0.3
Flask-JWT-Extended==1.1.0
Flask-Login==0.3.2
Flask-Mail==0.9.1
flask-marshmallow==0.7.0
Flask-Migrate==1.8.0
Flask-OpenID==1.2.4
Flask-Principal==0.4.0
Flask-Script==2.0.6
Flask-Security==1.7.4
Flask-SQLAlchemy==2.1
Flask-SSLify==0.1.5
Flask-Test==0.1.5
Flask-Testing==0.4.2
Flask-WTF==0.13.1
flipflop==1.0
flower==0.8.2
futures==2.2.0
gnureadline==6.3.3
guess-language==0.2
idna==2.2
imagesize==0.7.1
infinity==1.3
intervals==0.7.1
ipaddress==1.0.18
ipython==3.2.0
itsdangerous==0.24
Jinja2==2.9.4
kombu==3.0.29
livereload==2.3.2
lockfile==0.10.2
Mako==1.0.4
MarkupSafe==0.23
marshmallow==2.10.5
marshmallow-sqlalchemy==0.8.1
migrate==0.2.2
nose==1.3.7
paramiko==2.1.1
passlib==1.6.2
pathtools==0.1.2
pbr==0.10.8
phonenumbers==7.0.7
Pillow==3.4.1
pip-tools==0.3.6
psycopg2==2.6
pyasn1==0.1.9
pycountry==1.12
pycparser==2.17
pycrypto==2.6.1
Pygments==2.1.3
PyJWT==1.4.2
pyOpenSSL==0.15.1
python-dateutil==2.5.2
python-editor==1.0
python-gnupg==0.3.7
python-openid==2.2.5
pytz==2016.10
PyYAML==3.11
raven==5.32.0
requests==2.12.5
simplekv==0.10.0
six==1.10.0
snowballstemmer==1.2.1
speaklater==1.3
Sphinx==1.5.1
sphinx-rtd-theme==0.1.9
SQLAlchemy==1.1.1
sqlalchemy-migrate==0.9.5
SQLAlchemy-Utils==0.31.6
sqlparse==0.1.14
stripe==1.22.3
Tempita==0.5.2
tornado==4.1
Unidecode==0.4.18
urllib3==1.14
uWSGI==2.0.14
validators==0.10
watchdog==0.8.3
Werkzeug==0.11.15
WTForms==2.1
WTForms-Alchemy==0.15.0
WTForms-Components==0.10.0
WTForms-SQLAlchemy==0.1 #manage.py
from flask_script import Manager, Shell, Server
from myapp.application import create_app
manager = Manager(create_app())
manager.add_command("runserver",
Server(
threaded=True,
use_reloader=manager.app.debug,
use_debugger=manager.app.debug,
host='0.0.0.0',
port=5000,
)
)
if __name__ == '__main__':
manager.run() * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with fsevents reloader
* Debugger is active!
* Debugger pin disabled. DEBUGGER UNSECURED!
Could this be why i may be having this issue? would the version of click or some other package be preventing me from detecting the code changes? |
A discussion of the direction of Click vs Flask-Script isn't really the place to be debugging your code, @rlam3. I can't reproduce your issue. Code reloading works, in both systems. If it doesn't work for you, please use Stack Overflow for questions about your own code. Or open a bug report about this specific issue if you truly feel it's a bug with Flask-Script. Either way, be sure to include a Minimal, Complete, and Verifiable Example. |
I'm not sure how I want to do the transition myself yet but I'm more than happy with how Click (http://click.pocoo.org/) (and the integration of it into Flask 1.0) is going that I would like this to be the official way forward to build command line utilities in the Flask ecosystem.
My plan is that by next month there is a new Flask release that supports Click out of the box and recommends using it.
Given how many extensions currently use Flask-Script and how popular it became I would like to figure out how to migrate everything over to Click without causing a lot of frustration everywhere.
First things first: the click integration in Flask is barebones out of the box. It does have a run and shell command but it does not do anything fancy like ipython integration or printing url maps. However it does support loading in extra commands from extensions so a Flask-Script successor could provide all that missing functionality.
To answer the obvious questions why not Flask-Script:
Unfortunately these two design differences mean there is no clear migration path.
I would like to figure out how to progress best and how to make this as painless as possible.
The text was updated successfully, but these errors were encountered: