def export_blocks_and_transactions_command(execution_date, provider_uri, **kwargs):
        with TemporaryDirectory() as tempdir:
            start_block, end_block = get_block_range(tempdir, execution_date, provider_uri)

            logging.info('Calling export_blocks_and_transactions({}, {}, {}, {}, {}, ...)'.format(
                start_block, end_block, export_batch_size, provider_uri, export_max_workers))

            export_blocks_and_transactions.callback(
                start_block=start_block,
                end_block=end_block,
                batch_size=export_batch_size,
                provider_uri=provider_uri,
                max_workers=export_max_workers,
                blocks_output=os.path.join(tempdir, "blocks.csv"),
                transactions_output=os.path.join(tempdir, "transactions.csv"),
            )

            copy_to_export_path(
                os.path.join(tempdir, "blocks_meta.txt"), export_path("blocks_meta", execution_date)
            )

            copy_to_export_path(
                os.path.join(tempdir, "blocks.csv"), export_path("blocks", execution_date)
            )

            copy_to_export_path(
                os.path.join(tempdir, "transactions.csv"), export_path("transactions", execution_date)
            )
Пример #2
0
    def export_blocks_and_transactions_command(execution_date, **kwargs):
        task_instance = kwargs['ti']
        live_uri = task_instance.xcom_pull(key='live_uri',
                                           task_ids='node_watch')
        with TemporaryDirectory() as tempdir:
            start_block, end_block = get_block_range(tempdir,
                                                     execution_date,
                                                     provider_uri=live_uri)

            logging.info(
                'Calling export_blocks_and_transactions({}, {}, {}, {}, {}, ...)'
                .format(start_block, end_block, export_batch_size, live_uri,
                        export_max_workers))

            export_blocks_and_transactions.callback(
                start_block=start_block,
                end_block=end_block,
                batch_size=export_batch_size,
                provider_uri=live_uri,
                max_workers=export_max_workers,
                blocks_output=os.path.join(tempdir, "blocks.csv"),
                transactions_output=os.path.join(tempdir, "transactions.csv"),
            )

            copy_to_export_path(os.path.join(tempdir, "blocks_meta.txt"),
                                export_path("blocks_meta", execution_date))

            copy_to_export_path(os.path.join(tempdir, "blocks.csv"),
                                export_path("blocks", execution_date))

            copy_to_export_path(os.path.join(tempdir, "transactions.csv"),
                                export_path("transactions", execution_date))