Esempio n. 1
0
    def prepare(self, force=False):

        super(Ostap, self).prepare(force)
        self._check_inputs()

        
        share_dir = os.path.join (
            expandfilename ( getConfig('Configuration')['gangadir'] ) ,
            'shared'                            ,
            getConfig('Configuration')['user']  ,
            self.is_prepared.name               )
        
        input_sandbox_tar = os.path.join ( share_dir , 'inputsandbox',
                                           '_input_sandbox_%s.tar' % self.is_prepared.name ) 
        input_sandbox_tgz = os.path.join ( share_dir , 'inputsandbox',
                                           '_input_sandbox_%s.tgz' % self.is_prepared.name ) 
        
        fillPackedSandbox ( self.scripts      , input_sandbox_tar        ) 
        gzipFile          ( input_sandbox_tar , input_sandbox_tgz , True )
        
        # add the newly created shared directory into the metadata system if
        # the app is associated with a persisted object
        self.checkPreparedHasParent(self)
        self.post_prepare()
        logger.debug("Finished Preparing Application in %s" % share_dir)
Esempio n. 2
0
    def prepare(self, force=False):

        super(BenderScript, self).prepare(force)
        self._check_inputs()

        
        share_dir = os.path.join (
            expandfilename ( getConfig('Configuration')['gangadir'] ) ,
            'shared'                            ,
            getConfig('Configuration')['user']  ,
            self.is_prepared.name               )
        
        input_sandbox_tar = os.path.join ( share_dir , 'inputsandbox',
                                           '_input_sandbox_%s.tar' % self.is_prepared.name ) 
        input_sandbox_tgz = os.path.join ( share_dir , 'inputsandbox',
                                           '_input_sandbox_%s.tgz' % self.is_prepared.name ) 
        
        fillPackedSandbox ( self.scripts + self.imports , input_sandbox_tar  ) 
        gzipFile          ( input_sandbox_tar , input_sandbox_tgz , True     )
        
        # add the newly created shared directory into the metadata system if
        # the app is associated with a persisted object
        self.checkPreparedHasParent(self)
        self.post_prepare()
        logger.debug("Finished Preparing Application in %s" % share_dir)
Esempio n. 3
0
    def prepare(self, force=False):
        super(GaudiPython, self).prepare(force)
        self._check_inputs()

        share_dir = os.path.join(expandfilename(getConfig('Configuration')['gangadir']), 'shared', getConfig('Configuration')['user'], self.is_prepared.name)

        fillPackedSandbox(self.script, os.path.join(share_dir, 'inputsandbox', '_input_sandbox_%s.tar' % self.is_prepared.name))
        gzipFile(os.path.join(share_dir, 'inputsandbox', '_input_sandbox_%s.tar' % self.is_prepared.name),
                 os.path.join(share_dir, 'inputsandbox', '_input_sandbox_%s.tgz' % self.is_prepared.name), True)
        # add the newly created shared directory into the metadata system if
        # the app is associated with a persisted object
        self.checkPreparedHasParent(self)
        self.post_prepare()
Esempio n. 4
0
    def prepare(self, force=False):
        super(GaudiPython, self).prepare(force)
        self._check_inputs()

        share_dir = os.path.join(
            expandfilename(getConfig('Configuration')['gangadir']), 'shared',
            getConfig('Configuration')['user'], self.is_prepared.name)

        fillPackedSandbox(
            self.script,
            os.path.join(share_dir, 'inputsandbox',
                         '_input_sandbox_%s.tar' % self.is_prepared.name))
        gzipFile(
            os.path.join(share_dir, 'inputsandbox',
                         '_input_sandbox_%s.tar' % self.is_prepared.name),
            os.path.join(share_dir, 'inputsandbox',
                         '_input_sandbox_%s.tgz' % self.is_prepared.name),
            True)
        # add the newly created shared directory into the metadata system if
        # the app is associated with a persisted object
        self.checkPreparedHasParent(self)
        self.post_prepare()
Esempio n. 5
0
    def _parse_options(self):
        try:
            parser = self._get_parser()
        except ApplicationConfigurationError as err:
            logger.debug("_get_parser Error:\n%s" % str(err))
            raise err

        share_dir = os.path.join(
            expandfilename(getConfig('Configuration')['gangadir']), 'shared',
            getConfig('Configuration')['user'], self.is_prepared.name)
        # Need to remember to create the buffer as the perpare methods returns
        # are merely copied to the inputsandbox so must alread exist.
        #   share_path = os.path.join(share_dir,'inputsandbox')
        #   if not os.path.isdir(share_path): os.makedirs(share_path)

        fillPackedSandbox([FileBuffer('options.pkl', parser.opts_pkl_str)],
                          os.path.join(
                              share_dir, 'inputsandbox',
                              '_input_sandbox_%s.tar' % self.is_prepared.name))
        # FileBuffer(os.path.join(share_path,'options.pkl'),
        # parser.opts_pkl_str).create()
        # self.prep_inputbox.append(File(os.path.join(share_dir,'options.pkl')))

        # Check in any input datasets defined in optsfiles and allow them to be
        # read into the
        inputdata = parser.get_input_data()
        if len(inputdata.files) > 0:
            logger.warning(
                'Found inputdataset defined in optsfile, '
                'this will get pickled up and stored in the '
                'prepared state. Any change to the options/data will '
                'therefore require an unprepare first.')
            logger.warning(
                'NOTE: the prefered way of working '
                'is to define inputdata in the job.inputdata field. ')
            logger.warning(
                'Data defined in job.inputdata will superseed optsfile data!')
            logger.warning(
                'Inputdata can be transfered from optsfiles to the job.inputdata field '
                'using job.inputdata = job.application.readInputData(optsfiles)'
            )
            share_path = os.path.join(share_dir, 'inputdata')
            if not os.path.isdir(share_path):
                os.makedirs(share_path)
            f = open(os.path.join(share_path, 'options_data.pkl'), 'w+b')
            pickle.dump(inputdata, f)
            f.close()

        # store the outputsandbox/outputdata defined in the options file
        # Can remove this when no-longer need to define outputdata in optsfiles
        # Can remove the if job: when look into how to do prepare for standalone app
        # move into RuntimeHandler move whole parsing into options maybe?

        # try and get the job object
        # not present if preparing standalone app

        # must change this as prepare should be seperate from the jpb.inputdata

        share_path = os.path.join(share_dir, 'output')
        if not os.path.isdir(share_path):
            os.makedirs(share_path)
        f = open(os.path.join(share_path, 'options_parser.pkl'), 'w+b')
        pickle.dump(parser, f)
        f.close()
Esempio n. 6
0
    def _parse_options(self):
        try:
            parser = self._get_parser()
        except ApplicationConfigurationError as err:
            logger.debug("_get_parser Error:\n%s" % str(err))
            raise err

        share_dir = os.path.join(expandfilename(getConfig('Configuration')['gangadir']),
                                 'shared',
                                 getConfig('Configuration')['user'],
                                 self.is_prepared.name)
        # Need to remember to create the buffer as the perpare methods returns
        # are merely copied to the inputsandbox so must alread exist.
        #   share_path = os.path.join(share_dir,'inputsandbox')
        #   if not os.path.isdir(share_path): os.makedirs(share_path)

        fillPackedSandbox([FileBuffer('options.pkl', parser.opts_pkl_str)],
                          os.path.join(share_dir,
                                       'inputsandbox',
                                       '_input_sandbox_%s.tar' % self.is_prepared.name))
        # FileBuffer(os.path.join(share_path,'options.pkl'),
        # parser.opts_pkl_str).create()
        # self.prep_inputbox.append(File(os.path.join(share_dir,'options.pkl')))

        # Check in any input datasets defined in optsfiles and allow them to be
        # read into the
        inputdata = parser.get_input_data()
        if len(inputdata.files) > 0:
            logger.warning('Found inputdataset defined in optsfile, '
                           'this will get pickled up and stored in the '
                           'prepared state. Any change to the options/data will '
                           'therefore require an unprepare first.')
            logger.warning('NOTE: the prefered way of working '
                           'is to define inputdata in the job.inputdata field. ')
            logger.warning(
                'Data defined in job.inputdata will superseed optsfile data!')
            logger.warning('Inputdata can be transfered from optsfiles to the job.inputdata field '
                           'using job.inputdata = job.application.readInputData(optsfiles)')
            share_path = os.path.join(share_dir, 'inputdata')
            if not os.path.isdir(share_path):
                os.makedirs(share_path)
            f = open(os.path.join(share_path, 'options_data.pkl'), 'w+b')
            pickle.dump(inputdata, f)
            f.close()

        # store the outputsandbox/outputdata defined in the options file
        # Can remove this when no-longer need to define outputdata in optsfiles
        # Can remove the if job: when look into how to do prepare for standalone app
        # move into RuntimeHandler move whole parsing into options maybe?

        # try and get the job object
        # not present if preparing standalone app

        # must change this as prepare should be seperate from the jpb.inputdata


        share_path = os.path.join(share_dir, 'output')
        if not os.path.isdir(share_path):
            os.makedirs(share_path)
        f = open(os.path.join(share_path, 'options_parser.pkl'), 'w+b')
        pickle.dump(parser, f)
        f.close()