diff --git a/rddl-repository/Main.py b/rddl-repository/Main.py index db21719..734a10b 100644 --- a/rddl-repository/Main.py +++ b/rddl-repository/Main.py @@ -6,10 +6,10 @@ def main(): manager = RDDLRepoManager(rebuild=True) - # manager.ListProblems() - # envInfo = manager.GetProblem('CooperativeRecon_ippc2018') - envInfo = manager.GetProblem('RaceCar') - # envInfo.list_instances() + manager.list_problems() + # envInfo = manager.get_problem('CooperativeRecon_ippc2018') + envInfo = manager.get_problem('RaceCar') + envInfo.list_instances() envInfo.get_domain() envInfo.get_instance(0) envInfo.get_visualizer() diff --git a/rddl-repository/Manager/ProblemInfo.py b/rddl-repository/Manager/ProblemInfo.py index 19b8c0b..e1ee96d 100644 --- a/rddl-repository/Manager/ProblemInfo.py +++ b/rddl-repository/Manager/ProblemInfo.py @@ -34,7 +34,6 @@ def get_visualizer(self): if self.viz == 'None': return None - viz_backend_package_name = 'pyRDDLGym' spec = importlib.util.find_spec(viz_backend_package_name) if spec is None: raise RDDLRepoUnresolvedDependency(viz_backend_package_name + " is not installed") diff --git a/rddl-repository/Manager/RDDLRepoManager.py b/rddl-repository/Manager/RDDLRepoManager.py index 7ba7d40..cb7905f 100644 --- a/rddl-repository/Manager/RDDLRepoManager.py +++ b/rddl-repository/Manager/RDDLRepoManager.py @@ -11,22 +11,22 @@ class RDDLRepoManager: def __init__(self, rebuild=False): - self.Archiver_Dict = {} + self.archiver_dict= {} self.manager_path = os.path.dirname(os.path.abspath(__file__)) if os.path.isfile(self.manager_path+'/manifest.csv') and not rebuild: - self._LoadRepo() # load repo to dict + self._load_repo() # load repo to dict else: - self._BuildRepo() # build repo and load to dict + self._build_repo() # build repo and load to dict - def ListProblems(self): - for key, values in self.Archiver_Dict.items(): + def list_problems(self): + for key, values in self.archiver_dict.items(): print(key + ": " + values[1]) - def GetProblem(self, name): - if name in self.Archiver_Dict.keys(): - return ProblemInfo(self.Archiver_Dict[name]) + def get_problem(self, name): + if name in self.archiver_dict.keys(): + return ProblemInfo(self.archiver_dict[name]) - def _BuildRepo(self): + def _build_repo(self): root_path = os.path.dirname(os.path.abspath(__file__)) path_to_manifest = os.path.join(root_path, 'manifest.csv') root_path = root_path.split('/') @@ -48,7 +48,7 @@ def _BuildRepo(self): d = dir.split('/') module = 'Archive' + '.'.join(d) mymodule = importlib.import_module(module) - if mymodule.info['name'] in self.Archiver_Dict.keys(): + if mymodule.info['name'] in self.archiver_dict.keys(): raise RDDLRepoProblemDuplication() if 'domain.rddl' not in files: raise RDDLRepoDomainNotExist() @@ -58,7 +58,7 @@ def _BuildRepo(self): if context: context = '_' + context name = mymodule.info['name'] + context - self.Archiver_Dict[name] = [mymodule.info['name'], + self.archiver_dict[name] = [mymodule.info['name'], mymodule.info['description'], root, instances, @@ -72,21 +72,21 @@ def _BuildRepo(self): writer.writerow(HEADER) # iterate through the dictionary - for keys, values in self.Archiver_Dict.items(): + for keys, values in self.archiver_dict.items(): values[3] = ','.join(values[3]) writer.writerow(values) - def _LoadRepo(self): + def _load_repo(self): root_path = os.path.dirname(os.path.abspath(__file__)) path_to_manifest = os.path.join(root_path, 'manifest.csv') if not os.path.isfile(path_to_manifest): return {} - self.Archiver_Dict = {} + self.archiver_dict= {} with open(path_to_manifest) as file: reader = csv.reader(file, delimiter=',') for i, row in enumerate(reader): if i > 0: name, *entries = row - self.Archiver_Dict[name] = dict(zip(HEADER[1:], entries)) - return self.Archiver_Dict + self.archiver_dict[name] = dict(zip(HEADER[1:], entries)) + return self.archiver_dict