Skip to content

Commit

Permalink
Add the option to set the orchestrator/datastore ports in Cogment
Browse files Browse the repository at this point in the history
Add ParallelEnvironment to default exports from envs
  • Loading branch information
RedTachyon committed Jan 18, 2024
1 parent 206ec3b commit a58f860
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

- Added guided tutorial notebooks
- Added an option to customize the orchestrator and datastore ports
- Added ParallelEnvironment as a default export from envs
- Added a placeholder image for the web UI
- Updated the uvicorn dependency to require the [standard] option

## v0.1.0 - 2024-01-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion cogment_lab/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.

from cogment_lab.envs.gymnasium import GymEnvironment
from cogment_lab.envs.pettingzoo import AECEnvironment
from cogment_lab.envs.pettingzoo import AECEnvironment, ParallelEnvironment
18 changes: 8 additions & 10 deletions cogment_lab/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
)


ORCHESTRATOR_ENDPOINT = "grpc://localhost:9000"
ENVIRONMENT_ENDPOINT = "grpc://localhost:9001"
RANDOM_AGENT_ENDPOINT = "grpc://localhost:9002"
HUMAN_AGENT_ENDPOINT = "grpc://localhost:8999"
DATASTORE_ENDPOINT = "grpc://localhost:9003"


AgentName = str
ImplName = str
TrialName = str
Expand All @@ -60,6 +53,8 @@ def __init__(
torch_mode: bool = False,
log_dir: str | None = None,
mp_method: str | None = None,
orchestrator_port: int = 9000,
datastore_port: int = 9003,
):
"""Initializes the Cogment instance
Expand All @@ -79,9 +74,12 @@ def __init__(
self.envs: dict[ImplName, BaseEnv] = {}
self.actors: dict[ImplName, BaseActor] = {}

self.orchestrator_endpoint = f"grpc://localhost:{orchestrator_port}"
self.datastore_endpoint = f"grpc://localhost:{datastore_port}"

self.context = cogment.Context(cog_settings=cog_settings, user_id=user_id)
self.controller = self.context.get_controller(endpoint=cogment.Endpoint(ORCHESTRATOR_ENDPOINT))
self.datastore = self.context.get_datastore(endpoint=cogment.Endpoint(DATASTORE_ENDPOINT))
self.controller = self.context.get_controller(endpoint=cogment.Endpoint(self.orchestrator_endpoint))
self.datastore = self.context.get_datastore(endpoint=cogment.Endpoint(self.datastore_endpoint))

self.env_ports: dict[ImplName, int] = {}
self.actor_ports: dict[ImplName, int] = {}
Expand Down Expand Up @@ -466,7 +464,7 @@ async def start_trial(
environment_config=env_config,
actors=actor_params,
environment_implementation=env_name,
datalog_endpoint=DATASTORE_ENDPOINT,
datalog_endpoint=self.datastore_endpoint,
)

trial_id = await self.controller.start_trial(trial_id_requested=trial_name, trial_params=trial_params)
Expand Down

0 comments on commit a58f860

Please sign in to comment.