Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs mkdocstrings[python] mkdocs-gen-files mkdocs-material mkdocs-literate-nav mkdocs-jupyter
- run: pip install -U mkdocs mkdocstrings[python] mkdocs-gen-files mkdocs-material mkdocs-literate-nav mkdocs-jupyter
- run: mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ cython_debug/
/badgers/uncertainty-main-uncertainty-generate-augmentation/
/experiments/
/.continue/
/uncertainty-main-uncertainty-generate-augmentation/
Empty file removed badgers/mcp/__init__.py
Empty file.
67 changes: 67 additions & 0 deletions mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import inspect
import pkgutil

from badgers import generators
from badgers.core.base import GeneratorMixin



def is_implemented_method(method):
"""Check if a method is implemented and not abstract."""
return not inspect.isabstract(method)


def list_defined_classes_and_methods(module):
"""
List all classes and their methods defined in a given module.

Args:
module (module): The module to inspect.

Returns:
dict: A dictionary where keys are class names and values are tuples.
Each tuple contains the class docstring and a list of method tuples.
Each method tuple contains a method name and its docstring.
"""
classes = {}

# Walk through all submodules in the given module
for loader, module_name, is_pkg in pkgutil.walk_packages(module.__path__, module.__name__ + "."):
# Import the submodule
mod = __import__(module_name, fromlist="dummy")

# Inspect the submodule for classes and methods
for name, obj in inspect.getmembers(mod):
if inspect.isclass(obj) and obj.__module__ == module_name: # Check if the class is defined in the module
# Skip classes that directly inherit from GeneratorMixin
if GeneratorMixin in obj.__bases__:
continue

methods = []
for m_name, m_obj in inspect.getmembers(obj, inspect.isfunction):
if (m_name == '__init__' or not m_name.startswith('_')) and is_implemented_method(
m_obj): # Check if the method is public or __init__ and implemented
methods.append((m_name, m_obj.__doc__)) # Add the method name and docstring to the list
if methods: # Add only classes with implemented methods
classes[name] = (obj.__doc__, methods) # Store class docstring and methods

return classes


if __name__ == "__main__":
# Call the function to get classes and methods from the badgers.generators module
classes_and_methods = list_defined_classes_and_methods(generators)

# Print the classes and their methods with docstrings
for class_name, (class_doc, methods) in classes_and_methods.items():
print(f"Class: {class_name}")
if class_doc:
print(f" Class Docstring: {class_doc}")
else:
print(f" Class Docstring: None")
for method_name, method_doc in methods:
print(f" Method: {method_name}")
if method_doc:
print(f" Docstring: {method_doc}")
else:
print(f" Docstring: None")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "badgers"
version = "0.0.10"
version = "0.0.11"
keywords = ["data quality", "bad data", "data science"]
authors = [
{ name = "Julien Siebert", email = "[email protected]" },
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ networkx~=3.4.2
pandas~=2.2.3
scipy~=1.14.1
tox~=4.23.2
mkdocs~=1.4.3
mkdocstrings~=0.25.2
mkdocstrings-python~=1.10.9
mkdocs~=1.6.1
mkdocstrings~=0.29.1
mkdocstrings-python~=1.16.12
mkdocs-gen-files~=0.5.0
mkdocs-material~=9.1.12
mkdocs-literate-nav~=0.6.0
mkdocs-jupyter~=0.24.1
mkdocs-material~=9.6.15
mkdocs-literate-nav~=0.6.2
mkdocs-jupyter~=0.25.1
jupyterlab~=4.3.4
matplotlib~=3.10.0
Loading