This is an automated email from the ASF dual-hosted git repository.

jiwq pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 3968cf4  SUBMARINE-542. [SDK] get_log error when experiment is not 
started
3968cf4 is described below

commit 3968cf4375bcc2098d926bb55acac17543b09b44
Author: pingsutw <[email protected]>
AuthorDate: Wed Jun 24 15:08:10 2020 +0800

    SUBMARINE-542. [SDK] get_log error when experiment is not started
    
    ### What is this PR for?
    Fix get_log error when the experiment is not started
    ```bash
    IndexError                                Traceback (most recent call last)
    <ipython-input-13-8bf55eff97d1> in <module>
    ----> 1 
submarine_client.get_log(id)~/opt/anaconda3/envs/python3-7/lib/python3.7/site-packages/submarine/experiment/api/experiment_client.py
 in get_log(self, id, master)
        124
        125         if master is True:
    --> 126             log_contents = [log_contents[0]]
        127
        128         for log_content in log_contents:IndexError: list index out 
of range
    ```
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-542
    
    ### How should this be tested?
    https://travis-ci.org/github/pingsutw/hadoop-submarine/builds/701089803
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: pingsutw <[email protected]>
    Author: HUAN-PING SU <[email protected]>
    
    Closes #323 from pingsutw/SUBMARINE-542 and squashes the following commits:
    
    4620ea3 [pingsutw] Fix checkstyle
    92ae7df [HUAN-PING SU] Update experiment_client.py
    ee63190 [pingsutw] Fix code style
    ce458ad [pingsutw] SUBMARINE-542. [SDK] get_log error when experiment is 
pulling docker images
---
 .../submarine/experiment/api/experiment_client.py   | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/submarine-sdk/pysubmarine/submarine/experiment/api/experiment_client.py 
b/submarine-sdk/pysubmarine/submarine/experiment/api/experiment_client.py
index e8272a9..00adc1d 100644
--- a/submarine-sdk/pysubmarine/submarine/experiment/api/experiment_client.py
+++ b/submarine-sdk/pysubmarine/submarine/experiment/api/experiment_client.py
@@ -65,7 +65,10 @@ class ExperimentClient:
 
     def _log_pod(self, id, index):
         response = self.experiment_api.get_log(id)
-        log_content = response.result['logContent'][0]
+        log_contents = response.result['logContent']
+        if len(log_contents) == 0:
+            return index
+        log_content = log_contents[0]
         for i, log in enumerate(log_content['podLog']):
             if i < index:
                 continue
@@ -110,19 +113,19 @@ class ExperimentClient:
         response = self.experiment_api.delete_experiment(id)
         return response.result
 
-    def get_log(self, id, master=True):
+    def get_log(self, id, onlyMaster=False):
         """
-        Get training logs of the experiment.
-        By default only get the logs of Pod that has labels 'job-role: master'.
-        :param master: By default get pod with label 'job-role: master' pod if 
True.
-                    If need to get more Pod Logs, set False.
-        :param id: Experiment ID
-        :return: str: experiment logs
+        Get training logs of all pod of the experiment.
+        By default get all the logs of Pod
+        :param id: experiment id
+        :param onlyMaster: By default include pod log of "master" which might 
be
+         Tensorflow PS/Chief or PyTorch master
+        :return: str: pods logs
         """
         response = self.experiment_api.get_log(id)
         log_contents = response.result['logContent']
 
-        if master is True:
+        if onlyMaster is True and len(log_contents) != 0:
             log_contents = [log_contents[0]]
 
         for log_content in log_contents:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to