@@ -49,7 +49,6 @@ class DmEnvAdaptor(dm_env.Environment):
49
49
Users can also optionally provide a mapping of objects to DmEnvAdaptor
50
50
attributes. This is to accommodate user-created protocol extensions that
51
51
compliment the core protocol.
52
-
53
52
"""
54
53
55
54
# Disable pytype attribute checking for dynamically created extension attrs.
@@ -285,12 +284,16 @@ def create_world(connection: dm_env_rpc_connection.ConnectionType,
285
284
Args:
286
285
connection: An instance of Connection already connected to a dm_env_rpc
287
286
server.
288
- create_world_settings: Settings used to create the world. Values must be
289
- packable into a Tensor proto or already packed.
287
+ create_world_settings: Settings used to create the world. Nested settings
288
+ will be automatically flattened before sending to the server. Values must
289
+ be packable into a Tensor proto or already packed.
290
290
291
291
Returns:
292
292
Created world name.
293
293
"""
294
+ create_world_settings = dm_env_flatten_utils .flatten_dict (
295
+ create_world_settings , DEFAULT_KEY_SEPARATOR
296
+ )
294
297
295
298
create_world_settings = {
296
299
key : (value if isinstance (value , dm_env_rpc_pb2 .Tensor ) else
@@ -314,14 +317,18 @@ def join_world(
314
317
connection: An instance of Connection already connected to a dm_env_rpc
315
318
server.
316
319
world_name: Name of the world to join.
317
- join_world_settings: Settings used to join the world. Values must be
320
+ join_world_settings: Settings used to join the world. Nested settings will
321
+ be automatically flattened before sending to the server. Values must be
318
322
packable into a Tensor message or already packed.
319
323
**adaptor_kwargs: Additional keyword args used to create the DmEnvAdaptor
320
324
instance.
321
325
322
326
Returns:
323
327
Instance of DmEnvAdaptor.
324
328
"""
329
+ join_world_settings = dm_env_flatten_utils .flatten_dict (
330
+ join_world_settings , DEFAULT_KEY_SEPARATOR
331
+ )
325
332
326
333
join_world_settings = {
327
334
key : (value if isinstance (value , dm_env_rpc_pb2 .Tensor ) else
@@ -356,7 +363,8 @@ def create_and_join_world(connection: dm_env_rpc_connection.ConnectionType,
356
363
server.
357
364
create_world_settings: Settings used to create the world. Values must be
358
365
packable into a Tensor proto or already packed.
359
- join_world_settings: Settings used to join the world. Values must be
366
+ join_world_settings: Settings used to join the world. Nested settings will
367
+ be automatically flattened before sending to the server. Values must be
360
368
packable into a Tensor message.
361
369
**adaptor_kwargs: Additional keyword args used to create the DmEnvAdaptor
362
370
instance.
@@ -372,4 +380,3 @@ def create_and_join_world(connection: dm_env_rpc_connection.ConnectionType,
372
380
except (error .DmEnvRpcError , ValueError ):
373
381
connection .send (dm_env_rpc_pb2 .DestroyWorldRequest (world_name = world_name ))
374
382
raise
375
-
0 commit comments