Error on missing argument if installed from pypi
After installing from pypi I get:
Traceback (most recent call last):
File "${HOME}/.local/lib/python3.7/site-packages/giftless/wsgi_entrypoint.py", line 7, in <module>
app = init_app()
File "${HOME}.local/lib/python3.7/site-packages/giftless/app.py", line 43, in init_app
transfer.init_flask_app(app)
File "${HOME}/.local/lib/python3.7/site-packages/giftless/transfer/__init__.py", line 71, in init_flask_app
adapter.register_views(app)
File "${HOME}/.local/lib/python3.7/site-packages/giftless/transfer/basic_streaming.py", line 158, in register_views
ObjectsView.register(app, init_argument=self.storage)
File "${HOME}/.local/lib/python3.7/site-packages/giftless/view.py", line 30, in register
return super().register(*args, **kwargs)
File "${HOME}/.local/lib/python3.7/site-packages/flask_classful.py", line 138, in register
proxy = cls.make_proxy_method(name)
File "${HOME}/.local/lib/python3.7/site-packages/flask_classful.py", line 230, in make_proxy_method
i = cls()
TypeError: __init__() missing 1 required positional argument: 'storage'
unable to load app 0 (mountpoint='') (callable not found or import error)
The last call comes from flask_classfull, where I have version 0.14.2, if that is important.
Originally posted by @ANaumann85 in https://github.com/datopian/giftless/issues/57#issuecomment-731804759
Unfortunately this is a known issue and it happens because our setup.py just refers to flask-classful but requirements.txt requires Flask-Classful to be of a non-released Git revision which is not available on Pypi (yet?). The code relies on features in the non-released version of Flask-Classful.
I'll see how we can work around this issue. In the mean time, can you try to run the following in your virtual environment / local environemnt where you installed Giftless:
pip install -r https://raw.githubusercontent.com/datopian/giftless/master/requirements.txt
This should ensure all dependency versions are exactly as specified in requirements.txt. Let me know if that solves the issue.
yes, that particular requirements and the newly build flask solve the issue. Thank you for your fast response and solution.
I've tried a fix in #59 but it seems this direct notation is not allowed by pypi (when installing locally from setup.py it does work but pypi won't accept the package).
As it doesn't seem like flask-classful is going to make a release to pypi with the code we need soon, I am thinking about some alternatives:
- Make our own release of flask-classful (e.g. flask-classful-myfork) to pypi (not a good idea)
- Change the code to not require the extra constructor argument somehow (need to check if feasible) and rely on flask-classful 0.14.*.
- Drop dependency on flask-classful all together (may be a good idea but requires some effort)
- Drop dependency on Flask all together and switch to another framework specifically designed for APIs (e.g. FastAPI) - this will require more considerable effort, but may be worth it. However, if we switch to non-WSGI (e.g. ASGI) framework, we will need to replace current support for WSGI middleware, specifically for CORS and proxy forwarding, with something else.
From all of these, I think 2 and 3 make the most sense. I will need to look into them.
Of course, these is the option of not doing anything and waiting for flask-classful to make a release.
I'll just say as a newcomer the giftless documentation could be more explicit that THIS is the issue that people will encounter if they try to install from pypi. Docs are currently a bit vague as to what the symptom will be, or even which dependency is involved. A simple link and note to "see #58 for more info" might help there. If the docs had only mentioned "flask-classful" I might have noticed the stack trace and made the connection.
Considering the long hiatus since the most recent flask-classful release (and 18 months since even a commit) I tend to agree option 2 or 3 seems most prudent for right now.