Skip to content

Commit

Permalink
feat: make configs subscriptable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack17432 committed Oct 24, 2023
1 parent 80d119f commit c43c281
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cares_reinforcement_learning/util/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@

# NOTE: If a parameter is a list then don't wrap with Optional leave as implicit optional - List[type] = default

class EnvironmentConfig(BaseModel):
class SubscriptableClass(BaseModel):
def __getitem__(self, item):
return getattr(self, item)

class EnvironmentConfig(SubscriptableClass):
gym: str = Field(description='Gym Environment <openai, dmcs>')
task: str
domain: Optional[str] = None
image_observation: Optional[bool] = False

class TrainingConfig(BaseModel):
class TrainingConfig(SubscriptableClass):
seeds: List[int] = [10]

G: Optional[int] = 1
Expand All @@ -30,7 +34,7 @@ class TrainingConfig(BaseModel):
plot_frequency: Optional[int] = 100
checkpoint_frequency: Optional[int] = 100

class AlgorithmConfig(BaseModel):
class AlgorithmConfig(SubscriptableClass):
algorithm: str = Field(description='Name of the algorithm to be used')

class DQNConfig(AlgorithmConfig):
Expand Down

0 comments on commit c43c281

Please sign in to comment.