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

ModuleNotFoundError: No module named 'documentation_helpers' #373

Closed
pieterjanvc opened this issue Mar 19, 2024 · 6 comments · Fixed by #395
Closed

ModuleNotFoundError: No module named 'documentation_helpers' #373

pieterjanvc opened this issue Mar 19, 2024 · 6 comments · Fixed by #395
Labels
area: documentation 📖 Improvements or additions to documentation help wanted Extra attention is needed type: bug 🐛 Something isn't working
Milestone

Comments

@pieterjanvc
Copy link

Bug description

Following the tutorial, I'm stuck at the first code block at the line

import documentation_helpers

I pip installed ragna successfully

How to reproduce the bug?

If I run this in python 3.10.12 on Ubuntu

import documentation_helpers

I get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'documentation_helpers'

Versions and dependencies used

Python 2.10.12
Ragna ragna 0.2.0
Ubuntu 22.04.2 LTS

Anything else?

No response

@pieterjanvc pieterjanvc added the type: bug 🐛 Something isn't working label Mar 19, 2024
@pmeier
Copy link
Member

pmeier commented Mar 20, 2024

The module you are looking for is here, but is not distributed with Ragna as it is only needed for the documentation. Could you tell us how you are interacting with the tutorial?

In the REST API tutorial there are two blocks that require the documentation_helpers:

  1. To launch the REST API

    rest_api = documentation_helpers.RestApi()
    _ = rest_api.start(config)

    We explain above that outside of the documentation you would do this from another terminal

    # ## Step 1: Start the REST API
    #
    # Ragnas REST API is normally started from a terminal with
    #
    # ```bash
    # $ ragna api
    # ```
    #
    # For this tutorial we use our helper that does the equivalent just from Python.

  2. To upload a test document

    document_name = "ragna.txt"
    with open(documentation_helpers.assets / document_name, "rb") as file:
    content = file.read()

    You can find this document here, but you could also use any other document.

@pmeier
Copy link
Member

pmeier commented Apr 7, 2024

One option for us could be to just move the documentation helpers into ragna._docs. That way

  1. we don't need to have extra files in the documentation that need to be included through sys.path, reducing the noise in the example
  2. users can run the examples if they have Ragna installed
  3. we are keeping the advantage of not being bound to BC compatibility even after we adopt semantic versioning given that the module is private.

I guess we could also ship the ragna.txt file given that it is not large.

@pmeier pmeier added area: documentation 📖 Improvements or additions to documentation help wanted Extra attention is needed labels Apr 7, 2024
@arjxn-py
Copy link
Contributor

Hi there, I had also been trying to run this tutorial locally while setting up ragna.

Hence I tried to debug the issue and noticed that sys.path.insert(0, str(Path.cwd().parent)) is inserting an incorrect path if one is trying to run either of the gallery_python_api.py or gallery_rest_api.py from location other than docs/tutorials/ i.e. it is adding the path of the parent directory of cwd which should essentially point to docs/, but when trying to run tutorials from anywhere else it gets invalid (say from root, the path that gets added to to sys.path gets out of the project directory).

To fix this I replaced -

sys.path.insert(0, str(Path.cwd().parent))
import documentation_helpers

with -

cwd = Path(__file__).resolve().parent

while cwd:
    if (cwd / 'docs').is_dir():
        docs_path = cwd / 'docs'
        break
    cwd = cwd.parent

# If 'docs' directory is found, add it to the Python path
if docs_path:
    sys.path.insert(0, str(docs_path))

import documentation_helpers

But as @pmeier suggested moving the documentation helpers to ragna._docs is also a promising solution & I'd be really happy to assist the project try doing that & contribute to it further 🙂.
Thanks a lot 💐

@pmeier
Copy link
Member

pmeier commented Apr 23, 2024

I'd be really happy to assist the project try doing that & contribute to it further 🙂.

Hi @arjxn-py 👋 We would love to have your contribution here. If you send a PR, tag me there so I can review it.

@pmeier
Copy link
Member

pmeier commented Apr 24, 2024

@arjxn-py do you have a timeline for your contribution? I want to push a small bug fix release soon and this should be included.

@pmeier pmeier added this to the 0.2.1 milestone Apr 24, 2024
@arjxn-py
Copy link
Contributor

@arjxn-py do you have a timeline for your contribution? I want to push a small bug fix release soon and this should be included.

Apologies for the delay in response, I plan to fix this asap. I'm creating a branch & opening a PR to track progress in the meantime.

pmeier added a commit to arjxn-py/ragna that referenced this issue May 1, 2024
pmeier added a commit that referenced this issue May 1, 2024
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
pierrotsmnrd added a commit that referenced this issue May 13, 2024
commit 04168ab
Author: Arjun Verma <arjunverma.oc@gmail.com>
Date:   Wed May 1 12:35:41 2024 +0530

    #373 Include documentation_helpers in module (#395)

    Co-authored-by: Philip Meier <github.pmeier@posteo.de>

commit f947f2d
Author: Philip Meier <github.pmeier@posteo.de>
Date:   Mon Apr 29 17:08:40 2024 +0200

    bump mypy to 1.10 (#398)

commit e0fe014
Author: Kevin Klein <7267523+kklein@users.noreply.github.com>
Date:   Mon Apr 29 12:52:49 2024 +0200

    Add instructions to install from conda-forge. (#396)

    Co-authored-by: Philip Meier <github.pmeier@posteo.de>

commit 7963453
Author: Philip Meier <github.pmeier@posteo.de>
Date:   Thu Apr 25 20:38:50 2024 +0200

    use custom JSON type for database for more generic support (#389)

commit 3a5b82d
Author: William Black <125844868+smokestacklightnin@users.noreply.github.com>
Date:   Wed Apr 24 01:37:48 2024 -0700

    Remove Mosaic Assistant (#387)
pmeier added a commit that referenced this issue Jun 28, 2024
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
pmeier added a commit that referenced this issue Jun 28, 2024
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: documentation 📖 Improvements or additions to documentation help wanted Extra attention is needed type: bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants