- log current git commit hash
- diffs of current repo state
- pytorch-lightning integration
- view logs in terminal
- view logs in tensorboard
Requires:
- python + pip
- tensorboard
- pytorch
- OPTIONAL: tensorflow
Note: Full tensorflow installation is required to view logs in tensorboard. This is currently a requirement for all custom plugins. The plugin will still log without tensorflow, and logs can be viewed in the terminal (see below).
Ensure you have the above dependencies, then run:
pip install git+ssh://git@github.com/meltzerpete/git_logger_for_tensorboard.git#egg=git_logger_for_tensorboard
You will need to restart your terminal to use the git_logger_view
command.
With pytorch-lightning:
import pytorch_lightning as pl
from pytorch_lightning.loggers import TensorBoardLogger
from git_logger_for_tensorboard.git_logger import GitLightningLogger
tensorboard_logger = TensorBoardLogger(save_dir='lightning_logs',
name='my_experiment')
tb_logger = TensorBoardLogger(save_dir='lightning_logs',
name='my_model')
GitLightningLogger(tb_logger).log() # all git info/patches are logged to the current lightning run dir
trainer = pl.Trainer(*usual_args,
logger=tensorboard_logger)
...
With pytorch only:
from torch.utils.tensorboard import SummaryWriter
from git_logger_for_tensorboard.git_logger import GitLogger
summary_writer = SummaryWriter(log_dir='demo6')
GitLogger(summary_writer).log() # all git info/patches are logged to the log_dir
...
Simply go to the GIT_LOGGER
tab in tensorboard (see image at top of page).
Clicking a repository will take you there in the browser, clicking a commit hash will copy it to clipboard, and clicking a patch will download it as a file.
You can view the logs in the terminal by running the following (ensure you have restarted your shell after installation from pip):
$ git_logger_view --logdir lightning_logs main ✚ ✱ ◼
Run: lightning_logs/my_model/version_0
- branch: main
- remote_url: git@github.com:meltzerpete/git_logger_for_tensorboard.git
- last_commit: b7f80b13961c5f66b4c7ca088457c3c979651a1d
- last_upstream: b7f80b13961c5f66b4c7ca088457c3c979651a1d
- patch: True
- upstream_patch: False
...
patch
and upstream_patch
indicate if a patch is saved (because there were local differences against the commits),
and you can view these as follows:
$ git_logger_view --patch lightning_logs/my_model/version_0
# or --upstream_patch
or save them to file with:
$ git_logger_view --patch lightning_logs/my_model/version_0 > my_diff.patch
# or --upstream_patch