Пример #1
0
 def _log_commit_id(self):
     id = None
     if fastgit:
         fastgit.commit()
         id = fastgit.get_commit_id()
     e = Event(name='$commit-id$', val=id)
     self._meta_writer.add_event(e)
Пример #2
0
 def add_scalar_dict(self, name, scalar_dict, step=None):
     if step is None:
         step = self.get_step(name)
     e = Event(time=self.delta_time(),
               step=step,
               name=name,
               val=scalar_dict)
     self._event_writer.add_event(e)
Пример #3
0
 def _log_start_time(self, time=None):
     if time is None:
         self._start_time = T.time()
     else:
         if not isinstance(time, (int, float)):
             raise TypeError('time must be int or float')
         self._start_time = time
     t = datetime.datetime.fromtimestamp(self._start_time)
     e = Event(name='$start-time$', val=t.strftime('%Y-%m-%d %H:%M:%S'))
     self._meta_writer.add_event(e)
Пример #4
0
 def add_config(self, cfg_dict):
     for name, val in cfg_dict.items():
         e = Event(name=name, val=val)
         self._meta_writer.add_event(e)
Пример #5
0
 def _log_rng_seeds(self, seed=None):
     # TODO add more seed if need
     seed = set_rng_seeds(seed)
     self._rng_seed = seed
     e = Event(name='$rng-seed$', val=seed)
     self._meta_writer.add_event(e)
Пример #6
0
from fastlog.writer import FileWriter, Event
from fastlog import Logger
from fastlog import LogReader
import os
import json

events = [
    Event(step=1, time=None, name='loss', val=10.2),
    Event(step=2, time=12, name='loss', val=20.5),
    Event(step=3, time=None, name='loss', val=13.2),
    Event(step=4, time=13, name='loss', val=4.2),
    Event(step=5, time=20, name=None, val=50.2),
    Event(step=6, time=100, name='loss', val=6.2),
    Event(step=7, time=101, name='loss', val=None),
    Event(step=8, time=102, name='loss', val=8.2),
]


class TestWriter():
    fn = 'test_writer.log'

    def test1(self):
        w = FileWriter(self.fn)
        try:
            w.add_str('=' * 10)
            for e in events:
                w.add_event(e)
            w.add_str('=' * 10)
        finally:
            w.close()