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

FrontPageHandler will misrecognize a config-imported module as a plugin module, if the config is a single python file #93

Open
erikyao opened this issue Sep 27, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@erikyao
Copy link
Contributor

erikyao commented Sep 27, 2022

An Example

Suppose we have plugin config file config_web/pfocr.py, who imports a copy module itself:

import copy
from biothings.web.settings.default import QUERY_KWARGS

# Omitted

When we start pending_web with python3 index.py --conf=config_web/pfocr.py, FrontPageHandler will report:

[ERROR tornado.application:1798] Uncaught exception GET / (172.29.80.35)
    HTTPServerRequest(protocol='http', host='localhost:8000', method='GET', uri='/', version='HTTP/1.1', remote_ip='172.29.80.35')
    Traceback (most recent call last):
      File "/opt/home/pending/venv/lib/python3.8/site-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/opt/home/pending/pending.api/web/handlers/__init__.py", line 60, in get
        apilist = [{
      File "/opt/home/pending/pending.api/web/handlers/__init__.py", line 61, in <listcomp>
        "_id": conf.API_PREFIX,
    AttributeError: module 'copy' has no attribute 'API_PREFIX'

This error won't happen if we start with the whole config folder, like python3 index.py --conf=config_web.

Cause

FrontPageHandler assumes that all modules nested in the root config is a plugin module:

        root = self.biothings.config._primary
        attrs = [getattr(root, attr) for attr in dir(root)]
        confs = [attr for attr in attrs if isinstance(attr, types.ModuleType)]
        apilist = [{
            "_id": conf.API_PREFIX,
            "status": "running"
        } for conf in confs]

However in this case, the root config is the imported pfocr.py and its own copy module is not a plugin module.

@erikyao erikyao self-assigned this Sep 27, 2022
@ctrl-schaff ctrl-schaff assigned ctrl-schaff and unassigned erikyao Dec 10, 2024
@ctrl-schaff ctrl-schaff added the bug Something isn't working label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants