Skip to content

Commit

Permalink
[env_c_api] Remove "fps" and "act"
Browse files Browse the repository at this point in the history
These functions were deprecated in v1.4 and are now removed.
  • Loading branch information
tkoeppe committed Mar 4, 2021
1 parent 26e78de commit e51f240
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 45 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# DeepMind Lab Release Notes

## Next Release

### EnvCApi Changes:

1. The new API version is 2.0 (up from 1.4).
2. The EnvCApi functions `fps` and `act` have been removed. See previous
release notes for migration details.

## release-2020-12-07 December 2020 release

### New Levels:
Expand Down
7 changes: 0 additions & 7 deletions engine/code/deepmind/dmlab_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,11 +1153,6 @@ static void dmlab_act_discrete(void* context, const int act_d[]) {
static void dmlab_act_continuous(void* context, const double act_c[]) {}
static void dmlab_act_text(void* context, const EnvCApi_TextAction act_c[]) {}

static void dmlab_act(void* context, const int act_d[], const double act_c[]) {
dmlab_act_discrete(context, act_d);
dmlab_act_continuous(context, act_c);
}

static double get_engine_score(void) {
return cl.snap.ps.persistant[PERS_SCORE];
}
Expand Down Expand Up @@ -1507,11 +1502,9 @@ int dmlab_connect(const DeepMindLabLaunchParams* params, EnvCApi* env_c_api,
env_c_api->observation_spec = dmlab_observation_spec;
env_c_api->event_type_count = dmlab_event_type_count;
env_c_api->event_type_name = dmlab_event_type_name;
env_c_api->fps = dmlab_fps;
env_c_api->observation = dmlab_observation;
env_c_api->event_count = dmlab_event_count;
env_c_api->event = dmlab_event;
env_c_api->act = dmlab_act;
env_c_api->act_discrete = dmlab_act_discrete;
env_c_api->act_continuous = dmlab_act_continuous;
env_c_api->act_text = dmlab_act_text;
Expand Down
9 changes: 0 additions & 9 deletions python/dmlab_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,6 @@ static PyObject* Lab_observation_spec(PyObject* pself, PyObject* no_arg) {
return result;
}

static PyObject* Lab_fps(PyObject* self, PyObject* no_arg) {
return PyInt_FromLong(
((LabObject*)self)->env_c_api->fps(((LabObject*)self)->context));
}

static PyObject* Lab_action_spec(PyObject* pself, PyObject* no_arg) {
LabObject* self = (LabObject*)pself;
PyObject* discrete;
Expand Down Expand Up @@ -801,10 +796,6 @@ static PyMethodDef LabObject_methods[] = {
"Advance the environment a number of steps"},
{"observation_spec", Lab_observation_spec, METH_NOARGS,
"The shape of the observations"},
{"fps", Lab_fps, METH_NOARGS,
"An advisory metric that correlates discrete environment steps "
"(\"frames\") with real (wallclock) time: the number of frames per (real) "
"second."},
{"action_spec", Lab_action_spec, METH_NOARGS, "The shape of the actions"},
{"observations", Lab_observations, METH_NOARGS, "Get the observations"},
{"events", Lab_events, METH_NOARGS, "Get the events"},
Expand Down
2 changes: 1 addition & 1 deletion testing/recording_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ TEST_F(RecordingTest, TotalScorePreserved) {
// Record one second of frames. Repeat twice to advance through two maps.
double recording_reward_1;
const int move_forward[] = {0, 0, 0, 1, 0, 0, 0};
env_c_api.act(context, move_forward, nullptr);
env_c_api.act_discrete(context, move_forward);
env_c_api.advance(context, kFramesPerSecond, &recording_reward_1);
double recording_reward_2;
env_c_api.advance(context, kFramesPerSecond, &recording_reward_2);
Expand Down
20 changes: 3 additions & 17 deletions third_party/rl_api/env_c_api.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2019 Google Inc.
// Copyright 2016-2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,8 +84,8 @@
// and DEEPMIND_ENV_C_API_VERSION_MINOR through the initial creation
// function call.
//
#define DEEPMIND_ENV_C_API_VERSION_MAJOR 1
#define DEEPMIND_ENV_C_API_VERSION_MINOR 4
#define DEEPMIND_ENV_C_API_VERSION_MAJOR 2
#define DEEPMIND_ENV_C_API_VERSION_MINOR 0

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -391,12 +391,6 @@ struct EnvCApi_s {
// 'event_type_idx' shall be in range [0, event_type_count()).
const char* (*event_type_name)(void* context, int event_type_idx);

// DEPRECATED: use properties to communicate this information.
//
// An advisory metric that correlates discrete environment steps ("steps")
// with real (wallclock) time: the number of steps per (real) second.
int (*fps)(void* context);

// Run loop
///////////
//
Expand All @@ -421,14 +415,6 @@ struct EnvCApi_s {
// 'event' is invalidated by any other API call.
void (*event)(void* context, int event_idx, EnvCApi_Event* event);

// DEPRECATED: use act_discrete, act_continuous instead.
//
// Calling this function shall be equivalent to a call of
// 'act_discrete(context, actions discrete)' followed by a call of
// 'act_continuous(context, actions_continuous)'.
void (*act)(void* context,
const int actions_discrete[], const double actions_continuous[]);

// Sets the discrete actions to use by future calls of 'advance'.
// Actions are "sticky", and the same action values will continue to be used
// by 'advance' until the actions are changed by this function.
Expand Down
2 changes: 0 additions & 2 deletions third_party/rl_api/env_c_api_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ void Bind(std::unique_ptr<T> env, EnvCApi* api, void** context) {
api->observation_spec = DEEPMIND_RL_API_BIND(ObservationSpec);
api->event_type_count = DEEPMIND_RL_API_BIND(EventTypeCount);
api->event_type_name = DEEPMIND_RL_API_BIND(EventTypeName);
api->fps = DEEPMIND_RL_API_BIND(Fps);
api->observation = DEEPMIND_RL_API_BIND(Observation);
api->event_count = DEEPMIND_RL_API_BIND(EventCount);
api->event = DEEPMIND_RL_API_BIND(Event);
api->act = DEEPMIND_RL_API_BIND(Act);
api->act_discrete = DEEPMIND_RL_API_BIND(ActDiscrete);
api->act_continuous = DEEPMIND_RL_API_BIND(ActContinuous);
api->act_text = DEEPMIND_RL_API_BIND(ActText);
Expand Down
7 changes: 0 additions & 7 deletions third_party/rl_api/env_c_api_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ class MyGame {
int EventTypeCount() const { return 0; }
const char* EventTypeName(int event_type_idx) const { std::abort(); }

int Fps() { return 60; }

void Observation(int observation_idx, EnvCApi_Observation* observation) {
ObservationSpec(observation_idx, &observation->spec);
switch (observation_idx) {
Expand All @@ -182,11 +180,6 @@ class MyGame {

void Event(int event_idx, EnvCApi_Event* event) {}

void Act(const int actions_discrete[], const double actions_continuous[]) {
ActDiscrete(actions_discrete);
ActContinuous(actions_continuous);
}

void ActDiscrete(const int actions_discrete[]) {}
void ActContinuous(const double actions_continuous[]) {}
void ActText(const EnvCApi_TextAction actions_continuous[]) {}
Expand Down
5 changes: 3 additions & 2 deletions third_party/rl_api/env_c_api_example_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ TEST(EnvCApiExampleTest, ObservationDoubles) {
EXPECT_EQ(127.0, v);
}
}
EnvCApi_TextAction textAction{ kTextActions[0], strlen(kTextActions[0])};
env_c_api.act_discrete(context, kDiscreteActions);
env_c_api.act_continuous(context, kContinuousActions);
EnvCApi_TextAction textAction{ kTextActions[0], strlen(kTextActions[0])};
env_c_api.act_text(context, &textAction);
double reward;
EXPECT_EQ(EnvCApi_EnvironmentStatus_Running,
Expand Down Expand Up @@ -384,7 +384,8 @@ TEST(EnvCApiExampleTest, ObservationBytes) {
EXPECT_EQ(127, v);
}
}
env_c_api.act(context, kDiscreteActions, kContinuousActions);
env_c_api.act_discrete(context, kDiscreteActions);
env_c_api.act_continuous(context, kContinuousActions);
double reward;
EXPECT_EQ(EnvCApi_EnvironmentStatus_Running,
env_c_api.advance(context, /*num_steps=*/5, &reward));
Expand Down

0 comments on commit e51f240

Please sign in to comment.