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

Incompatible with fastapi>=0.95? #258

Open
fabcor-maxiv opened this issue Jul 25, 2023 · 0 comments · May be fixed by #259
Open

Incompatible with fastapi>=0.95? #258

fabcor-maxiv opened this issue Jul 25, 2023 · 0 comments · May be fixed by #259

Comments

@fabcor-maxiv
Copy link
Collaborator

Is the code incompatible with fastapi>=0.95?

When starting the application with fastapi==0.100.0, we get errors like the following one:

INFO:     | 2023-07-25 16:42:38 | pyispyb.core.routes | Importing proposals.py
ERROR:    | 2023-07-25 16:42:38 | pyispyb.core.routes | Could not import module `proposals.py`
Traceback (most recent call last):
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/pyispyb/core/routes/__init__.py", line 37, in init_app
    module = import_module(".%s" % module_name[:-3], package=__name__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/pyispyb/core/routes/proposals.py", line 26, in <module>
    @router.get(
     ^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/routing.py", line 706, in decorator
    self.add_api_route(
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/routing.py", line 645, in add_api_route
    route = route_class(
            ^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/routing.py", line 491, in __init__
    self.dependant = get_dependant(path=self.path_format, call=self.endpoint)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 268, in get_dependant
    sub_dependant = get_param_sub_dependant(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 111, in get_param_sub_dependant
    return get_sub_dependant(
           ^^^^^^^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 147, in get_sub_dependant
    sub_dependant = get_dependant(
                    ^^^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 261, in get_dependant
    type_annotation, depends, param_field = analyze_param(
                                            ^^^^^^^^^^^^^^
  File "/home/fabcor/workspace/kits-ims/ispyb/py-ispyb/.tox/dev/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 410, in analyze_param
    assert isinstance(field_info, params.Path), (
AssertionError: Cannot use `Query` for path param 'proposal'

We found this fastapi ticket. Which leads us to assume that the application as it is written now is not compatible with fastapi>=0.95. And indeed after downgrading fastapi with a command like python -m pip install 'fastapi<0.95' the errors disappear.

fabcor-maxiv added a commit to fabcor-maxiv/py-ispyb that referenced this issue Jul 25, 2023
@fabcor-maxiv fabcor-maxiv linked a pull request Jul 25, 2023 that will close this issue
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 a pull request may close this issue.

1 participant