GokuMohandas / mlops-course

Learn how to design, develop, deploy and iterate on production-grade ML applications.
https://madewithml.com
MIT License
2.96k stars 515 forks source link

Error while working in mkdocs #20

Closed mukul74 closed 1 year ago

mukul74 commented 1 year ago

Hi, I would like to ask for some help in the document creation code

python -m mkdocs serve

while running this in the specified folder, I am getting this error.

INFO - Building documentation... WARNING - Config value: 'selection'. Warning: Unrecognised configuration name: selection INFO - Cleaning site directory D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\mkdocstrings\handlers\python__init__.py:13: UserWarning: The 'python-legacy' extra of mkdocstrings will become mandatory in the next release. We have no way to detect if you already specify it, so if you do, please ignore this warning. You can globally disable it with the PYTHONWARNINGS environment variable: PYTHONWARNINGS=ignore::UserWarning:mkdocstrings.handlers.python warnings.warn( ERROR - mkdocstrings: module 'tagifai' has no attribute 'data' Traceback (most recent call last): File "D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\pytkdocs\cli.py", line 205, in main output = json.dumps(process_json(line)) File "D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\pytkdocs\cli.py", line 114, in process_json return process_config(json.loads(json_input)) File "D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\pytkdocs\cli.py", line 91, in process_config obj = loader.get_object_documentation(path, members) File "D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\pytkdocs\loader.py", line 355, in get_object_documentation
leaf = get_object_tree(dotted_path, self.new_path_syntax) File "D:\personal\Study\MadeWithML\mlops\mwml\lib\site-packages\pytkdocs\loader.py", line 281, in get_object_tree obj = getattr(current_node.obj, obj_name) AttributeError: module 'tagifai' has no attribute 'data' ERROR - Error reading page 'tagifai\data.md': ERROR - Could not collect 'tagifai.data'

Aborted with a BuildError!

Please provide your assistance.

Thanks

GokuMohandas commented 1 year ago

Hey @mukul74, looks like you need to provide the exact path of your python executable. So hopefully you're in a virtual environment and you should be able to do something like: path/venv/bin/python -m mkdocs serve. Also ensure that the mkdocs files you created follow the proper indentation.

mukul74 commented 1 year ago

Hi, thanks for the feedback, I am currently in the correct virtualenv. I tried the the mentioned code(Train. evaluate and other) as mentioned in the blog, that is running perfectly fine. So I guess virtualenv is correct.

Few observations for the error. W/O

plugins:
  - mkdocstrings

it is able to generate the required pages, obviously w/o content please refer to the snapshot attached below.

image

If I enable the

plugins:
  - mkdocstrings

I get the errors mentioned above.

Maybe because of windows, this error.

GokuMohandas commented 1 year ago

@mukul74 , I remember seeing this error a long time ago and it was because I didn't have the proper library installed or my mkdocs.yaml file was not correct. I can try to reproduce your error this weekend when I get some time but be sure to follow the instructions here. And if you can, provide a public URL to you code up until this point so I can see what you have so far.

mukul74 commented 1 year ago

@GokuMohandas , thanks. I will also try to get the correct libraries, this could be an issue too. Yeah sure I will provide the public URL.

tonypeng1 commented 1 year ago

@mukul74, I also encounter a similar problem. mkdocs serve only works for the python files in a few of the project folders but does not work for the python files in some of the other folders (ERROR - Could not collect ...).

I copy a python file from a folder that does not work to a folder that works and then this file can be successfully collected by running mkdocs serve.

In my case, it is discovered that the folders that work all have a __init__.py file that identifies them as regular package folders.

My problem is resolved by adding a __init__.py file to a folder from which we want mkdocs serve to collect files and making it a regular package folder.

Hope this helps in your case!

https://stackoverflow.com/questions/75232397/mkdocs-unable-to-find-modules/75324821#75324821

GokuMohandas commented 1 year ago

Hey @tonypeng1, glad that you were able to resolve your issue! May I ask what version of Python and what version of mkdocs packages you're using? I'm able to run mkdocs serve without using any __init__.py files. I'm using Python 3.9.1, mkdocs==1.3.0 and mkdocstrings==0.18.1.