コード例 #1
0
    def setUp(self):
        self.generated_files = []
        self.job = Job.from_file(test.do_test_file(CONFIG_FILE))
        self.job_with_includes = Job.from_file(test.do_test_file(CONFIG_WITH_INCLUDES))

        self.generated_files.append(self.job.super_config_path)
        self.generated_files.append(self.job_with_includes.super_config_path)
コード例 #2
0
    def setUp(self):
        self.generated_files = []
        self.job = Job.from_file(test.do_test_file(CONFIG_FILE))
        self.job_with_includes = Job.from_file(
            test.do_test_file(CONFIG_WITH_INCLUDES))

        self.generated_files.append(self.job.super_config_path)
        self.generated_files.append(self.job_with_includes.super_config_path)
コード例 #3
0
ファイル: job_unittest.py プロジェクト: hsberlin/openquake
    def setUp(self):
        self.generated_files = []
        self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE))
        self.job_with_includes = \
            Job.from_file(helpers.get_data_path(CONFIG_WITH_INCLUDES))

        self.generated_files.append(self.job.super_config_path)
        self.generated_files.append(self.job_with_includes.super_config_path)
コード例 #4
0
    def test_prepares_blocks_using_the_input_region(self):
        """ This test might be currently catastrophically retarded. If it is
        blame Lars.
        """

        block_path = test.do_test_file(BLOCK_SPLIT_TEST_FILE)

        print "In open job"
        a_job = Job.from_file(block_path)
        self.generated_files.append(a_job.super_config_path)

        verts = [float(x) for x in a_job.params['REGION_VERTEX'].split(",")]
        # Flips lon and lat, and builds a list of coord tuples
        coords = zip(verts[1::2], verts[::2])
        expected = shapes.RegionConstraint.from_coordinates(coords)
        expected.cell_size = float(a_job.params['REGION_GRID_SPACING'])

        expected_sites = []
        for site in expected:
            print site
            expected_sites.append(site)

        a_job._partition()
        blocks_keys = a_job.blocks_keys
        print blocks_keys

        self.assertEqual(1, len(blocks_keys))
        self.assertEqual(job.Block(expected_sites),
                         job.Block.from_kvs(blocks_keys[0]))
コード例 #5
0
ファイル: job_unittest.py プロジェクト: danciul/openquake
    def test_prepares_blocks_using_the_input_region(self):
        """ This test might be currently catastrophically retarded. If it is
        blame Lars.
        """

        block_path = helpers.get_data_path(BLOCK_SPLIT_TEST_FILE)

        print "In open job"
        a_job = Job.from_file(block_path)
        self.generated_files.append(a_job.super_config_path)

        verts = [float(x) for x in a_job.params['REGION_VERTEX'].split(",")]
        # Flips lon and lat, and builds a list of coord tuples
        coords = zip(verts[1::2], verts[::2])
        expected = shapes.RegionConstraint.from_coordinates(coords)
        expected.cell_size = float(a_job.params['REGION_GRID_SPACING'])

        expected_sites = []
        for site in expected:
            print site
            expected_sites.append(site)

        a_job._partition()
        blocks_keys = a_job.blocks_keys
        print blocks_keys

        self.assertEqual(1, len(blocks_keys))
        self.assertEqual(job.Block(expected_sites),
                         job.Block.from_kvs(blocks_keys[0]))
コード例 #6
0
ファイル: job_unittest.py プロジェクト: johndouglas/openquake
 def test_is_job_completed(self):
     job_id = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db').job_id
     session = get_db_session("reslt", "writer")
     pairs = [('pending', False), ('running', False),
              ('succeeded', True), ('failed', True)]
     for status, is_completed in pairs:
         session.query(OqJob).update({'status': status})
         session.commit()
         self.assertEqual(Job.is_job_completed(job_id), is_completed)
コード例 #7
0
ファイル: job_unittest.py プロジェクト: favalex/openquake
 def test_is_job_completed(self):
     job_id = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db').job_id
     row = OqJob.objects.get(id=job_id)
     pairs = [('pending', False), ('running', False),
              ('succeeded', True), ('failed', True)]
     for status, is_completed in pairs:
         row.status = status
         row.save()
         self.assertEqual(Job.is_job_completed(job_id), is_completed)
コード例 #8
0
ファイル: job_unittest.py プロジェクト: johndouglas/openquake
    def test_get_status_from_db(self):
        self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db')

        session = get_db_session("reslt", "writer")
        session.query(OqJob).update({'status': 'failed'})
        session.commit()
        self.assertEqual(Job.get_status_from_db(self.job.job_id), 'failed')
        session.query(OqJob).update({'status': 'running'})
        session.commit()
        self.assertEqual(Job.get_status_from_db(self.job.job_id), 'running')
コード例 #9
0
ファイル: job_unittest.py プロジェクト: favalex/openquake
    def test_get_status_from_db(self):
        self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db')
        row = OqJob.objects.get(id=self.job.job_id)

        row.status = "failed"
        row.save()
        self.assertEqual("failed", Job.get_status_from_db(self.job.job_id))

        row.status = "running"
        row.save()
        self.assertEqual("running", Job.get_status_from_db(self.job.job_id))
コード例 #10
0
ファイル: job_unittest.py プロジェクト: johndouglas/openquake
    def test_set_status(self):
        self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db')

        session = get_db_session("reslt", "writer")

        status = 'running'
        self.job.set_status(status)

        job = session.query(OqJob).filter(OqJob.id == self.job.job_id).one()

        self.assertEqual(status, job.status)
コード例 #11
0
ファイル: helpers.py プロジェクト: johndouglas/openquake
def job_from_file(config_file_path):
    """
    Create a Job instance from the given configuration file.

    The results are configured to go to XML files.  *No* database record will
    be stored for the job.  This allows running test on jobs without requiring
    a database.
    """

    job = Job.from_file(config_file_path, 'xml')
    cleanup_loggers()

    return job
コード例 #12
0
ファイル: job_unittest.py プロジェクト: danciul/openquake
 def test_job_with_only_hazard_config_only_has_hazard_section(self):
     FLAGS.include_defaults = False
     job_with_only_hazard = Job.from_file(helpers.get_data_path(HAZARD_ONLY))
     self.assertEqual(["HAZARD"], job_with_only_hazard.sections)
     FLAGS.include_defaults = True
コード例 #13
0
ファイル: job_unittest.py プロジェクト: favalex/openquake
 def test_job_db_record_for_output_type_xml(self):
     self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'xml')
     OqJob.objects.get(id=self.job.job_id)
コード例 #14
0
ファイル: job_unittest.py プロジェクト: danciul/openquake
 def test_can_store_and_read_jobs_from_kvs(self):
     self.job = Job.from_file(os.path.join(helpers.DATA_DIR, CONFIG_FILE))
     self.generated_files.append(self.job.super_config_path)
     self.assertEqual(self.job, Job.from_kvs(self.job.id))
コード例 #15
0
 def test_classical_psha_based_job(self):
     job = Job.from_file(TEST_JOB_FILE_CLASSICAL)
     self.assertTrue(job.launch())
コード例 #16
0
ファイル: job_unittest.py プロジェクト: danciul/openquake
 def test_classical_psha_based_job(self):
     job = Job.from_file(TEST_JOB_FILE_CLASSICAL)
     self.assertTrue(job.launch())
コード例 #17
0
ファイル: job_unittest.py プロジェクト: danciul/openquake
 def test_job_runs_with_a_good_config(self):
     job = Job.from_file(TEST_JOB_FILE)
     self.assertTrue(job.launch())
コード例 #18
0
 def test_job_runs_with_a_good_config(self):
     job = Job.from_file(TEST_JOB_FILE)
     self.assertTrue(job.launch())
コード例 #19
0
 def test_can_store_and_read_jobs_from_kvs(self):
     self.job = Job.from_file(os.path.join(test.DATA_DIR, CONFIG_FILE))
     self.generated_files.append(self.job.super_config_path)
     self.assertEqual(self.job, Job.from_kvs(self.job.id))
コード例 #20
0
 def test_job_with_only_hazard_config_only_has_hazard_section(self):
     FLAGS.include_defaults = False
     job_with_only_hazard = Job.from_file(test.do_test_file(HAZARD_ONLY))
     self.assertEqual(["HAZARD"], job_with_only_hazard.sections)
     FLAGS.include_defaults = True
コード例 #21
0
ファイル: job_unittest.py プロジェクト: johndouglas/openquake
    def test_job_db_record_for_output_type_xml(self):
        self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'xml')

        session = get_db_session("uiapi", "writer")

        session.query(OqJob).filter(OqJob.id == self.job.job_id).one()
コード例 #22
0
ファイル: job_unittest.py プロジェクト: favalex/openquake
 def test_set_status(self):
     self.job = Job.from_file(helpers.get_data_path(CONFIG_FILE), 'db')
     status = 'running'
     self.job.set_status(status)
     self.assertEqual(status, OqJob.objects.get(id=self.job.job_id).status)