コード例 #1
0
 def run(self):
     client = GCSClient()
     if self.string:
         client.put_string(contents=self.string, dest_path=self.gs_path, mimetype=self.mime_type)
     elif self.file_path:
         client.put(filename=self.file_path, dest_path=self.gs_path, mimetype=self.mime_type)
         if self.remove_file:
             os.remove(self.file_path)
コード例 #2
0
    def run(self):
        result_folder = self.input()['results'].path

        with open(self.input()['run_name'].path, 'r') as f:
            run_name = f.read()

        zipfile_name = shutil.make_archive(run_name, 'zip', result_folder)

        service_account_info = json.loads(
            os.environ.get('GOOGLE_APPLICATION_CREDENTIALS_JSON'))
        credentials = service_account.Credentials.from_service_account_info(
            service_account_info)

        client = GCSClient(oauth_credentials=credentials)

        client.put(zipfile_name, f"{self.bucket}/{run_name}.zip")
コード例 #3
0
 def run(self):
     client = GCSClient()
     source_path = f"resources/csv/{self.date.isoformat()}.csv"
     client.put(source_path,
                dest_path=f"gs://luigi_example/{self.date.isoformat()}.csv")