Skip to content

Commit

Permalink
Remove Phase as parameter for context processor components. If the …
Browse files Browse the repository at this point in the history
…phase is needed, it can be accessed via its containing `Entity`.

PiperOrigin-RevId: 648683197
Change-Id: I9382641bd2e3ef5639a701f0945ea1396df40d9d
  • Loading branch information
duenez authored and copybara-github committed Jul 2, 2024
1 parent 4793bf5 commit 76a4568
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
3 changes: 1 addition & 2 deletions concordia/components/agent/v2/no_op_context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class NoOpContextProcessor(component_v2.ContextProcessorComponent):
@override
def process(
self,
phase: component_v2.Phase,
contexts: component_v2.ComponentContextMapping,
) -> None:
del phase, contexts
del contexts
31 changes: 0 additions & 31 deletions concordia/typing/component_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import abc
from collections.abc import Mapping
import enum

from concordia.typing import entity as entity_lib

Expand All @@ -25,34 +24,6 @@
ComponentContextMapping = Mapping[ComponentName, ComponentContext]


class Phase(enum.Enum):
"""Phases of the agent lifecycle.
Attributes:
INIT: The agent has just been created. No action has been requested nor
observation has been received. This can be followed by a call to `pre_act`
or `pre_observe`.
PRE_ACT: The agent has received a request to act. Components are being
requested for their action context. This will be followed by `POST_ACT`.
POST_ACT: The agent has just submitted an action attempt. Components are
being informed of the action attempt. This will be followed by
`UPDATE`.
PRE_OBSERVE: The agent has received an observation. Components are being
informed of the observation. This will be followed by `POST_OBSERVE`.
POST_OBSERVE: The agent has just observed. Components are given a chance to
provide context after processing the observation. This will be followed by
`UPDATE`.
UPDATE: The agent is about to update its internal state. This will be
followed by `PRE_ACT` or `PRE_OBSERVE`.
"""
INIT = enum.auto()
PRE_ACT = enum.auto()
POST_ACT = enum.auto()
PRE_OBSERVE = enum.auto()
POST_OBSERVE = enum.auto()
UPDATE = enum.auto()


class BaseComponent:
"""A base class for components."""

Expand Down Expand Up @@ -199,7 +170,6 @@ class ContextProcessorComponent(BaseComponent, metaclass=abc.ABCMeta):
@abc.abstractmethod
def process(
self,
phase: Phase,
contexts: ComponentContextMapping,
) -> None:
"""Processes the context from components.
Expand All @@ -209,6 +179,5 @@ def process(
internal state or access other components.
Args:
phase: The phase in which the context is being processed.
contexts: The context from other components.
"""

0 comments on commit 76a4568

Please sign in to comment.