-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Currently the events api requires writing start and end events when we want to track duration of an operation in the trainer. Such as -
experiment.log_event(Event(name="data_download_start", source=EventSource(name="trainer"), wallclock_time = int(time.time()) , metadata={}))
trainset = datasets.CIFAR10(data_dir, transform=data_tfms["train"], download=True)
experiment.log_event(Event(name="data_download_finish", source=EventSource(name="trainer"), wallclock_time = int(time.time()) , metadata={}))
The UX for the same could be improved if we use -
- python contexts for logging events at the start and end of a block of a code.
- decorators to log events at the start and end of a function.
So something of the nature -
with experiment.track_duration(event_name="data_download", source = "trainer") as duration_logger:
trainset = datasets.CIFAR10(data_dir, transform=data_tfms["train"], download=True)
Under the hood, the new track_duration method in Experiment will return a DurationLogger object with the experiment object inside it and other metadata being passed in the method, and in the enter log the start event and in exit log the end event.
So something like this -
class DurationLogger:
def __init__(self, name: str, source:str):
self._experiment = experiment
self._name = name
self._source = source
def __enter__(self):
self._experiment.log_event(.... start event... )
def __exit__(self):
self._experiment.log_event(...end event)
Metadata
Metadata
Assignees
Labels
No labels