This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrial_datastore.proto
179 lines (140 loc) · 6.63 KB
/
trial_datastore.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// Copyright 2021 AI Redefined Inc. <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package cogmentAPI;
import "cogment/api/common.proto";
// API for trial datastore, it stores trial samples
service TrialDatastoreSP {
// -- Online operations (e.g. during training)
// Retrieve the trials matching the given request
rpc RetrieveTrials(RetrieveTrialsRequest) returns (RetrieveTrialsReply) {}
// Retrieve samples from matching trials, trials can be ongoing
rpc RetrieveSamples(RetrieveSamplesRequest) returns (stream RetrieveSampleReply) {}
// -- Offline trial data managmement operations
// Add a trial to the activity logger, once a trial is added, samples can be retrieved
// Expected header metadata
// - trial-id
rpc AddTrial(AddTrialRequest) returns (AddTrialReply) {}
// Add samples to a trial
// Expected header metadata
// - trial-id
rpc AddSample(stream AddSampleRequest) returns (AddSamplesReply) {}
// Delete the trials matching the given request, on failure no trial is deleted
rpc DeleteTrials(DeleteTrialsRequest) returns (DeleteTrialsReply) {}
}
// --- Reply/Request Messages
message RetrieveTrialsRequest {
repeated string trial_ids = 1; // List of desired trial ids, if empty all trials are returned
uint32 timeout = 2; // Wait for trials that might be created within this duration (in ms).
uint32 trials_count = 3; // Desired number of trial in the reply, 0 means no limit
string trial_handle = 4; // Leave empty for the initial request, use previously
// received `RetrieveTrialsReply.next_trial_handle` and
// provide otherwise the same request to access the next trials
}
message RetrieveTrialsReply {
repeated StoredTrialInfo trial_infos = 1;
string next_trial_handle = 2;
}
message RetrieveSamplesRequest {
// Defines a list of filter that returned samples will all match
repeated string trial_ids = 1; // List of desired trial ids, if empty no data will be returned
repeated string actor_names = 2; // List of desired actor names, if empty all actor samples will be returned
repeated string actor_classes = 3; // List of desired actor classes, if empty all actor samples will be returned
repeated string actor_implementations = 4; // List of desired actor implementations, if empty all actor samples will be returned
repeated StoredTrialSampleField selected_sample_fields = 5; // Which fields of `StoredTrialSample.ActorSample` should be returned, if empty all fields are returned
}
message RetrieveSampleReply {
StoredTrialSample trial_sample = 1;
}
message DeleteTrialsRequest {
repeated string trial_ids = 1;
}
message DeleteTrialsReply {}
message AddTrialRequest {
string user_id = 1;
TrialParams trial_params = 2;
}
message AddTrialReply {}
message AddSampleRequest {
StoredTrialSample trial_sample = 1;
}
message AddSamplesReply {}
// --- TrialDatastore main messages
message StoredTrialInfo {
string trial_id = 1;
TrialState last_state = 2; // Last known trial state
string user_id = 3;
uint32 samples_count = 4;
TrialParams params = 5;
}
message StoredTrialSample {
// Represents a sample generated by a trial at a given tick.
// Data in this sample can be filtered (as specified in `RetrieveSamplesRequest`)
string user_id = 1;
string trial_id = 2;
uint64 tick_id = 3;
fixed64 timestamp = 4; // When tick occured as a nanosecond unix timestamp
TrialState state = 5;
repeated StoredTrialActorSample actor_samples = 6;
repeated bytes payloads = 7; // Grouped payloads of the observations, actions, rewards and messages.
}
enum StoredTrialSampleField {
STORED_TRIAL_SAMPLE_FIELD_UNKNOWN = 0;
STORED_TRIAL_SAMPLE_FIELD_OBSERVATION = 1;
STORED_TRIAL_SAMPLE_FIELD_ACTION = 2;
STORED_TRIAL_SAMPLE_FIELD_REWARD = 3;
STORED_TRIAL_SAMPLE_FIELD_RECEIVED_REWARDS = 4;
STORED_TRIAL_SAMPLE_FIELD_SENT_REWARDS = 5;
STORED_TRIAL_SAMPLE_FIELD_RECEIVED_MESSAGES = 6;
STORED_TRIAL_SAMPLE_FIELD_SENT_MESSAGES = 7;
}
message StoredTrialActorSample {
// Represents a sample generated by an actor in a trial at a given tick
// Only makes sense as a part of StoredTrialSample
// Actor are referenced by their index in the trials' params `TrialParams.actors` field.
// Where it make sense, the actor index can be set to -1 to reference the trial's environment.
//
// Payloads (ie observations data, actions data, reward user data and messages payloads)
// are grouped in the `payloads` field and referenced by their index in this field
uint32 actor = 1; // Index of the actor
// Observation received by the actor at t
optional uint32 observation = 2; // Index in the payload of the parent StoredTrialSample
// Action performed by the actor at t
optional uint32 action = 3; // Index in the payload of the parent StoredTrialSample
// Reward received by the actor for t
optional float reward = 4; // Aggregated reward value
repeated StoredTrialActorSampleReward received_rewards = 6;
// Rewards sent by the actor for t
repeated StoredTrialActorSampleReward sent_rewards = 7;
// Messages received by the actor before t+1
repeated StoredTrialActorSampleMessage received_messages = 8;
// Messages sent by the actor before t+1
repeated StoredTrialActorSampleMessage sent_messages = 9;
}
message StoredTrialActorSampleReward {
// Represents a reward sent or received by an actor
// Only makes sense as a part of StoredTrialActorSample
int32 sender = 1; // Index of the actor, -1 for the environment, ignored for sent rewards
int32 receiver = 2; // Index of the actor, -1 for the environment, ignored for received rewards
float reward = 4;
float confidence = 5;
optional uint32 user_data = 6; // Index in the payload of the parent StoredTrialSample
}
message StoredTrialActorSampleMessage {
// Represents a message sent or received by an actor
// Only makes sense as a part of StoredTrialActorSample
int32 sender = 1; // Index of the actor, -1 for the environment, ignored for sent messages
int32 receiver = 2; // Index of the actor, -1 for the environment, ignored for received messages
uint32 payload = 3; // Index in the payload of the parent StoredTrialSample
}