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

[BUG] Missing dependency: sphinx python package #2282

Open
acardona opened this issue Jan 15, 2025 · 3 comments
Open

[BUG] Missing dependency: sphinx python package #2282

acardona opened this issue Jan 15, 2025 · 3 comments

Comments

@acardona
Copy link
Contributor

acardona commented Jan 15, 2025

When attempting to import skeletons via pymaid, we get this error:

{
  "error": "Could not import 'custom_rest_swagger_googledoc.get_googledocstring' for API setting 'VIEW_DESCRIPTION_FUNCTION'. ModuleNotFoundError: No module named 'sphinx'.",
  "detail": "Traceback (most recent call last):\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/settings.py\", line 179, in import_from_string\n    return import_string(val)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/django/utils/module_loading.py\", line 30, in import_string\n    return cached_import(module_path, class_name)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/django/utils/module_loading.py\", line 15, in cached_import\n    module = import_module(module_path)\n  File \"/usr/lib/python3.10/importlib/__init__.py\", line 126, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n  File \"\u003Cfrozen importlib._bootstrap\u003E\", line 1050, in _gcd_import\n  File \"\u003Cfrozen importlib._bootstrap\u003E\", line 1027, in _find_and_load\n  File \"\u003Cfrozen importlib._bootstrap\u003E\", line 1006, in _find_and_load_unlocked\n  File \"\u003Cfrozen importlib._bootstrap\u003E\", line 688, in _load_unlocked\n  File \"\u003Cfrozen importlib._bootstrap_external\u003E\", line 883, in exec_module\n  File \"\u003Cfrozen importlib._bootstrap\u003E\", line 241, in _call_with_frames_removed\n  File \"/opt/catmaid/fibsem/django/lib/custom_rest_swagger_googledoc.py\", line 8, in \u003Cmodule\u003E\n    from sphinx.ext.napoleon import Config\nModuleNotFoundError: No module named 'sphinx'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/django/core/handlers/base.py\", line 220, in _get_response\n    response = response.render()\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/django/template/response.py\", line 114, in render\n    self.content = self.rendered_content\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/response.py\", line 74, in rendered_content\n    ret = renderer.render(self.data, accepted_media_type, context)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/renderers.py\", line 727, in render\n    context = self.get_context(data, accepted_media_type, renderer_context)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/renderers.py\", line 689, in get_context\n    'description': self.get_description(view, response.status_code),\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/renderers.py\", line 604, in get_description\n    return view.get_view_description(html=True)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/views.py\", line 244, in get_view_description\n    func = self.settings.VIEW_DESCRIPTION_FUNCTION\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/settings.py\", line 227, in __getattr__\n    val = perform_import(val, attr)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/settings.py\", line 168, in perform_import\n    return import_from_string(val, setting_name)\n  File \"/opt/catmaid/fibsem/django/env/lib/python3.10/site-packages/rest_framework/settings.py\", line 182, in import_from_string\n    raise ImportError(msg)\nImportError: Could not import 'custom_rest_swagger_googledoc.get_googledocstring' for API setting 'VIEW_DESCRIPTION_FUNCTION'. ModuleNotFoundError: No module named 'sphinx'.\n",
  "type": "ImportError",
  "meta": null
}

Likely the 'sphinx' python package is missing from the requirements text files for building the python virtual environment.

@acardona acardona changed the title [BUG] Missing dependency: sphynx python package [BUG] Missing dependency: sphinx python package Jan 17, 2025
@acardona
Copy link
Contributor Author

Turns out it's the sphinx package and not sphynx that is missing.

@tomka
Copy link
Contributor

tomka commented Feb 6, 2025

sphinx is usually only needed for building the documentation and is part of the requirements-doc.txt requirements file. It looks like pymaid tries to access an endpoint that returns the documentation HTML rather than the requested content (maybe because the Content-Type header wasn't set to application/json?).

Accessing the HTML version of some endpoints for documentation purposes seems useful generally and I think it would make sense to move the "doc" requirement into the main requirements.txt file.

tomka added a commit that referenced this issue Feb 6, 2025
This is useful for consuming API documentation on a CATMAID instance.
Some DRF endpoints allow to show API documentation when called with a
regular GET request from the browser. This prevents CATMAID raising an
import error in these cases and instead shows the API documentation
HTML. Apparantly, there are also cases where `pymaid` would cause
similar error responses without `sphinx`. This should be fixes with this
commit as well.

Fixes #2282
@tomka
Copy link
Contributor

tomka commented Feb 6, 2025

This is updated in dev now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants