Example #1
0
 def __add_input_files(self):
     input_files = []
     path = self.__variables['files']
     dataset = self.__variables['dataset']
     campaign = self.__variables['campaign']
     if path != '':
         input_files = ParentCommand.input_files_from_path(path)
         # dress them for CMSSW (unless they have a global path)
         input_files = ['file://{0}'.format(f) if not f.startswith('/store') else f for f in input_files]
     else:
         input_files = find_input_files(
             campaign, dataset, self.__variables, LOG
         )
     self.__variables['input_files'] = input_files
Example #2
0
    def run(self, args, variables):
        self.__text = """This command is deprecated and will be replaced with
        a newer version soon."""
        return False
        output_file = None
        if 'output_file' in variables:
            output_file = os.path.join(RESULTDIR, variables['output_file'])
            if not output_file.endswith('.root'):
                output_file += '.root'
        else:
            output_file = OUTPUT_FILE.format(ds=variables['dataset'])
        variables['output_file'] = output_file

        self.__prepare(args, variables)
        campaign = self.__variables['campaign']
        chosen_dataset = self.__variables['dataset']
        input_files = find_input_files(
            campaign, chosen_dataset, self.__variables, logger=LOG
        )
        LOG.debug(
            "Using files for NTP input:\n{0}".format('\n'.join(input_files)))

        self.__output_file = self.__variables['output_file']

        self.__write_pset(input_files)

        # making sure the correct HLT menu is read
        if 'reHLT' in input_files[0]:
            self.__variables['isReHLT'] = 1

        if not self.__variables['noop']:
            code = self.__run_cmssw()
            self.__text = "Ran {PSET}\n"
            self.__text += "Logging information can be found in {LOGDIR}/ntp.log\n"
            if code == 0:
                self.__text += "Created ntuples: {OUTPUT_FILE}\n"
                self.__text = self.__text.format(
                    PSET=PSET, LOGDIR=LOGDIR, OUTPUT_FILE=self.__output_file)
            else:
                self.__text += "CMSSW experienced an error,"
                self.__text += " return code: {code}\n"
                self.__text = self.__text.format(
                    PSET=PSET, LOGDIR=LOGDIR, code=code)
                return False

        else:
            LOG.info('Found "noop", not running CMSSW')

        return True
Example #3
0
    def run(self, args, variables):
        self.__text = """This command is deprecated and will be replaced with
        a newer version soon."""
        return False
        output_file = None
        if 'output_file' in variables:
            output_file = os.path.join(RESULTDIR, variables['output_file'])
            if not output_file.endswith('.root'):
                output_file += '.root'
        else:
            output_file = OUTPUT_FILE.format(ds=variables['dataset'])
        variables['output_file'] = output_file

        self.__prepare(args, variables)
        campaign = self.__variables['campaign']
        chosen_dataset = self.__variables['dataset']
        input_files = find_input_files(
            campaign, chosen_dataset, self.__variables, logger=LOG
        )
        LOG.debug(
            "Using files for NTP input:\n{0}".format('\n'.join(input_files)))

        self.__output_file = self.__variables['output_file']

        self.__write_pset(input_files)

        # making sure the correct HLT menu is read
        if 'reHLT' in input_files[0]:
            self.__variables['isReHLT'] = 1

        if not self.__variables['noop']:
            code = self.__run_cmssw()
            self.__text = "Ran {PSET}\n"
            self.__text += "Logging information can be found in {LOGDIR}/ntp.log\n"
            if code == 0:
                self.__text += "Created ntuples: {OUTPUT_FILE}\n"
                self.__text = self.__text.format(
                    PSET=PSET, LOGDIR=LOGDIR, OUTPUT_FILE=self.__output_file)
            else:
                self.__text += "CMSSW experienced an error,"
                self.__text += " return code: {code}\n"
                self.__text = self.__text.format(
                    PSET=PSET, LOGDIR=LOGDIR, code=code)
                return False

        else:
            LOG.info('Found "noop", not running CMSSW')

        return True
Example #4
0
 def __add_input_files(self):
     input_files = []
     path = self.__variables['files']
     dataset = self.__variables['dataset']
     campaign = self.__variables['campaign']
     if path != '':
         input_files = ParentCommand.input_files_from_path(path)
         # dress them for CMSSW (unless they have a global path)
         input_files = [
             'file://{0}'.format(f) if not f.startswith('/store') else f
             for f in input_files
         ]
     else:
         input_files = find_input_files(campaign, dataset, self.__variables,
                                        LOG)
     self.__variables['input_files'] = input_files
Example #5
0
    def run(self, args, variables):
        self.__prepare(args, variables)
        campaign = self.__variables["campaign"]
        chosen_dataset = self.__variables["dataset"]
        input_files = self.__variables["files"]
        if not input_files:
            input_files = find_input_files(campaign, chosen_dataset, self.__variables, logger=LOG)
            input_files = str(input_files[0])
        # take only first file
        self.__variables["files"] = input_files
        self.__variables["isTTbarMC"] = 1

        from ..local import Command as LocalC

        run_local = LocalC()
        rc = run_local.run(args, self.__variables)
        self.__text = run_local.get_text()

        return rc
Example #6
0
    def run(self, args, variables):
        self.__prepare(args, variables)
        campaign = self.__variables['campaign']
        chosen_dataset = self.__variables['dataset']
        input_files = self.__variables['files']
        if not input_files:
            input_files = find_input_files(campaign,
                                           chosen_dataset,
                                           self.__variables,
                                           logger=LOG)
            input_files = str(input_files[0])
        # take only first file
        self.__variables['files'] = input_files
        self.__variables['isTTbarMC'] = 1

        from ..local import Command as LocalC
        run_local = LocalC()
        rc = run_local.run(args, self.__variables)
        self.__text = run_local.get_text()

        return rc
Example #7
0
    def __get_run_config(self, campaign, dataset):
        from crab.util import find_input_files
        from crab import get_config
        run_config = {
            'requestName': 'Test',
            'outputDatasetTag': 'Test',
            'inputDataset': 'Test',
            'splitting': 'FileBased',
            'unitsPerJob': 1,
            'outLFNDirBase': os.path.join(HDFS_STORE_BASE, 'ntuple'),
            'lumiMask': '',
            'pyCfgParams': None,
            'files': [],
        }

        using_local_files = self.__variables['files'] != ''
        input_files = find_input_files(campaign, dataset, self.__variables,
                                       LOG)

        if not using_local_files:
            run_config = get_config(campaign, dataset)
            run_config['outLFNDirBase'] = self.__replace_output_dir(run_config)

        run_config['files'] = input_files
        parameters = self.__extract_params()
        if run_config['pyCfgParams']:
            params = '{parameters} {cfg_params}'.format(
                parameters=parameters,
                cfg_params=' '.join(run_config['pyCfgParams']),
            )
            run_config['pyCfgParams'] = params
        else:
            run_config['pyCfgParams'] = parameters

        LOG.info('Retrieved CRAB config')

        run_config['additional_input_files'] = self.__input_files

        self.__config = run_config
    def __get_run_config(self, campaign, dataset):
        from crab.util import find_input_files
        from crab import get_config
        run_config = {
            'requestName': 'Test',
            'outputDatasetTag': 'Test',
            'inputDataset': 'Test',
            'splitting': 'FileBased',
            'unitsPerJob': 1,
            'outLFNDirBase': os.path.join(HDFS_STORE_BASE, 'ntuple'),
            'lumiMask': '',
            'pyCfgParams': None,
            'files': [],
        }

        using_local_files = self.__variables['files'] != ''
        input_files = find_input_files(
            campaign, dataset, self.__variables, LOG)

        if not using_local_files:
            run_config = get_config(campaign, dataset)
            run_config['outLFNDirBase'] = self.__replace_output_dir(run_config)

        run_config['files'] = input_files
        parameters = self.__extract_params()
        if run_config['pyCfgParams']:
            params = '{parameters} {cfg_params}'.format(
                parameters=parameters,
                cfg_params=' '.join(run_config['pyCfgParams']),
            )
            run_config['pyCfgParams'] = params
        else:
            run_config['pyCfgParams'] = parameters

        LOG.info('Retrieved CRAB config')

        run_config['additional_input_files'] = self.__input_files

        self.__config = run_config