diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 4a3e78a..831e648 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -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 diff --git a/.gitignore b/.gitignore index f21eefe..1e6885c 100644 --- a/.gitignore +++ b/.gitignore @@ -165,3 +165,4 @@ cython_debug/ /badgers/uncertainty-main-uncertainty-generate-augmentation/ /experiments/ /.continue/ +/uncertainty-main-uncertainty-generate-augmentation/ diff --git a/badgers/mcp/__init__.py b/badgers/mcp/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/mcp/__init__.py b/mcp/__init__.py new file mode 100644 index 0000000..cb34777 --- /dev/null +++ b/mcp/__init__.py @@ -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") diff --git a/pyproject.toml b/pyproject.toml index a08df1a..df94426 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "julien.siebert@iese.fraunhofer.de" }, diff --git a/requirements.txt b/requirements.txt index dc3801e..073019e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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