import sys
import bson.objectid
import config.global_configuration as global_conf
import database.client
import batch_analysis.trial_runner as trial_runner


def main(*args):
    """
    Run a given system with a given image source.
    This represents a basic task.
    Scripts to run this will be autogenerated by the job system
    The first argument is the system id, the second argument is the image source to use
    (note that args[0] should be the x
    :return: 
    """
    if len(args) >= 2:
        system_id = bson.objectid.ObjectId(args[0])
        image_source_id = bson.objectid.ObjectId(args[1])

        config = global_conf.load_global_config('config.yml')
        db_client = database.client.DatabaseClient(config=config)

        s_system = db_client.system_collection.find_one({'_id': system_id})
        system = db_client.deserialize_entity(s_system)

        s_image_source = db_client.image_source_collection.find_one({'_id': image_source_id})
        image_source = db_client.deserialize_entity(s_image_source)

        trial_result = trial_runner.run_system_with_source(system, image_source)
        db_client.trials_collection.insert(trial_result.serialize())


if __name__ == '__main__':
    main(*sys.argv[1:])

import sys
import bson.objectid
import config.global_configuration as global_conf
import database.client
import core.image_collection
import core.image_entity
import systems.deep_learning.keras_frcnn
import batch_analysis.trial_runner as trial_runner


def main(*args):
    """
    Run a given system with a given image source.
    This represents a basic task.
    Scripts to run this will be autogenerated by the job system
    The first argument is the system id, the second argument is the image source to use
    (note that args[0] should be the x
    :return: 
    """
    if len(args) >= 2:
        system_id = bson.objectid.ObjectId(args[0])
        image_source_id = bson.objectid.ObjectId(args[1])

        config = global_conf.load_global_config('config.yml')
        db_client = database.client.DatabaseClient(config=config)

        system = None
        s_system = db_client.system_collection.find_one({'_id': system_id})
        if s_system is not None:
            system = db_client.deserialize_entity(s_system)
        del s_system

        image_source = None
        s_image_source = db_client.image_source_collection.find_one({'_id': image_source_id})
        if s_image_source is not None:
            image_source = db_client.deserialize_entity(s_image_source)
        del s_image_source

        if system is not None and image_source is not None:
            trial_result = trial_runner.run_system_with_source(system, image_source)
            if trial_result is not None:
                db_client.trials_collection.insert(trial_result.serialize())


if __name__ == '__main__':
    main(*sys.argv[1:])

Make the run system task more error friendly
Make the run system task more error friendly

  import sys
  import bson.objectid
  import config.global_configuration as global_conf
  import database.client
+ import core.image_collection
+ import core.image_entity
+ import systems.deep_learning.keras_frcnn
  import batch_analysis.trial_runner as trial_runner
  
  
  def main(*args):
      """
      Run a given system with a given image source.
      This represents a basic task.
      Scripts to run this will be autogenerated by the job system
      The first argument is the system id, the second argument is the image source to use
      (note that args[0] should be the x
      :return: 
      """
      if len(args) >= 2:
          system_id = bson.objectid.ObjectId(args[0])
          image_source_id = bson.objectid.ObjectId(args[1])
  
          config = global_conf.load_global_config('config.yml')
          db_client = database.client.DatabaseClient(config=config)
  
+         system = None
          s_system = db_client.system_collection.find_one({'_id': system_id})
+         if s_system is not None:
-         system = db_client.deserialize_entity(s_system)
+             system = db_client.deserialize_entity(s_system)
+         del s_system
  
+         image_source = None
          s_image_source = db_client.image_source_collection.find_one({'_id': image_source_id})
+         if s_image_source is not None:
-         image_source = db_client.deserialize_entity(s_image_source)
+             image_source = db_client.deserialize_entity(s_image_source)
+         del s_image_source
  
+         if system is not None and image_source is not None:
-         trial_result = trial_runner.run_system_with_source(system, image_source)
+             trial_result = trial_runner.run_system_with_source(system, image_source)
+             if trial_result is not None:
-         db_client.trials_collection.insert(trial_result.serialize())
+                 db_client.trials_collection.insert(trial_result.serialize())
  
  
  if __name__ == '__main__':
      main(*sys.argv[1:])
  
Make the run system task more error friendly
## Code Before:
import sys
import bson.objectid
import config.global_configuration as global_conf
import database.client
import batch_analysis.trial_runner as trial_runner


def main(*args):
    """
    Run a given system with a given image source.
    This represents a basic task.
    Scripts to run this will be autogenerated by the job system
    The first argument is the system id, the second argument is the image source to use
    (note that args[0] should be the x
    :return: 
    """
    if len(args) >= 2:
        system_id = bson.objectid.ObjectId(args[0])
        image_source_id = bson.objectid.ObjectId(args[1])

        config = global_conf.load_global_config('config.yml')
        db_client = database.client.DatabaseClient(config=config)

        s_system = db_client.system_collection.find_one({'_id': system_id})
        system = db_client.deserialize_entity(s_system)

        s_image_source = db_client.image_source_collection.find_one({'_id': image_source_id})
        image_source = db_client.deserialize_entity(s_image_source)

        trial_result = trial_runner.run_system_with_source(system, image_source)
        db_client.trials_collection.insert(trial_result.serialize())


if __name__ == '__main__':
    main(*sys.argv[1:])

## Instruction:
Make the run system task more error friendly
## Code After:
import sys
import bson.objectid
import config.global_configuration as global_conf
import database.client
import core.image_collection
import core.image_entity
import systems.deep_learning.keras_frcnn
import batch_analysis.trial_runner as trial_runner


def main(*args):
    """
    Run a given system with a given image source.
    This represents a basic task.
    Scripts to run this will be autogenerated by the job system
    The first argument is the system id, the second argument is the image source to use
    (note that args[0] should be the x
    :return: 
    """
    if len(args) >= 2:
        system_id = bson.objectid.ObjectId(args[0])
        image_source_id = bson.objectid.ObjectId(args[1])

        config = global_conf.load_global_config('config.yml')
        db_client = database.client.DatabaseClient(config=config)

        system = None
        s_system = db_client.system_collection.find_one({'_id': system_id})
        if s_system is not None:
            system = db_client.deserialize_entity(s_system)
        del s_system

        image_source = None
        s_image_source = db_client.image_source_collection.find_one({'_id': image_source_id})
        if s_image_source is not None:
            image_source = db_client.deserialize_entity(s_image_source)
        del s_image_source

        if system is not None and image_source is not None:
            trial_result = trial_runner.run_system_with_source(system, image_source)
            if trial_result is not None:
                db_client.trials_collection.insert(trial_result.serialize())


if __name__ == '__main__':
    main(*sys.argv[1:])
