Ejemplo n.º 1
0
    def execute(self, model_id, filename, actual_records):
        if filename:
            self.ctx.log('Sending actuals on data in %s' % filename)
            if filename and not fsclient.is_s3_path(filename):
                filename = os.path.abspath(filename)

            return self._file_actual_to_cloud(filename, model_id)
        else:
            return self._actuals_to_cloud(actual_records, model_id)
Ejemplo n.º 2
0
 def download_prediction_result(self, results, local_file):
     for provider in results.keys():
         result = results[provider]
         predicted = dict_dig(result, 'data', 'predicted')
         if predicted and type(predicted) == str and fsclient.is_s3_path(
                 predicted):
             file_path = os.path.splitext(local_file)[0] + '_predicted.csv'
             client = self.create_uploader()
             client.download(predicted, file_path)
             result['data']['predicted'] = file_path
             self.ctx.log(f'{predicted} downloaded to {file_path}')
Ejemplo n.º 3
0
    def load(self, path=None):
        if path is None:
            path = os.getcwd()
        for pname in self.part_names:
            filename = os.path.join(path, '%s.yaml' % pname)

            if not fsclient.is_s3_path(filename):
                filename = os.path.abspath(filename)

            if fsclient.is_file_exists(filename):
                self.parts[pname] = self._load(filename)
        self.is_loaded = True
Ejemplo n.º 4
0
    def verify(data_source_file, config_path=None):
        if urllib.parse.urlparse(data_source_file).scheme in ['http', 'https']:
            return data_source_file, False

        if not fsclient.is_s3_path(data_source_file):
            if config_path is None:
                config_path = os.getcwd()

            data_source_file = os.path.join(config_path, data_source_file)
            if not fsclient.is_s3_path(data_source_file):
                data_source_file = os.path.abspath(data_source_file)

        filename, file_extension = os.path.splitext(data_source_file)
        if not file_extension in SUPPORTED_FORMATS:
            raise AugerException(
                'Source file has to be one of the supported fomats: %s' %
                ', '.join(SUPPORTED_FORMATS))

        if not fsclient.is_file_exists(data_source_file):
            raise AugerException(
                'Can\'t find file to import: %s' % data_source_file)

        return data_source_file, True
Ejemplo n.º 5
0
    def mk_project_folder(self):
        if not self.ctx.config.path:
            project_path = os.path.join(os.getcwd(), self.project_name)
        else:
            project_path = self.ctx.config.path

        if not fsclient.is_s3_path(project_path):
            project_path = os.path.abspath(project_path)

        if fsclient.is_folder_exists(project_path):
            raise Exception(
                'Can\'t create \'%s\'. Folder already exists.' % \
                    self.project_name)

        fsclient.create_folder(project_path)
        self.ctx.log('Created project folder %s', self.project_name)
        return project_path
Ejemplo n.º 6
0
    def execute(self,
                filename,
                model_id,
                threshold=None,
                locally=False,
                data=None,
                columns=None,
                output=None):
        if filename and not fsclient.is_s3_path(filename):
            self.ctx.log('Predicting on data in %s' % filename)
            filename = os.path.abspath(filename)

        if locally:
            predicted = self._predict_locally(filename, model_id, threshold,
                                              data, columns, output)
        else:
            predicted = self._predict_on_cloud(filename, model_id, threshold,
                                               data, columns, output)

        return predicted