From 8d4c23dd860927afdd70fe90ddf64b5afb4dfa03 Mon Sep 17 00:00:00 2001
From: Manos Angelidis <angelidis@fortiss.org>
Date: Fri, 17 Dec 2021 11:49:19 +0000
Subject: [PATCH] Merged in NRRPLT-8424 (pull request #38)

[NRRPLT-8424] Added the recording path in the launch experiment function

* [NRRPLT-8424] Added the recording path in the launch experiment function

* [NRRPLT-8424] Fix for pylint complains
* Merged development into NRRPLT-8424
* Merged development into NRRPLT-8424

Approved-by: Eloy Retamino
---
 hbp_nrp_virtual_coach/pynrp/simulation.py               | 6 ++++--
 hbp_nrp_virtual_coach/pynrp/tests/test_virtual_coach.py | 2 +-
 hbp_nrp_virtual_coach/pynrp/virtual_coach.py            | 8 +++++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/hbp_nrp_virtual_coach/pynrp/simulation.py b/hbp_nrp_virtual_coach/pynrp/simulation.py
index ea5b829..1b8de48 100644
--- a/hbp_nrp_virtual_coach/pynrp/simulation.py
+++ b/hbp_nrp_virtual_coach/pynrp/simulation.py
@@ -92,7 +92,7 @@ class Simulation(object):
 
     # pylint: disable=too-many-locals, too-many-arguments
     def launch(self, experiment_id, experiment_conf, server, reservation, cloned=True,
-               storage_token=None, brain_processes=1, profiler='disabled'):
+               storage_token=None, brain_processes=1, profiler='disabled', recordingPath=None):
         """
         Attempt to launch and initialize the given experiment on the given servers. This
         should not be directly invoked by users, use the VirtualCoach interface to validate
@@ -107,6 +107,7 @@ class Simulation(object):
         :param storage_token: A string representing the token for storage authorization.
         :param brain_processes: Number of mpi processes in the brain simulation.
         :param profiler: profiler option. Possible values are: disabled, cle_step and cprofile.
+        :param recordingPath: (optional) the path to a the zip of a recording.
         """
         assert isinstance(experiment_id, string_types)
         assert isinstance(experiment_conf, string_types)
@@ -142,7 +143,8 @@ class Simulation(object):
                         'experimentConfiguration': experiment_conf,
                         'gzserverHost': self.__server_info['serverJobLocation'],
                         'reservation': reservation,
-                        'private': cloned}
+                        'private': cloned,
+                        'playbackPath': recordingPath}
 
             status_code, sim_json = self.__http_client.post(url, sim_info)
 
diff --git a/hbp_nrp_virtual_coach/pynrp/tests/test_virtual_coach.py b/hbp_nrp_virtual_coach/pynrp/tests/test_virtual_coach.py
index 7405371..c5fef8b 100644
--- a/hbp_nrp_virtual_coach/pynrp/tests/test_virtual_coach.py
+++ b/hbp_nrp_virtual_coach/pynrp/tests/test_virtual_coach.py
@@ -384,7 +384,7 @@ mock-server-5
         self._vc._VirtualCoach__http_headers = {'Authorization': 'token'}
 
         def launch(experiment_id, experiment_conf, server, reservation, cloned, token,
-                   brain_processes=1, profiler='disabled'):
+                   brain_processes=1, profiler='disabled', recordingPath=None):
             if server == 'mock-server-1':
                 raise Exception('fake failure!')
             return True
diff --git a/hbp_nrp_virtual_coach/pynrp/virtual_coach.py b/hbp_nrp_virtual_coach/pynrp/virtual_coach.py
index 9914902..da450c9 100644
--- a/hbp_nrp_virtual_coach/pynrp/virtual_coach.py
+++ b/hbp_nrp_virtual_coach/pynrp/virtual_coach.py
@@ -215,9 +215,10 @@ class VirtualCoach(object):
 
         return token
 
+    # pylint: disable-msg=too-many-locals
     def launch_experiment(self, experiment_id,
                           server=None, reservation=None, cloned=True, brain_processes=1,
-                          profiler='disabled'):
+                          profiler='disabled', recordingPath=None):
         """
         Attempts to launch a simulation with the given parameters. If no server is explicitly given
         then all available backend servers will be tried. Only cloned experiments to the Storage
@@ -234,6 +235,7 @@ class VirtualCoach(object):
         :param brain_processes: (optional) Number of mpi processes in the brain simulation.
         :param profiler: (optional) profiler option.
                          Possible values are: disabled, cle_step and cprofile.
+        :param recordingPath: (optional) the path to a the zip of a recording.
         """
         assert isinstance(experiment_id, string_types)
         assert isinstance(server, (string_types, type(None)))
@@ -274,8 +276,8 @@ class VirtualCoach(object):
         sim = Simulation(self.__http_client, self.__config, self)
         for server_i in servers:
             try:
-                if sim.launch(experiment_id, str(experiment_conf), str(server_i),
-                              reservation, cloned, self.__storage_token, brain_processes, profiler):
+                if sim.launch(experiment_id, str(experiment_conf), str(server_i), reservation, 
+                        cloned, self.__storage_token, brain_processes, profiler, recordingPath):
                     return sim
 
             # pylint: disable=broad-except
-- 
GitLab