Forum Discussion
Docstrings from Custom Library not displaying in Notebook
- 1 year ago
Hello kwenzelmms
Ensure docstrings use triple-quoted strings immediately following function/class declarations
def my_function(param):
"""Display this docstring in Fabric Notebooks
Args:
param: Example parameter
"""
...Package libraries as `.whl` files with proper metadata in `setup.py`
Create dedicated Fabric environment
2. Add custom library through UI:
• Workspace > New > Environment > Add from PyPI/upload WHL
3. Publish environment before notebook use
4. Select environment in notebook toolbarIn notebook :
import importlib
importlib.reload(mylib)If this is helpful please accept the answer
Hello kwenzelmms
Ensure docstrings use triple-quoted strings immediately following function/class declarations
def my_function(param):
"""Display this docstring in Fabric Notebooks
Args:
param: Example parameter
"""
...
Package libraries as `.whl` files with proper metadata in `setup.py`
Create dedicated Fabric environment
2. Add custom library through UI:
• Workspace > New > Environment > Add from PyPI/upload WHL
3. Publish environment before notebook use
4. Select environment in notebook toolbar
In notebook :
import importlib
importlib.reload(mylib)
If this is helpful please accept the answer
- kwenzelmms1 year agoFrequent Visitor
I have tried the recommendation you mentioned and am still not seeing the docstrings. Though I see them in VsCode, I want to build another local project where the module is referenced as a true library and not part of an existing project. That way I can see whether the docstrings are being stripped from my library.
I'm simply using python -m build to built it. I know that won't strip docstrings away.
- Anonymous1 year agoNot applicable
Hi kwenzelmms,
Thanks for going through the responses. Since you can see the docstrings in VS Code but not in Fabric, it’s likely an issue with how Fabric loads the library rather than the packaging process itself.
You can follow few steps to verify if docstrings are present. You can verify optimization flags in Fabric
as it might be running Python in optimized mode, which removes docstrings. Use this code:
"import sys
print(sys.flags.optimize)"If it returns 1 or 2, Python is running in optimized mode, which removes docstrings. If it returns 0 then docstrings should be available.
You can also run the following code inside your Fabric Notebook to verify if docstrings are present.
"import my_custom_library
print(my_custom_library.some_function.__doc__)"
If this returns "None", it confirms that docstrings are being stripped at runtime in Fabric.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.