Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
latentvector committed Nov 19, 2024
1 parent 6d17325 commit 03fe258
Show file tree
Hide file tree
Showing 17 changed files with 408 additions and 405 deletions.
1 change: 1 addition & 0 deletions commune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
M = IDONTGIVEAFUCKWHATYOUCALLTHIS = c = Block = Lego = M = Agent = Module # alias c.Module as c.Block, c.Lego, c.M
c.add_to_globals(globals())
key = c.get_key # override key function with file key in commune/key.py TODO: remove this line with a better solution
utils = c.utils # set utils as a global

13 changes: 8 additions & 5 deletions commune/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ def determine_type(x):
except ValueError:
pass
return x
def forward(sep = '--',
def forward(argv = None,
sep = '--',
fn_splitters = [':', '/', '//', '::'],
base = 'module',
helper_fns = ['code', 'schema', 'fn_schema', 'help', 'fn_info', 'fn_hash']):
helper_fns = ['code', 'schema', 'fn_schema', 'help', 'fn_info', 'fn_hash'],
default_fn = 'vs'):
t0 = time.time()
argv = sys.argv[1:]
argv = argv or sys.argv[1:]
if len(argv) == 0:
argv = [default_fn]
output = None
init_kwargs = {}
if any([arg.startswith(sep) for arg in argv]):
Expand All @@ -67,15 +71,14 @@ def forward(sep = '--',
value = arg.split('=')[-1] if '=' in arg else True
argv.remove(arg)
init_kwargs[key] = determine_type(value)

# any of the --flags are init kwargs
fn = argv.pop(0).replace('-', '_')
module = c.module(base)
fs = [fs for fs in fn_splitters if fs in fn]
if len(fs) == 1:
module, fn = fn.split(fs[0])
module = c.shortcuts.get(module, module)
modules = c.modules()
modules = c.get_modules()
module_options = []
for m in modules:
if module == m:
Expand Down
Loading

0 comments on commit 03fe258

Please sign in to comment.