Example #1
0
def create_task_input():
    from django.db.models import Q
    from taskengine.models import ProductionTask, ProductionTaskInput
    from deftcore.log import get_exception_string
    from taskengine.atlas.datamgmt import DDMWrapper

    task_def = TaskDefinition(debug_mode=True)
    ddm_wrapper = DDMWrapper()

    tasks = ProductionTask.objects.filter(~Q(project='user'), id__gte=4000000).order_by('id')

    for task in tasks.iterator():
        try:
            number_of_events = 0
            number_of_files = 0
            input_dataset = task.input_dataset
            events_per_file = task.events_per_file
            if not events_per_file and input_dataset:
                events_per_file = task_def.get_events_per_file(input_dataset)
            if task.total_req_events:
                number_of_events = task.total_req_events
                if events_per_file:
                    number_of_files = number_of_events / events_per_file
            elif task.number_of_events:
                number_of_events = task.number_of_events
                if events_per_file:
                    number_of_files = number_of_events / events_per_file
            elif task.number_of_files:
                number_of_files = task.number_of_files
                number_of_events = number_of_files * events_per_file
            else:
                if input_dataset:
                    try:
                        number_of_files = ddm_wrapper.ddm_get_number_files(input_dataset)
                    except:
                        pass
                    number_of_events = number_of_files * events_per_file
            task_input = ProductionTaskInput(task=task,
                                             ctag=task.step.step_template.ctag,
                                             output_formats=task.step.step_template.output_formats,
                                             input_name=task_def.get_step_input_data_name(task.step),
                                             events=number_of_events,
                                             files=number_of_files,
                                             events_per_job=task.events_per_job,
                                             events_per_file=events_per_file,
                                             input_dataset=input_dataset
                                             )
            task_input.save()
        except:
            print "Task ID = %d, exception occurred: %s" % (int(task.id), get_exception_string())
Example #2
0
    def test_ddm_wrapper(self):
        from taskengine.atlas.datamgmt import DDMWrapper

        try:
            ddm_wrapper = DDMWrapper()
        except Exception as ex:
            print "test_ddm_wrapper, exception occurred (1): %s" % str(ex)
            ddm_wrapper = None

        self.assertNotEqual(ddm_wrapper, None)
        self.assertNotEqual(ddm_wrapper.ddm_client, None)

        try:
            dataset_list = ddm_wrapper.get_datasets_and_containers('ddo.000001.Atlas.Ideal.DBRelease.v')
        except Exception as ex:
            print "test_ddm_wrapper, exception occurred (2): %s" % str(ex)
            dataset_list = None

        self.assertNotEqual(dataset_list, None)
        self.assertNotEqual(len(dataset_list), 0)
        self.assertEqual(sorted(dataset_list['datasets'])[0], 'ddo.000001.Atlas.Ideal.DBRelease.v020700')