A tool for recording RL trajectories.

Overview

EnvironmentLogger

EnvLogger is a standard dm_env.Environment class wrapper that records interactions between a real environment and an agent. These interactions are saved on disk as trajectories and can be retrieved in whole, by individual timesteps or by specific episodes.

drawing

Metadata

To better categorize your logged data, you may want to add some tags in the metadata when you construct the logger wrapper. The metadata is written once per EnvLogger instance.

env = envlogger.EnvLogger(
    env,
    data_directory='/tmp/experiment_logs',
    metadata={
        'environment_type': 'dm_control',
        'agent_type': 'D4PG'
    })

Examples

Most of the time, it is just a one-liner wrapper, e.g.

import envlogger
from envlogger.testing import catch_env
import numpy as np

env = catch_env.Catch()
with envlogger.EnvLogger(
    env, data_directory='/tmp/experiment_logs') as env:

  env.reset()
  for step in range(100):
    action = np.random.randint(low=0, high=3)
    timestep = env.step(action)

Reading stored trajectories

Reader can read stored trajectories. Example:

from envlogger import reader

with reader.Reader(
    data_directory='/tmp/experiment_logs') as r:
  for episode in r.episodes:
    for step in episode:
       # step is a step_data.StepData.
       # Use step.timestep.observation, step.timestep.reward, step.action etc...

Getting Started

EnvLogger currently only supports Linux based OSes and Python 3.

You can install EnvLogger via pip:

pip install envlogger
Compiling from source

For this option you will need to install Bazel and GMP (libgmp-dev on Debian-based systems). Please note that Bazel versions >4.0 are not supported. Our recommended version is 3.7.2. Then:

git clone https://github.com/deepmind/envlogger/
cd envlogger
bazel test --test_output=errors envlogger/...
Running inside Docker

We provide a Docker image that can be used to run tests in a more controlled environment. You can run it as follows:

sh docker/build.sh
docker run -it envlogger bash
bazel test --test_output=errors envlogger/...

Benchmarks

Wrapping your environment with EnvLogger adds an approximately 2 millisecond overhead per environment step. See the following difference in distributions in the case of random agent on a 100 steps per second Catch environment (measured in milliseconds).

Percentiles 50th 95th 99th 99.9th mean (± std)
w/o EnvLogger 10.15 10.23 11.51 14.70 10.19 (± 1.06)
w/ EnvLogger 12.65 14.39 15.94 19.43 12.88 (± 0.34)

Acknowledgements

We greatly appreciate all the support from the TF-Agents team in setting up building and testing for EnvLogger.

You might also like...
A rosbag2 recorder node that backs up split files to an external location during recording

System Data Recorder (SDR) A lifecycle node and executable for recording topic data to a rosbag2 bag, while simultaneously copying the split bag files

A GPS bicycle speedometer that supports offline maps and track recording
A GPS bicycle speedometer that supports offline maps and track recording

X-TRACK 开源GPS自行车码表。 拥有可显示实时位置的离线地图。 支持记录和显示实时轨迹以及导出标准GPX格式的轨迹文件。 全新设计的"页面生命周期管理"和"消息订阅发布框架"。 演示视频:https://www.bilibili.com/video/BV1GB4y1K7VV GUI LVGL

Bank Management System is based on a concept of recording customer’s account details

Bank Management System is based on a concept of recording customer’s account details. Here the user can perform all the tasks like creating an account, deposit amount, withdraw amount, check balance, view all account holders detail, close an account and modify an account. There’s no login system for this project. All the main features for banking system are set in this project.

6D - Pose Annotation Tool (6D-PAT) - is a tool that allows the user to load a set of images and also a set of 3D models and annotate where in the 2D image the 3D object ist placed.
6D - Pose Annotation Tool (6D-PAT) - is a tool that allows the user to load a set of images and also a set of 3D models and annotate where in the 2D image the 3D object ist placed.

6D - Pose Annotation Tool (6D-PAT) For detiled explanations checkout the WikiPage. What is it? With 6D-PAT you can create 6D annotations on images for

LZFSE compression library and command line tool

LZFSE This is a reference C implementation of the LZFSE compressor introduced in the Compression library with OS X 10.11 and iOS 9. LZFSE is a Lempel-

Library and command line tool to detect SHA-1 collision in a file

sha1collisiondetection Library and command line tool to detect SHA-1 collisions in files Copyright 2017 Marc Stevens [email protected] Distributed

The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects

olcPixelGameEngine The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects. You only need the one file -

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

DirectX Tool Kit for DirectX 11 http://go.microsoft.com/fwlink/?LinkId=248929 Copyright (c) Microsoft Corporation. All rights reserved. January 9, 202

Minerva: a fast and flexible tool for deep learning on multi-GPU. It provides ndarray programming interface, just like Numpy. Python bindings and C++ bindings are both available. The resulting code can be run on CPU or GPU. Multi-GPU support is very easy. Warp speed Data Transfer (WDT)  is an embeddedable library (and command line tool) aiming to transfer data between 2 systems as fast as possible over multiple TCP paths.
Warp speed Data Transfer (WDT) is an embeddedable library (and command line tool) aiming to transfer data between 2 systems as fast as possible over multiple TCP paths.

WDT Warp speed Data Transfer Design philosophy/Overview Goal: Lowest possible total transfer time - to be only hardware limited (disc or network bandw

A tool for generating cross-language type declarations and interface bindings.

Djinni Djinni is a tool for generating cross-language type declarations and interface bindings. It's designed to connect C++ with either Java or Objec

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

SWIG (Simplified Wrapper and Interface Generator) Version: 4.1.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages

a tool to count accesses to member variables in c++ programs

access_profiler access_profiler is a heavy-weight class field access profiler, implemented as C++ library. to use this profiler, include "access_profi

Bear is a tool that generates a compilation database for clang tooling.

ʕ·ᴥ·ʔ Build EAR Bear is a tool that generates a compilation database for clang tooling. The JSON compilation database is used in the clang project to

Tool to check C++ #include dependencies (dependency graphs created in .dot format)
Tool to check C++ #include dependencies (dependency graphs created in .dot format)

Read Me for Dependency Checker Copyright (C) 2012-2017, TomTom International BV. All rights reserved. The tool cpp-dependencies creates #include depen

A tool for use with clang to analyze #includes in C and C++ source files

Include What You Use For more in-depth documentation, see docs. Instructions for Users "Include what you use" means this: for every symbol (type, func

The approximate regex matching library and agrep command line tool.

Introduction TRE is a lightweight, robust, and efficient POSIX compliant regexp matching library with some exciting features such as approximate (fuzz

Comments
  • importing acme and envlogger crashes

    importing acme and envlogger crashes

    Hello,

    Using a very minimal setup I have an error on import, I guess the name StatusCode is used by both programs in absl...

    conda create -n test_envlogger python=3.7 pip
    conda activate test_envlogger
    pip install tensorflow gym dm-acme[tensorflow] envlogger
    python -c "import acme; import envlogger"
    
    Traceback (most recent call last):
      File "temp_test.py", line 2, in <module>
        import envlogger
      File "/home/vmallet/anaconda3/envs/test_3/lib/python3.7/site-packages/envlogger/__init__.py", line 18, in <module>
        from envlogger import environment_logger
      File "/home/vmallet/anaconda3/envs/test_3/lib/python3.7/site-packages/envlogger/environment_logger.py", line 32, in <module>
        from envlogger.backends import riegeli_backend_writer
      File "/home/vmallet/anaconda3/envs/test_3/lib/python3.7/site-packages/envlogger/backends/riegeli_backend_writer.py", line 24, in <module>
        from envlogger.backends.python import riegeli_dataset_writer
    ImportError: generic_type: cannot initialize type "StatusCode": an object with that name is already defined
    

    I hope you can help me !

    Best, Vincent

    opened by Vincentx15 19
  • Multiprocessed reader

    Multiprocessed reader

    Hello, I'm trying to boost the reading using multiprocessing but I get an error a AttributeError: Can't pickle local object 'BackendReader._get_nth_episode..get_nth_step_from_episode'. Probably the object is not pickable for some reason.

    Any chance you managed to do it on your side? Or would have other hints to boost the reading?

    Thanx.

    enhancement 
    opened by mikygit 9
  • Fatal Python error: Aborted

    Fatal Python error: Aborted

    Hello, I running into an error when playing with the py_writer. I modified it to store 100000 trajectories, which it does apparently by creating a 100000 timestamp subfolders... But it failed to read the data using the following code:

    with reader.Reader(data_directory=_TRAJECTORIES_DIR.value) as r: for i, episode in enumerate(r.episodes): logging.info(f"-------------- {i} --------------------: {len(episode)}")

    Any ideas? Is there a way to gather the stored files into the same subfolders as it seems to be the pb? Thanx.

    WARNING: Logging before InitGoogleLogging() is written to STDERR F20211207 11:48:44.483004 104240 bundle.cc:24] Check failed: finished_ JoinAll() should be called before releasing the bundle. *** Check failure stack trace: *** Fatal Python error: Aborted

    Current thread 0x00007fa729473740 (most recent call first): File "/usr/local/lib/python3.9/dist-packages/envlogger/backends/riegeli_backend_reader.py", line 45 in init File "/usr/local/lib/python3.9/dist-packages/envlogger/reader.py", line 45 in init File "/envlogger/envlogger/backends/cross_language_test/py_writer.py", line 92 in main File "/usr/local/lib/python3.9/dist-packages/absl/app.py", line 258 in _run_main File "/usr/local/lib/python3.9/dist-packages/absl/app.py", line 312 in run File "/envlogger/envlogger/backends/cross_language_test/py_writer.py", line 104 in Aborted (core dumped)

    opened by mikygit 2
  • Python 3.10 Wheel

    Python 3.10 Wheel

    Hi!

    Would it be possible to publish Python 3.10 wheels? Other DeepMind projects are already publishing for 3.10 and it would be really nice to have envlogger.

    Thanks!

    enhancement 
    opened by JesseFarebro 1
Owner
DeepMind
DeepMind
Cute Log is a C++ Library that competes to be a unique logging tool.

Cute Log Cute Log is a C++ Library that competes to be a unique logging tool. Version: 2 Installation Click "Code" on the main repo page (This one.).

null 3 Oct 13, 2022
Compressed Log Processor (CLP) is a free tool capable of compressing text logs and searching the compressed logs without decompression.

CLP Compressed Log Processor (CLP) is a tool capable of losslessly compressing text logs and searching the compressed logs without decompression. To l

null 516 Dec 30, 2022
A gazebo actor plugin that utilizes the map of the environment and graph search methods to generate random actor trajectories that don't pass through walls, furniture, etc.

Gazebo-Map-Actor-Plugin A gazebo actor plugin that utilizes the map of the environment and graph search methods to generate random actor trajectories

Yasin Sonmez 11 Dec 23, 2022
This is a fork of prboom+ with extra tooling for demo recording and playback, with a focus on speedrunning.

dsda-doom v0.15.1 This is a fork of prboom+ with extra tooling for demo recording and playback, with a focus on speedrunning. Heretic Support (beta) D

Ryan Krafnick 135 Jan 8, 2023
An OBS plugin for removing background in portrait images (video), making it easy to replace the background when screen recording.

OBS Plugin: Background Removal Introduction Building MacOSX Linux / Ubuntu Windows Download Check out the latest releases for downloads and install in

Roy Shilkrot 1.4k Jan 8, 2023
⏺️ A simple recording program with the ability to record screens and audio on your computer.

⏺️ A simple recording program with the ability to record screens and audio on your computer.

kimhwan 392 Dec 31, 2022
simple and efficient screen recording utility for Windows

wcap Simple and efficient screen recording utility for Windows. Get latest binary here: wcap.exe press Ctrl + PrintScreen to start recording monitor (

Mārtiņš Možeiko 483 Dec 31, 2022
Simple and efficient screen recording utility for Windows.

simple and efficient screen recording utility for Windows

Mārtiņš Možeiko 484 Dec 31, 2022
recording OSC messages with ofxPubSubOsc

ofxRecordOsc recording OSC with ofxPubSubOsc. Dependencies ofxOsc ofxPubSubOsc 0.3.2- Notice if you got error on ofx::RecordOsc::Player::play, please

ISHII 2bit 5 Nov 21, 2021
ebpf syscall recording demo project

ebpf syscall recording demo project

Sascha Grunert 9 Jun 7, 2022