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

--html works but --http doesn't #33

Closed
nicolaskruchten opened this issue Feb 15, 2019 · 4 comments

Comments

2 participants
@nicolaskruchten
Copy link
Contributor

commented Feb 15, 2019

Expected Behavior

Static and live generation should work the same way.

Actual Behavior

In my project I can run pdoc my_module --html and it runs fine, generating HTML etc but while pdoc my_module --http localhost:8080 starts the web server, the page fails to render with ModuleNotFoundError: No module named 'my_module'

Steps to Reproduce

  1. git clone git@github.com:plotly/plotly_express.git (maybe install some deps)
  2. pdoc plotly_express --html vs pdoc plotly_express --http localhost:8080
@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2019

After git clone, I ran pip install -e . in the plotly_express directory. Can't seem to reproduce the issue:

$ pdoc plotly_express --http localhost:8080 
Starting pdoc server on localhost:8080
pdoc server ready at http://localhost:8080
127.0.0.1 - - [17/Feb/2019 16:33:30] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [17/Feb/2019 16:33:32] "GET /plotly_express HTTP/1.1" 302 -
127.0.0.1 - - [17/Feb/2019 16:33:32] "GET /plotly_express/ HTTP/1.1" 200 -
127.0.0.1 - - [17/Feb/2019 16:33:42] "GET /plotly_express/colors/index.html HTTP/1.1" 302 -
127.0.0.1 - - [17/Feb/2019 16:33:42] "GET /plotly_express/colors/ HTTP/1.1" 200 -
127.0.0.1 - - [17/Feb/2019 16:33:50] "GET /plotly_express/colors/diverging.html HTTP/1.1" 200 -

If I don't install plotly_express, I get the following error:

Exception happened during processing of request from ('127.0.0.1', 46388)
Traceback (most recent call last):
  File "/home/user/pdoc/pdoc/__init__.py", line 540, in import_module
    module.__loader__.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/tmp/plotly_express/plotly_express/_px.py", line 5, in <module>
    from .colors.qualitative import Plotly as default_qualitative_seq
SystemError: Parent module 'plotly_express' not loaded, cannot perform relative import

But this is due to pdoc importing the documented module, plotly_express using relative imports, and Python not honoring relative imports from non-packages (i.e. filesystem paths).

@nicolaskruchten

This comment has been minimized.

Copy link
Contributor Author

commented Feb 17, 2019

Right, I was trying this without installing locally. I guess this is just not a supported use case?

@kernc kernc reopened this Feb 17, 2019

@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2019

I see. The discrepancy between --html (which even without installing works) and --http (which doesn't) was unintended. Looking into it.

@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2019

It has to do with these lines

pdoc/pdoc/cli.py

Lines 333 to 334 in 53544d8

# Support loading modules specified as python paths relative to cwd
sys.path.append(os.getcwd())

I guess we can just move them a few lines up ...

@kernc kernc added the bug label Feb 17, 2019

@kernc kernc closed this in 6444b77 Feb 17, 2019

kernc added a commit that referenced this issue Feb 17, 2019

kernc added a commit that referenced this issue Feb 17, 2019

@kernc kernc added this to the 0.5.3 milestone Mar 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.