Notifier

class negmas.events.Notifier(name=None, *, id=None, type_name=None)[source]

Bases: NamedObject

An object that can notify other objects

Attributes Summary

id

The unique ID of this entity

name

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

short_type_name

type_name

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

notify(notifiable, notification)

set_id(id)

Sets the unique ID of this entity

spawn([spawn_as, spawn_params])

spawn_object(*args, **kwargs)

Attributes Documentation

id

The unique ID of this entity

name

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

short_type_name
type_name
uuid

The unique ID of this entity

Methods Documentation

checkpoint(path, file_name=None, info=None, exist_ok=False, single_checkpoint=True, step_attribs=('current_step', '_current_step', '_Entity__current_step', '_step'))

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

Parameters:
  • path (PathLike) – Full path to a directory to store the checkpoint

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

  • info (dict[str, Any] | None) – Information to save with the checkpoint (must be json serializable)

  • exist_ok (bool) – If true, override existing dump

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

  • step_attribs (tuple[str, ...]) – 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

Return type:

Path

Returns:

full path to the file used to save the checkpoint

classmethod checkpoint_info(file_name)

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

Parameters:

file_name (Path | str) – Name of the object

Return type:

dict[str, Any]

Returns:

classmethod create(*args, **kwargs)

Creates an object and returns a proxy to it.

classmethod from_checkpoint(file_name, return_info=False)

Creates an object from a saved checkpoint

Parameters:
  • file_name (Path | str)

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

Return type:

NamedObject | tuple[NamedObject, dict[str, Any]]

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

notify(notifiable, notification)[source]
set_id(id)

Sets the unique ID of this entity

classmethod spawn(spawn_as='object', spawn_params=None, *args, **kwargs)
classmethod spawn_object(*args, **kwargs)