You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2018/04/24 13:00:39 UTC

svn commit: r1829992 - in /uima/uima-ducc/trunk: src/main/assembly/bin.xml src/main/scripts/ducc_job_specification.py src/main/scripts/ducc_service_status.py uima-ducc-examples/src/main/bin/ uima-ducc-examples/src/main/bin/sequential_submit_example.py

Author: degenaro
Date: Tue Apr 24 13:00:39 2018
New Revision: 1829992

URL: http://svn.apache.org/viewvc?rev=1829992&view=rev
Log:
UIMA-5770 DUCC user commands to retrieve job specification & get service status

Added:
    uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py   (with props)
    uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py   (with props)
    uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/
    uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py   (with props)
Modified:
    uima/uima-ducc/trunk/src/main/assembly/bin.xml

Modified: uima/uima-ducc/trunk/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/assembly/bin.xml?rev=1829992&r1=1829991&r2=1829992&view=diff
==============================================================================
--- uima/uima-ducc/trunk/src/main/assembly/bin.xml (original)
+++ uima/uima-ducc/trunk/src/main/assembly/bin.xml Tue Apr 24 13:00:39 2018
@@ -520,12 +520,20 @@ under the License.
 
     <fileSet>
       <!-- build up the verification scripting -->
+      <directory>uima-ducc-examples/src/main/bin</directory>
+      <outputDirectory>examples/bin</outputDirectory>
+      <fileMode>755</fileMode>
+      <directoryMode>755</directoryMode>        
+    </fileSet>
+
+    <fileSet>
+      <!-- build up the verification scripting -->
       <directory>uima-ducc-examples/src/main/scripts</directory>
       <outputDirectory>examples/systemtest</outputDirectory>
       <fileMode>755</fileMode>
       <directoryMode>755</directoryMode>        
     </fileSet>
-
+    
     <fileSet>
       <!-- build up the verification test jobs -->
       <directory>uima-ducc-examples/src/main/resources/org/apache/uima/ducc/test</directory>

Added: uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py?rev=1829992&view=auto
==============================================================================
--- uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py (added)
+++ uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py Tue Apr 24 13:00:39 2018
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+
+# -----------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+# -----------------------------------------------------------------------
+
+# Retrieve a DUCC Job Specification from Webserver
+
+import sys
+import urllib2
+
+from optparse import OptionParser
+from HTMLParser import HTMLParser
+
+row = 0
+column = 0
+
+job_spec_provider = 'ducc'
+job_spec_key = ''
+job_spec_value = ''
+
+class DuccServiceDeploymentsTabHTMLParser(HTMLParser):
+    
+    def handle_starttag(self, tag, attrs):
+        global options, row, column, job_spec_provider, job_spec_key, job_spec_value
+        #print("Encountered a start tag:", tag)
+        if(tag == 'td'):
+            column = column + 1
+
+    def handle_endtag(self, tag):
+        global options, row, column, job_spec_provider, job_spec_key, job_spec_value
+        if(tag == 'tr'):
+            display = True
+            if(options.user):
+                if(job_spec_provider != 'user'):
+                    display = False
+            if(display):
+                if(options.provider):
+                    print job_spec_provider, job_spec_key, job_spec_value
+                else:
+                    print job_spec_key, job_spec_value
+            job_spec_provider = 'ducc'
+            job_spec_key=''
+            job_spec_value = ''
+            column = 0
+            row = row + 1
+        #print("Encountered an end tag :", tag)
+
+    def handle_data(self, data):
+        global options, row, column, job_spec_provider, job_spec_key, job_spec_value
+        if(column == 1):
+            job_spec_provider = data
+        elif(column == 2):
+            job_spec_key = data
+        else:
+            job_spec_value = job_spec_value+data
+        #print("Encountered some data  :", str(row), str(column), data)
+
+class DuccServiceStatus():
+    
+    # parse command line
+    def parse_cmdline(self):
+        global options
+        parser = OptionParser()
+        parser.add_option('--scheme', action='store', dest='scheme', default='http', help='default = http')
+        parser.add_option('--host', action='store', dest='host', default=None, help='required (no default)')
+        parser.add_option('--port', action='store', dest='port', default='42133', help='default = 42133')
+        parser.add_option('--id', action='store', dest='id', default=None, help='required (no default)')
+        parser.add_option('--provider', action='store_true', dest='provider', default=False, help='display provider (optional)')
+        parser.add_option('--user', action='store_true', dest='user', default=False, help='display provider==user entries only (optional)')
+        (options, args) = parser.parse_args()
+        
+        if(options.host == None):
+            parser.error("missing --host")
+    
+        if(options.id == None):
+            parser.error("missing --id")
+        
+    def main(self, argv):
+        servlet = '/ducc-servlet/job-specification-data'
+        self.parse_cmdline()
+        url_string = options.scheme+'://'+options.host+':'+options.port+servlet+'?id='+options.id
+        #print url_string
+        response = urllib2.urlopen(url_string)
+        html = response.read()
+        
+        parser = DuccServiceDeploymentsTabHTMLParser()
+        parser.feed(html)
+
+if __name__ == '__main__':
+    instance = DuccServiceStatus()
+    instance.main(sys.argv[1:])

Propchange: uima/uima-ducc/trunk/src/main/scripts/ducc_job_specification.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py?rev=1829992&view=auto
==============================================================================
--- uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py (added)
+++ uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py Tue Apr 24 13:00:39 2018
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+# -----------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+# -----------------------------------------------------------------------
+
+# Retrieve a DUCC Service status from Webserver
+
+import sys
+import urllib2
+
+from optparse import OptionParser
+from HTMLParser import HTMLParser
+
+row = 0
+column = 0
+
+service_host = None
+service_pid = None
+service_state = None
+
+class DuccServiceDeploymentsTabHTMLParser(HTMLParser):
+    
+    def handle_starttag(self, tag, attrs):
+        global row, column, service_host, service_pid, service_state
+        #print("Encountered a start tag:", tag)
+        if(tag == 'td'):
+            column = column + 1
+
+    def handle_endtag(self, tag):
+        global row, column, service_host, service_pid, service_state
+        if(tag == 'tr'):
+            column = 0
+            row = row + 1
+        #print("Encountered an end tag :", tag)
+
+    def handle_data(self, data):
+        global row, column, service_host, service_pid, service_state
+        if(column == 2):
+            service_state = data
+        elif(column == 6):
+            service_host = data
+        elif(column == 7):
+            service_pid = data
+            print 'host:'+service_host, 'pid:'+service_pid,'state:'+ service_state
+        else:
+            pass
+        #print("Encountered some data  :", str(row), str(column), data)
+
+class DuccServiceStatus():
+    
+    # parse command line
+    def parse_cmdline(self):
+        global options
+        parser = OptionParser()
+        parser.add_option('--scheme', action='store', dest='scheme', default='http', help='default = http')
+        parser.add_option('--host', action='store', dest='host', default=None, help='required (no default)')
+        parser.add_option('--port', action='store', dest='port', default='42133', help='default = 42133')
+        parser.add_option('--name', action='store', dest='name', default=None, help='required (no default)')
+        (options, args) = parser.parse_args()
+        
+        if(options.host == None):
+            parser.error("missing --host")
+    
+        if(options.name == None):
+            parser.error("missing --name")
+        
+    def main(self, argv):
+        servlet = '/ducc-servlet/service-deployments-data'
+        self.parse_cmdline()
+        url_string = options.scheme+'://'+options.host+':'+options.port+servlet+'?name='+options.name
+        #print url_string
+        response = urllib2.urlopen(url_string)
+        html = response.read()
+        
+        parser = DuccServiceDeploymentsTabHTMLParser()
+        parser.feed(html)
+
+if __name__ == '__main__':
+    instance = DuccServiceStatus()
+    instance.main(sys.argv[1:])

Propchange: uima/uima-ducc/trunk/src/main/scripts/ducc_service_status.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py?rev=1829992&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py (added)
+++ uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py Tue Apr 24 13:00:39 2018
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+# -----------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+# -----------------------------------------------------------------------
+
+# Example script to run 2 DUCC jobs, sequentially
+
+import os
+import inspect
+
+# determine ducc_home, relatively
+ducc_home = os.path.dirname(os.path.abspath(inspect.stack()[0][1]))[:-12]
+
+# calculate ducc_submit command path
+cmd_submit = os.path.join(ducc_home,'bin/ducc_submit')
+
+jobA = 'examples/simple/1.job'
+jobB = 'examples/simple/1.dd.job'
+
+# construct path to example 1.job and 1.dd.job
+file_jobA = os.path.join(ducc_home,jobA)
+file_jobB = os.path.join(ducc_home,jobB)
+
+# construct submit commands for 1.job and 1.dd.job
+run_jobA = cmd_submit+' -f '+file_jobA+' '+'--wait_for_completion'
+run_jobB = cmd_submit+' -f '+file_jobB+' '+'--wait_for_completion'
+
+# submit 1.job and wait for completion
+print 'jobA: submit '+jobA
+result = os.system(run_jobA)
+print 'jobA: '+str(result)
+
+# can't get here until 1.job is finished
+
+# submit 1.dd.job and wait for completion
+print 'jobB: submit '+jobB
+result = os.system(run_jobA)
+print 'jobB: '+str(result)
+
+# can't get here until 1.dd.ob is finished
+

Propchange: uima/uima-ducc/trunk/uima-ducc-examples/src/main/bin/sequential_submit_example.py
------------------------------------------------------------------------------
    svn:eol-style = native