44
55from functools import partial
66from glob import glob
7- import git
87import inspect
98import logging as log
109import os
1110import os .path as osp
1211
1312from datumaro .components .config import Config
14- from datumaro .components .config_model import Model , Source
1513from datumaro .util .os_util import import_foreign_module
1614
1715
@@ -46,29 +44,6 @@ def __getitem__(self, key):
4644 def __contains__ (self , key ):
4745 return key in self .items
4846
49-
50- class ModelRegistry (Registry ):
51- def __init__ (self , config = None ):
52- super ().__init__ (config , item_type = Model )
53-
54- def load (self , config ):
55- # TODO: list default dir, insert values
56- if 'models' in config :
57- for name , model in config .models .items ():
58- self .register (name , model )
59-
60-
61- class SourceRegistry (Registry ):
62- def __init__ (self , config = None ):
63- super ().__init__ (config , item_type = Source )
64-
65- def load (self , config ):
66- # TODO: list default dir, insert values
67- if 'sources' in config :
68- for name , source in config .sources .items ():
69- self .register (name , source )
70-
71-
7247class PluginRegistry (Registry ):
7348 def __init__ (self , config = None , builtin = None , local = None ):
7449 super ().__init__ (config )
@@ -85,47 +60,6 @@ def __init__(self, config=None, builtin=None, local=None):
8560 self .register (k , v )
8661
8762
88- class GitWrapper :
89- def __init__ (self , config = None ):
90- self .repo = None
91-
92- if config is not None and config .project_dir :
93- self .init (config .project_dir )
94-
95- @staticmethod
96- def _git_dir (base_path ):
97- return osp .join (base_path , '.git' )
98-
99- @classmethod
100- def spawn (cls , path ):
101- spawn = not osp .isdir (cls ._git_dir (path ))
102- repo = git .Repo .init (path = path )
103- if spawn :
104- repo .config_writer ().set_value ("user" , "name" , "User" ) \
105- .set_value ("user" , "email" , "user@nowhere.com" ) \
106- .release ()
107- # gitpython does not support init, use git directly
108- repo .git .init ()
109- repo .git .commit ('-m' , 'Initial commit' , '--allow-empty' )
110- return repo
111-
112- def init (self , path ):
113- self .repo = self .spawn (path )
114- return self .repo
115-
116- def is_initialized (self ):
117- return self .repo is not None
118-
119- def create_submodule (self , name , dst_dir , ** kwargs ):
120- self .repo .create_submodule (name , dst_dir , ** kwargs )
121-
122- def has_submodule (self , name ):
123- return name in [submodule .name for submodule in self .repo .submodules ]
124-
125- def remove_submodule (self , name , ** kwargs ):
126- return self .repo .submodule (name ).remove (** kwargs )
127-
128-
12963class Environment :
13064 _builtin_plugins = None
13165 PROJECT_EXTRACTOR_NAME = 'datumaro_project'
@@ -136,11 +70,6 @@ def __init__(self, config=None):
13670 config = Config (config ,
13771 fallback = PROJECT_DEFAULT_CONFIG , schema = PROJECT_SCHEMA )
13872
139- self .models = ModelRegistry (config )
140- self .sources = SourceRegistry (config )
141-
142- self .git = GitWrapper (config )
143-
14473 env_dir = osp .join (config .project_dir , config .env_dir )
14574 builtin = self ._load_builtin_plugins ()
14675 custom = self ._load_plugins2 (osp .join (env_dir , config .plugins_dir ))
@@ -284,12 +213,6 @@ def make_converter(self, name, *args, **kwargs):
284213 def make_transform (self , name , * args , ** kwargs ):
285214 return partial (self .transforms .get (name ), * args , ** kwargs )
286215
287- def register_model (self , name , model ):
288- self .models .register (name , model )
289-
290- def unregister_model (self , name ):
291- self .models .unregister (name )
292-
293216 def is_format_known (self , name ):
294217 return name in self .importers or name in self .extractors
295218
0 commit comments