drytorch.core.log_events

Classes containing logging event classes.

Classes

ActorRegistrationEvent(actor_name, actor_ts, ...)

Event logged when a source has been registered.

EndEpochEvent(source_name, model_name, epoch)

Event logged when an epoch ends.

EndTestEvent(source_name, model_name)

Event logged when a test is ended.

EndTrainingEvent(source_name)

Event logged when training ends.

Event()

Class for logging events.

IterateBatchEvent(source_name, batch_size, ...)

Event logged to create during batch iteration.

LearningRateEvent(model_name, source_name, epoch)

Event logged when the learning rate is updated.

LoadModelEvent(model_name, definition, ...)

Event logged when a model is loaded.

MetricEvent(model_name, source_name, epoch, ...)

Event logged when metrics from the dataset are aggregated.

ModelRegistrationEvent(model_name, model_ts, ...)

Event logged when a model is created.

SaveModelEvent(model_name, definition, ...)

Event logged when a checkpoint is saved.

StartEpochEvent(source_name, model_name, epoch)

Event logged when an epoch starts.

StartExperimentEvent(config, exp_name, ...)

Event logged when an experiment starts.

StartTestEvent(source_name, model_name)

Event logged when a test is started.

StartTrainingEvent(source_name, model_name, ...)

Event logged when training starts.

StopExperimentEvent(exp_name, run_id)

Event logged when an experiment stops.

TerminatedTrainingEvent(source_name, ...)

Event logged when training is terminated.

class ActorRegistrationEvent(actor_name: str, actor_ts: datetime, model_name: str, model_ts: datetime, metadata: dict[str, Any])[source]

Bases: Event

Event logged when a source has been registered.

Parameters:
actor_name

the name of the caller.

Type:

str

actor_ts

the source’s timestamp.

Type:

datetime.datetime

model_name

the name of the model that was called.

Type:

str

model_ts

the model’s timestamp.

Type:

datetime.datetime

metadata

additional metadata about the caller.

Type:

dict[str, Any]

class EndEpochEvent(source_name: str, model_name: str, epoch: int)[source]

Bases: Event

Event logged when an epoch ends.

Parameters:
  • source_name (str)

  • model_name (str)

  • epoch (int)

source_name

the name of the object that is training a model.

Type:

str

model_name

the name of the model.

Type:

str

epoch

the epoch that was trained.

Type:

int

class EndTestEvent(source_name: str, model_name: str)[source]

Bases: Event

Event logged when a test is ended.

Parameters:
  • source_name (str)

  • model_name (str)

source_name

the name of the object calling the test.

Type:

str

model_name

the name of the model.

Type:

str

class EndTrainingEvent(source_name: str)[source]

Bases: Event

Event logged when training ends.

Parameters:

source_name (str)

source_name

The name of the object that is training a model.

Type:

str

class Event[source]

Bases: object

Class for logging events.

__post_init__() None[source]

Publish the event on creation.

Return type:

None

static set_auto_publish(func: Callable[[Event], None] | None) None[source]

Specify how to notify subscribers upon creation.

Parameters:

func (Callable[[Event], None] | None)

Return type:

None

class IterateBatchEvent(source_name: str, batch_size: int | None, n_iter: int, dataset_size: int, push_updates: list[~collections.abc.Callable[[~collections.abc.Mapping[str, ~typing.Any], int], None]] = <factory>)[source]

Bases: Event

Event logged to create during batch iteration.

Parameters:
source_name

the object calling the iteration.

Type:

str

batch_size

the size of the mini-batch.

Type:

int | None

n_iter

the number of iterations planned.

Type:

int

dataset_size

the size of the dataset.

Type:

int

push_updates

callbacks from loggers that require push updates.

Type:

list[collections.abc.Callable[[collections.abc.Mapping[str, Any], int], None]]

update(metrics: Mapping[str, Any], n_processes: int = 1) None[source]

Push the updated metrics to the loggers.

Parameters:
  • metrics (Mapping[str, Any]) – calculated values by metric name.

  • n_processes (int) – number of processes used for data loading.

Return type:

None

class LearningRateEvent(model_name: str, source_name: str, epoch: int, base_lr: Mapping[str, float] | float | None = None, scheduler_name: str | None = None)[source]

Bases: Event

Event logged when the learning rate is updated.

Parameters:
model_name

the name of the model.

Type:

str

source_name

the name of the object that computed the metrics.

Type:

str

epoch

the number of epochs the model was trained.

Type:

int

base_lr

new value(s) for the learning rate(s).

Type:

collections.abc.Mapping[str, float] | float | None

scheduler_name

the representation of the scheduler.

Type:

str | None

class LoadModelEvent(model_name: str, definition: str, location: str, epoch: int)[source]

Bases: Event

Event logged when a model is loaded.

Parameters:
  • model_name (str)

  • definition (str)

  • location (str)

  • epoch (int)

model_name

the name of the model.

Type:

str

definition

specifies what was loaded.

Type:

str

location

the location where the model is loaded from.

Type:

str

epoch

the epoch at which the model was loaded.

Type:

int

class MetricEvent(model_name: str, source_name: str, epoch: int, metrics: Mapping[str, float])[source]

Bases: Event

Event logged when metrics from the dataset are aggregated.

Parameters:
model_name

the name of the model.

Type:

str

source_name

the name of the object that computed the metrics.

Type:

str

epoch

the number of epochs the model was trained.

Type:

int

metrics

the aggregated metrics.

Type:

collections.abc.Mapping[str, float]

class ModelRegistrationEvent(model_name: str, model_ts: datetime, architecture_repr: str)[source]

Bases: Event

Event logged when a model is created.

Parameters:
model_name

the name of the model.

Type:

str

model_ts

the model’s timestamp.

Type:

datetime.datetime

architecture_repr

the representation of the module architecture.

Type:

str

class SaveModelEvent(model_name: str, definition: str, location: str, epoch: int)[source]

Bases: Event

Event logged when a checkpoint is saved.

Parameters:
  • model_name (str)

  • definition (str)

  • location (str)

  • epoch (int)

model_name

the name of the model.

Type:

str

definition

specifies what was saved.

Type:

str

location

the location where the model is saved.

Type:

str

epoch

the epoch at which the model was saved.

Type:

int

class StartEpochEvent(source_name: str, model_name: str, epoch: int, end_epoch: int | None = None)[source]

Bases: Event

Event logged when an epoch starts.

Parameters:
  • source_name (str)

  • model_name (str)

  • epoch (int)

  • end_epoch (int | None)

source_name

the name of the object that is training a model.

Type:

str

model_name

the name of the model.

Type:

str

epoch

the epoch number.

Type:

int

end_epoch

the final epoch number for the current training session.

Type:

int | None

class StartExperimentEvent(config: Any, exp_name: str, run_ts: datetime, run_id: str, resumed: bool = False, par_dir: Path = PosixPath('.'), tags: list[str] = <factory>)[source]

Bases: Event

Event logged when an experiment starts.

Parameters:
config

configuration for the experiment.

Type:

Any

exp_name

the name of the experiment.

Type:

str

run_ts

run’s timestamp.

Type:

datetime.datetime

run_id

identifier of the run.

Type:

str

resumed

this run was resumed.

Type:

bool

par_dir

the parent directory for the experiment.

Type:

pathlib.Path

tags

descriptors for the experiment’s variation (e.g., “lr=0.01”).

Type:

list[str]

class StartTestEvent(source_name: str, model_name: str)[source]

Bases: Event

Event logged when a test is started.

Parameters:
  • source_name (str)

  • model_name (str)

source_name

the name of the object calling the test.

Type:

str

model_name

the name of the model.

Type:

str

class StartTrainingEvent(source_name: str, model_name: str, start_epoch: int, end_epoch: int)[source]

Bases: Event

Event logged when training starts.

Parameters:
  • source_name (str)

  • model_name (str)

  • start_epoch (int)

  • end_epoch (int)

source_name

the object that is training a model.

Type:

str

model_name

the name of the model.

Type:

str

start_epoch

the starting epoch of the training.

Type:

int

end_epoch

the ending epoch of the training.

Type:

int

class StopExperimentEvent(exp_name: str, run_id: str)[source]

Bases: Event

Event logged when an experiment stops.

Parameters:
exp_name

the name of the experiment.

Type:

str

run_id

identifier of the run.

Type:

str

class TerminatedTrainingEvent(source_name: str, model_name: str, epoch: int, reason: str)[source]

Bases: Event

Event logged when training is terminated.

Parameters:
  • source_name (str)

  • model_name (str)

  • epoch (int)

  • reason (str)

source_name

the name object calling the termination.

Type:

str

model_name

the name of the model.

Type:

str

epoch

the epoch at which training was terminated.

Type:

int

reason

the cause of the termination.

Type:

str