From c1f687fe7e7c05d6a790e6c760dfcee9d8beb7d3 Mon Sep 17 00:00:00 2001
From: Manuel Guenther <manuel.guenther@idiap.ch>
Date: Wed, 5 Nov 2014 11:15:27 +0100
Subject: [PATCH] Removed non-working 'unfinished-also' flag from 'jman
 report'; updated documentation setup.

---
 MANIFEST.in               |  2 +-
 buildout.cfg              |  3 +--
 {docs => doc}/conf.py     | 55 ++++++++++++++++-----------------------
 {docs => doc}/index.rst   |  8 +++---
 {docs => doc}/manual.rst  |  1 -
 {docs => doc}/program.rst |  0
 gridtk/manager.py         | 20 ++++++--------
 gridtk/script/jman.py     |  3 +--
 setup.py                  |  2 +-
 9 files changed, 40 insertions(+), 54 deletions(-)
 rename {docs => doc}/conf.py (84%)
 rename {docs => doc}/index.rst (79%)
 rename {docs => doc}/manual.rst (98%)
 rename {docs => doc}/program.rst (100%)

diff --git a/MANIFEST.in b/MANIFEST.in
index 9c7a0f8..553e266 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,3 @@
 include README.rst bootstrap.py buildout.cfg
-recursive-include docs *.rst
+recursive-include doc *.rst
 recursive-include gridtk *.sh
diff --git a/buildout.cfg b/buildout.cfg
index 240b059..675be9c 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -6,8 +6,7 @@ develop = .
 ; optional package: ipdb (for debugging)
 eggs =  gridtk
         ipdb
-        sphinx-pypi-upload
 
 [scripts]
-recipe = xbob.buildout:scripts
+recipe = bob.buildout:scripts
 
diff --git a/docs/conf.py b/doc/conf.py
similarity index 84%
rename from docs/conf.py
rename to doc/conf.py
index 5acf6cc..9a413ac 100644
--- a/docs/conf.py
+++ b/doc/conf.py
@@ -1,17 +1,15 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 :
+# Manuel Guenther <manuel.guenther@idiap.ch>
+# Tue Nov  4 18:34:42 CET 2014
 #
-# Torch5spro documentation build configuration file, created by
-# sphinx-quickstart on Mon Mar 21 18:07:34 2011.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
+# Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland
+
+import os
+import sys
+import glob
+import pkg_resources
 
-import sys, os
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -33,6 +31,7 @@ extensions = [
   'sphinx.ext.autodoc',
   'sphinx.ext.autosummary',
   'sphinx.ext.doctest',
+  'sphinx.ext.intersphinx',
   ]
 
 # The viewcode extension appeared only on Sphinx >= 1.0.0
@@ -61,14 +60,17 @@ project = u'GridTk'
 import time
 copyright = u'%s, Idiap Research Institute' % time.strftime('%Y')
 
+# Grab the setup entry
+distribution = pkg_resources.require('gridtk')[0]
+
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '1.1'
+version = distribution.version
 # The full version, including alpha/beta/rc tags.
-release = '1.1.0'
+release = distribution.version
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -182,7 +184,7 @@ html_theme = 'default'
 #html_file_suffix = None
 
 # Output file base name for HTML help builder.
-htmlhelp_basename = 'gridtkdoc'
+htmlhelp_basename = 'gridtk_doc'
 
 
 # -- Options for LaTeX output --------------------------------------------------
@@ -227,7 +229,6 @@ latex_documents = [
 rst_epilog = """
 .. Some variables
 .. |project| replace:: GridTk
-.. |torchweb| replace:: http://www.idiap.ch/software/torch5spro
 .. |current-year| date:: %Y
 """
 
@@ -236,25 +237,15 @@ rst_epilog = """
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'torch5spro', u'GridTk Documentation',
+    ('index', 'idiap', u'GridTk Documentation',
      [u'Idiap Research Institute'], 1)
 ]
 
-# Skips selected members in auto-generated documentation. Unfortunately, old
-# versions of Boost.Python will note generate a __self__ member for static
-# methods and that screws-up Sphinx processing
-def skip_member(app, what, name, obj, skip, options):
-  # We don't use this technique if the version of Sphinx is relatively new
-  if sphinx.__version__ >= "1.0": return False
-
-  # Else, we have to remove objects that do not have a __self__ attribute set
-  import types
-  if isinstance(obj, types.BuiltinFunctionType) and \
-    not hasattr(obj, '__self__') and what == 'class':
-      app.warn("Skipping %s %s (no __self__)" % (what, name))
-      return True
+# Default processing flags for sphinx
+autoclass_content = 'both'
+autodoc_member_order = 'bysource'
+autodoc_default_flags = ['members', 'undoc-members', 'inherited-members', 'show-inheritance']
 
-  return False
 
 def setup(app):
-  app.connect('autodoc-skip-member', skip_member)
+  pass
diff --git a/docs/index.rst b/doc/index.rst
similarity index 79%
rename from docs/index.rst
rename to doc/index.rst
index eaa8f64..1ff97b2 100644
--- a/docs/index.rst
+++ b/doc/index.rst
@@ -2,10 +2,12 @@
 .. author: Manuel Günther <manuel.guenther@idiap.ch>
 .. date: Fri Aug 30 14:31:49 CEST 2013
 
-Welcome to GridTk's documentation!
-==================================
+.. _gridtk:
 
-The GridTK serves as a tool to submit jobs and keep track of their dependencies and their current statusus.
+Parallel Execution of Jobs in the SGE Grid or on a Local Machine
+================================================================
+
+The GridTK serves as a tool to submit jobs and keep track of their dependencies and their current statuses.
 These jobs can either be submitted to an SGE grid, or to be run in parallel on the local machine.
 
 There are two main ways to interact with the GridTK.
diff --git a/docs/manual.rst b/doc/manual.rst
similarity index 98%
rename from docs/manual.rst
rename to doc/manual.rst
index 3ded995..b24ec23 100644
--- a/docs/manual.rst
+++ b/doc/manual.rst
@@ -175,7 +175,6 @@ E.g.:
 will print the contents of the output and error log file from the job with the desired ID (and only the array job with the given ID).
 
 To report only the output or only the error logs, you can use the ``-o`` or ``-e`` option, respectively.
-When some (array-)jobs are still running, use the ``-u`` option to list their current output and/or error logs.
 Hopefully, that helps in debugging the problem!
 
 
diff --git a/docs/program.rst b/doc/program.rst
similarity index 100%
rename from docs/program.rst
rename to doc/program.rst
diff --git a/gridtk/manager.py b/gridtk/manager.py
index f583647..10505cd 100644
--- a/gridtk/manager.py
+++ b/gridtk/manager.py
@@ -232,7 +232,7 @@ class JobManager:
     self.unlock()
 
 
-  def report(self, job_ids=None, array_ids=None, unfinished=False, output=True, error=True):
+  def report(self, job_ids=None, array_ids=None, output=True, error=True):
     """Iterates through the output and error files and write the results to command line."""
     def _write_contents(job):
       # Writes the contents of the output and error files to command line
@@ -248,13 +248,11 @@ class JobManager:
 
     def _write_array_jobs(array_jobs):
       for array_job in array_jobs:
-        if unfinished or array_job.status in accepted_status:
-          print("Array Job", str(array_job.id), ("(%s) :"%array_job.machine_name if array_job.machine_name is not None else ":"))
-          _write_contents(array_job)
+        print("Array Job", str(array_job.id), ("(%s) :"%array_job.machine_name if array_job.machine_name is not None else ":"))
+        _write_contents(array_job)
 
     self.lock()
 
-    accepted_status = ('failure',) if error and not output else ('success', 'failure')
     # check if an array job should be reported
     if array_ids:
       if len(job_ids) != 1: logger.error("If array ids are specified exactly one job id must be given.")
@@ -267,14 +265,12 @@ class JobManager:
       jobs = self.get_jobs(job_ids)
       for job in jobs:
         if job.array:
-          if unfinished or job.status in accepted_status or job.status == 'executing':
-            print(job)
-            _write_array_jobs(job.array)
+          print(job)
+          _write_array_jobs(job.array)
         else:
-          if unfinished or job.status in accepted_status:
-            print(job)
-            _write_contents(job)
-        if job.log_dir is not None and job.status in accepted_status:
+          print(job)
+          _write_contents(job)
+        if job.log_dir is not None:
           print("-"*60)
 
     self.unlock()
diff --git a/gridtk/script/jman.py b/gridtk/script/jman.py
index 9838c0d..4ffa1e6 100644
--- a/gridtk/script/jman.py
+++ b/gridtk/script/jman.py
@@ -183,7 +183,7 @@ def communicate(args):
 def report(args):
   """Reports the results of the finished (and unfinished) jobs."""
   jm = setup(args)
-  jm.report(job_ids=get_ids(args.job_ids), array_ids=get_ids(args.array_ids), unfinished=args.unfinished_also, output=not args.errors_only, error=not args.output_only)
+  jm.report(job_ids=get_ids(args.job_ids), array_ids=get_ids(args.array_ids), output=not args.errors_only, error=not args.output_only)
 
 
 def stop(args):
@@ -325,7 +325,6 @@ def main(command_line_options = None):
   report_parser = cmdparser.add_parser('report', aliases=['rep', 'r', 'explain', 'why'], formatter_class=formatter, help='Iterates through the result and error log files and prints out the logs.')
   report_parser.add_argument('-e', '--errors-only', action='store_true', help='Only report the error logs (by default, both logs are reported).')
   report_parser.add_argument('-o', '--output-only', action='store_true', help='Only report the output logs  (by default, both logs are reported).')
-  report_parser.add_argument('-u', '--unfinished-also', action='store_true', help='Report also the unfinished jobs; use this option also to check error files for jobs with success status.')
   report_parser.add_argument('-j', '--job-ids', metavar='ID', nargs='+', help='Report only the jobs with the given ids (by default, all finished jobs are reported)')
   report_parser.add_argument('-a', '--array-ids', metavar='ID', nargs='+', help='Report only the jobs with the given array ids. If specified, a single job-id must be given as well.')
   report_parser.set_defaults(func=report)
diff --git a/setup.py b/setup.py
index ee0c0a7..99f9000 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ if sys.version_info[:2] < (2, 7) or ((3,0) <= sys.version_info[:2] < (3,2)):
 
 setup(
     name='gridtk',
-    version='1.1.7a0',
+    version='1.1.8a0',
     description='SGE Grid and Local Submission and Monitoring Tools for Idiap',
 
     url='http://github.com/idiap/gridtk',
-- 
GitLab