diff --git a/mixtape/core/models/agent_step.py b/mixtape/core/models/agent_step.py index 78bb978..2db1276 100644 --- a/mixtape/core/models/agent_step.py +++ b/mixtape/core/models/agent_step.py @@ -1,6 +1,7 @@ from django.db import models from mixtape.core.ray_utils.logger import NumpyJSONEncoder +from mixtape.environments.mappings import action_maps from .step import Step @@ -15,3 +16,10 @@ class Meta: action = models.FloatField() reward = models.FloatField() observation_space = models.JSONField(encoder=NumpyJSONEncoder) + + @property + def action_string(self) -> str: + # Note: "select_related" should be called on any AgentStep where this is used, otherwise + # this property can create very inefficient queries + environment = self.step.episode.inference_request.checkpoint.training_request.environment + return action_maps[environment].get(int(self.action), f'{self.action}') diff --git a/mixtape/core/templates/core/base.html b/mixtape/core/templates/core/base.html index 32e779c..98287d7 100644 --- a/mixtape/core/templates/core/base.html +++ b/mixtape/core/templates/core/base.html @@ -5,6 +5,7 @@ + {% block title %}MIXTAPE{% endblock %}