1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14-
1514"""Provide a client to play back a logs directory."""
1615
1716import json
@@ -162,6 +161,12 @@ def transform(self,
162161 if not dir_key :
163162 dir_key = dev_key
164163 msg .depth = os .path .join (self ._abs_path , dir_key , filename )
164+ if not os .path .exists (msg .depth ) and msg .upload_depth :
165+ abs_path , filename = os .path .split (msg .upload_depth )
166+ _ , dir_key = os .path .split (abs_path )
167+ if not dir_key :
168+ dir_key = dev_key
169+ msg .depth = os .path .join (self ._abs_path , dir_key , filename )
165170 return msg , utils .time_at_timestamp (msg .ts ), msg .seq
166171
167172
@@ -185,15 +190,15 @@ class LogsDirectoryClient(playback_client.PlaybackClient):
185190 """Class to implement a logs directory client."""
186191
187192 def __init__ (self , robot_id : str , working_directory : str ,
188- client_id : Optional [str ], select_client : bool ,
193+ client_id : Optional [str ], select_client_id : bool ,
189194 gym_run_id : Optional [str ], select_gym_run : bool ) -> None :
190195 """Init a LogsDirectoryClient.
191196
192197 Args:
193198 robot_id: the robot id to connect to.
194199 working_directory: optional directory to run within.
195200 client_id: the client ID to simulate (e.g. 00005.json vs 00000.json).
196- select_client : if client ID is None, will select first client.
201+ select_client_id : if client ID is None, will select first client.
197202 gym_run_id: if specified, will select the given snapshot by gym_run_id.
198203 select_gym_run: if specified, but gym_run_id is None, will select first
199204 snapshot.
@@ -213,7 +218,7 @@ def __init__(self, robot_id: str, working_directory: str,
213218 device_iterator .start ()
214219 command_iterator .start ()
215220 self .start_playback (device_iterator , command_iterator , client_id ,
216- select_client , gym_run_id , select_gym_run , True )
221+ select_client_id , gym_run_id , select_gym_run , True )
217222 started = True
218223 finally :
219224 if not started :
@@ -222,7 +227,7 @@ def __init__(self, robot_id: str, working_directory: str,
222227
223228
224229def connect_logs_directory (robot_id : str , working_directory : str ,
225- client_id : Optional [str ], select_client : bool ,
230+ client_id : Optional [str ], select_client_id : bool ,
226231 gym_run_id : Optional [str ], select_gym_run : bool ,
227232 kwargs : Dict [str , Any ]) -> host .Host :
228233 """Connect to Reach using TCP on specific host:port.
@@ -231,7 +236,7 @@ def connect_logs_directory(robot_id: str, working_directory: str,
231236 robot_id: the robot id to connect to.
232237 working_directory: optional directory to run within.
233238 client_id: the client ID to simulate.
234- select_client : if client ID is None, will select first client.
239+ select_client_id : if client ID is None, will select first client.
235240 gym_run_id: if specified, will select the given snapshot by gym_run_id.
236241 select_gym_run: if specified, but gym_run_id is None, will select first
237242 snapshot.
@@ -241,5 +246,6 @@ def connect_logs_directory(robot_id: str, working_directory: str,
241246 Host interface if successful.
242247 """
243248 return host_impl .HostImpl (
244- LogsDirectoryClient (robot_id , working_directory , client_id , select_client ,
245- gym_run_id , select_gym_run ), ** kwargs )
249+ LogsDirectoryClient (robot_id , working_directory , client_id ,
250+ select_client_id , gym_run_id , select_gym_run ),
251+ ** kwargs )
0 commit comments