NamedObject

class negmas.common.NamedObject(name: Optional[str] = None, *, id: Optional[str] = None)[source]

Bases: object

The base class of all named entities.

All named entities need to call this class’s __init__() somewhere during initialization.

Parameters
  • name (str) – The given name of the entity. Notice that the class will add this to a base that depends on the child’s class name.

  • id (str) – A unique identifier in the whole system. In principle you should let the system create this identifier by passing None. In special cases like in serialization you may want to set the id directly

Attributes Summary

id

The unique ID of this entity

name

A convenient name of the entity (intended primarily for printing/logging/debugging).

uuid

The unique ID of this entity

Methods Summary

checkpoint(path[, file_name, info, …])

Saves a checkpoint of the current object at the given path.

checkpoint_info(file_name)

Returns the information associated with a dump of the object saved in the given file

create(*args, **kwargs)

Creates an object and returns a proxy to it.

from_checkpoint(file_name[, return_info])

Creates an object from a saved checkpoint

spawn([spawn_as, spawn_params])

spawn_object(*args, **kwargs)

spawn_process(*args, **kwargs)

spawn_remote_http([remote_http_address, …])

spawn_remote_tcp([remote_tcp_address, …])

spawn_thread(*args, **kwargs)

Attributes Documentation

id

The unique ID of this entity

name

A convenient name of the entity (intended primarily for printing/logging/debugging).

uuid

The unique ID of this entity

Methods Documentation

checkpoint(path: Union[pathlib.Path, str], file_name: Optional[str] = None, info: Optional[Dict[str, Any]] = None, exist_ok: bool = False, single_checkpoint: bool = True, step_attribs: Tuple[str] = ('current_step', '_current_step', '_Entity__current_step', '_step'))pathlib.Path[source]

Saves a checkpoint of the current object at the given path.

Parameters
  • path – Full path to a directory to store the checkpoint

  • file_name – Name of the file to dump into. If not given, a unique name is created

  • info – Information to save with the checkpoint (must be json serializable)

  • exist_ok – If true, override existing dump

  • single_checkpoint – If true, keep a single checkpoint for the last step

  • step_attribs – Attributes to represent the time-step of the object. Any of the given attributes will be used in the file name generated if single_checkpoint is False. If single_checkpoint is True, the filename will not contain time-step information

Returns

full path to the file used to save the checkpoint

classmethod checkpoint_info(file_name: Union[str, pathlib.Path])Dict[str, Any][source]

Returns the information associated with a dump of the object saved in the given file

Parameters

file_name – Name of the object

Returns:

classmethod create(*args, **kwargs)[source]

Creates an object and returns a proxy to it.

classmethod from_checkpoint(file_name: Union[str, pathlib.Path], return_info=False)Union[negmas.common.NamedObject, Tuple[negmas.common.NamedObject, Dict[str, Any]]][source]

Creates an object from a saved checkpoint

Parameters
  • file_name

  • return_info – If True, tbe information saved when the file was dumped are returned

Returns

Either the object or the object and dump-info as a dict (if return_info was true)

Remarks:

  • If info is returned, it is guaranteed to have the following members:
    • time: Dump time

    • type: Type of the dumped object

    • id: ID

    • name: name

classmethod spawn(spawn_as='object', spawn_params: Optional[Dict[str, Any]] = None, *args, **kwargs)[source]
classmethod spawn_object(*args, **kwargs)[source]
classmethod spawn_process(*args, **kwargs)[source]
classmethod spawn_remote_http(remote_http_address: str = 'localhost', remote_http_port: Optional[int] = None, *args, **kwargs)[source]
classmethod spawn_remote_tcp(remote_tcp_address: str = 'localhost', remote_tcp_port: Optional[int] = None, *args, **kwargs)[source]
classmethod spawn_thread(*args, **kwargs)[source]