diff --git a/commune/README.md b/commune/README.md deleted file mode 100644 index db1e6f00..00000000 --- a/commune/README.md +++ /dev/null @@ -1,25 +0,0 @@ -xA module is a colleciton of functions as well as data or state -variables. The functions can be called from the command line interface or through the API. The data or state variables can be accessed and modified through the API. There is no blockchain or database in the module. The module is a simple way to organize code and data. To define a module, just define a class - -To make a module create a name - -{name}/module.py - -Then do this - -```python -class Module: - def __init__(self): - self.data = {} - def forward(self, a=1, b=2): - return a + b -``` - -To call it from the command line interface do this - -```bash -c {name}/forward a=1 b=2 -or -c.module(name).forward(a=1, b=2) -``` - diff --git a/commune/module.py b/commune/module.py index 13232ede..d07a843f 100755 --- a/commune/module.py +++ b/commune/module.py @@ -105,6 +105,12 @@ def ask(*args, **kwargs): return c.ask(*args, **kwargs) module.ask = ask return module + + + @classmethod + def getfile(cls, obj=None) -> str: + obj = cls.resolve_module(obj) + return inspect.getfile(obj) @classmethod def filepath(cls, obj=None) -> str: @@ -2041,6 +2047,12 @@ def run_test(self, module=None, parallel=True): return fn2result + def readmes(self, path='./', search=None): + files = c.files(path) + readmes = [f for f in files if f.endswith('.md')] + return readmes + + c.add_routes() Module = c # Module is alias of c