pangaea-data-publisher / fuji

FAIRsFAIR Research Data Object Assessment Service
MIT License
51 stars 36 forks source link

F-UJI is broken after connexion update #463

Closed afuetterer closed 7 months ago

afuetterer commented 8 months ago

Description

F-UJI does not work after the connexion update. I pointed this out in the related PR #460. There are breaking changes in the update.

Expected Behavior

F-UJI server should start.

Tests should finish.

Actual Behavior

F-UJI server is unable to start.

$ python -m fuji_server -c fuji_server/config/server.ini
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File ".../fuji_server/__main__.py", line 34, in <module>
    from fuji_server.app import create_app
  File ".../fuji_server/app.py", line 30, in <module>
    from fuji_server import encoder
  File ".../fuji_server/encoder.py", line 1, in <module>
    from connexion.apps.flask_app import FlaskJSONEncoder
ModuleNotFoundError: No module named 'connexion.apps.flask_app'

Tests not possible.

$ hatch run test    
ImportError while loading conftest '.../fuji/tests/conftest.py'.
tests/conftest.py:13: in <module>
    from fuji_server.app import create_app
fuji_server/app.py:30: in <module>
    from fuji_server import encoder
fuji_server/encoder.py:1: in <module>
    from connexion.apps.flask_app import FlaskJSONEncoder
E   ModuleNotFoundError: No module named 'connexion.apps.flask_app'

Your Environment

dfsp-spirit commented 8 months ago

I just came here to report this, glad that this has been noticed already. It's broken for both manual installation and the Docker image, of course, I tried both.

Since we depend on F-UJI for our current project, is there any workaround for now, like running an older Docker image or checking out an older version? If so, which one do you recommend?

I guess monkeypatching pyproject.toml and pinning the connexion[swagger-ui] dependency to a specific version (the one before the error, maybe 2.14) should also do it.

Update: the monkeypatching approach works. One can clone the git repo, modify the connexion line in pyproject.toml (line 24) to read "connexion[swagger-ui]==2.14", and then pip install F-UJI. I did this in a fresh conda environment with Python 3.11. After installation, I got an error about Flask AttributeError: module 'flask.json' has no attribute 'JSONEncoder' when trying to start the F-UJI server, but that was easily fixed via pip uninstall Flask followed by pip install Flask==2.2.5. For our development environment, this is good enough for now.

huberrob commented 8 months ago

I am working on this but the migration to connexion 3 seems not to be that trivial

afuetterer commented 8 months ago

Excellent.

For anyone finding this issue and in case it is still open, you can follow @dfsp-spirit's suggestion to get a working F-UJI server or checkout a commit before 3a9dd19.

@huberrob: In case you need help with this. Maybe add the "help wanted" tag to the issue?

huberrob commented 8 months ago

OK, I think its done, at least all the tests are passed now and I can run it locally. Can you please take a try and verify?

huberrob commented 8 months ago

And @dfsp-spirit maybe you can tell a bit more about your project and how you are using F-UJi there?

dfsp-spirit commented 8 months ago

I'm working on infrastructure for a German NFDI and we're trying to get a picture of the technical level the repositories in our field are at, and also at metadata standards. If they offer a suitable API, we use F-UJI as part of the assessment of the FAIRness, by sampling some datasets from the repos.

dfsp-spirit commented 8 months ago

@huberrob I tried it and it works for me, great, thanks. I guess this can be closed.

(I tested b0e2752).

afuetterer commented 8 months ago

I get an error. Seems not to be working?

python -m fuji_server -c fuji_server/config/server.ini
YAML PATH .../fuji/fuji_server/yaml
Remote Logging not possible ,please correct : fuji.localhost /loghandler/index.php
.../.venv/lib/python3.11/site-packages/flask_limiter/extension.py:336: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
  warnings.warn(
`ConnexionMiddleware.run` is optimized for development. For production, run using a dedicated ASGI server.
INFO:     Started server process [89257]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
ERROR:    [Errno 99] error while attempting to bind on address ('::1', 1071, 0, 0): cannot assign requested address
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
huberrob commented 8 months ago

Maybe this is related to the config settings, can you check if this still appears when you change

service_host = localhost to service_host = 0.0.0.0

or 127.0.0.1 ?

afuetterer commented 7 months ago

Well. Today it just works. Nevermind my last comment. I think it works fine.