Skip to content

Commit

Permalink
Merge pull request #4 from ataitler/StructureBranch
Browse files Browse the repository at this point in the history
handling missing pyRDDLGym dependency for viz import
  • Loading branch information
ataitler authored Feb 15, 2023
2 parents 4c48c15 + e495c88 commit 72db3d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 4 additions & 3 deletions rddl-repository/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

def main():
manager = RDDLRepoManager(rebuild=True)
manager.ListProblems()
envInfo = manager.GetProblem('CooperativeRecon_ippc2018')
envInfo.list_instances()
# manager.ListProblems()
# envInfo = manager.GetProblem('CooperativeRecon_ippc2018')
envInfo = manager.GetProblem('RaceCar')
# envInfo.list_instances()
envInfo.get_domain()
envInfo.get_instance(0)
envInfo.get_visualizer()
Expand Down
5 changes: 4 additions & 1 deletion rddl-repository/Manager/ErrorHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ class RDDLRepoDomainNotExist(ValueError):
pass

class RDDLRepoProblemDuplication(ValueError):
pass
pass

class RDDLRepoUnresolvedDependency(ValueError):
pass
11 changes: 10 additions & 1 deletion rddl-repository/Manager/ProblemInfo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os.path
import sys
import importlib.util

from .ErrorHandling import RDDLRepoInstanceNotExist, RDDLRepoUnresolvedDependency

from .ErrorHandling import RDDLRepoInstanceNotExist
sys.path.append('../rddl-repository')
viz_backend_package_name = 'pyRDDLGym'


class ProblemInfo:
def __init__(self, problem_data):
Expand Down Expand Up @@ -30,6 +34,11 @@ 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")

path_to_viz = self.loc.split('/')
repo_root = path_to_viz.index('Archive')
path_to_viz = '.'.join(path_to_viz[repo_root:])
Expand Down

0 comments on commit 72db3d2

Please sign in to comment.