Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
latentvector committed Sep 15, 2024
1 parent 11479ec commit 5d1e7f3
Show file tree
Hide file tree
Showing 25 changed files with 290 additions and 790 deletions.
266 changes: 46 additions & 220 deletions commune/module.py

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions commune/modules/git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ def is_repo(self, libpath:str ):
# has the .git folder
return c.cmd(f'ls -a {libpath}').count('.git') > 0


@staticmethod
def clone(repo_url:str, target_directory:str = None, branch=None):
def clone(repo_url:str, path:str = None, branch=None):
prefix = 'https://github.com/'
if not repo_url.startswith(prefix):
repo_url = f'{prefix}{repo_url}'

if target_directory == None:
target_directory = repo_url.split('/')[-1].split('.')[0]
if path == None:
path = path.split('/')[-1].split('.')[0]
else:
target_directory = c.resolve_path(target_directory)
path = c.resolve_path(path)
# Clone the repository
return subprocess.run(['git', 'clone', repo_url, target_directory])
return subprocess.run(['git', 'clone', repo_url, path])



Expand Down Expand Up @@ -130,7 +128,10 @@ def merge_remote_repo(cls, remote_name:str, remote_url:str, remote_branch:str, l

cmd = ' && '.join(cmds)
return c.cmd(cmd, cwd)




@classmethod
def clone(cls, url):
prefix = 'https://github.com/'
if not url.startswith(prefix):
url = prefix + url
return c.cmd(f'git clone {url}', verbose=True, cwd=c.libpath)
61 changes: 0 additions & 61 deletions commune/modules/template/template.py

This file was deleted.

1 change: 0 additions & 1 deletion commune/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# THIS IS WHAT THE INTERNET IS, A BUNCH OF NAMESPACES, AND A BUNCH OF SERVERS, AND A BUNCH OF MODULES.
# THIS IS THE INTERNET OF INTERNETS.
class Namespace(c.Module):

# the default
network : str = 'local'
@classmethod
Expand Down
4 changes: 2 additions & 2 deletions commune/serializer.py → commune/serializer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def deserialize(self, x) -> object:
return x

def serializer_map(self):
type_path = self.dirpath() + '/serializers'
type_path = self.dirpath()
module_paths = c.find_objects(type_path)
return {p.split('.')[-2]: c.obj(p)() for p in module_paths}
return {p.split('.')[-2]: c.obj(p)() for p in module_paths if '__init__' not in p}


def types(self):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5d1e7f3

Please sign in to comment.