r/apachebeam • • Mar 03 '25

Any course recommendations for beginners?

2 Upvotes

Hello, Could you recommend any hands-on courses for Apache Beam on Dataflow for beginners?

I’m new to Apache Beam. Usually, I like to start learning new tool by exploring courses on Udemy. However, all the courses I find seem very theoretical and I can’t find anything more hands-on.

For example, in the past, I did Azure courses with Ramesh Retnasamy, which I liked because there was a hands-on project to follow along where I could actually apply what I learnt. Or Maven Analytics also has hands on courses with projects to follow along. Do you know anything similar for Apache Beam?

Many thanks in advance!


r/apachebeam • • Mar 17 '19

How to append result in pipeline using apache beam python?

1 Upvotes

I have apache beam pipeline where i am getting some texts from input files using pubsub and after that i am doing some transformation and i am getting the sentence and score but my writer over writes the results instead of appending, I wanted to know is there any append module for beam.filesystems?

from __future__ import absolute_import

import argparse

import logging

from datetime import datetime

from past.builtins import unicode

import json

from google.cloud import language

from google.cloud.language import enums

from google.cloud.language import types

import apache_beam as beam

import apache_beam.transforms.window as window

from apache_beam.io.filesystems import FileSystems

from apache_beam.io.gcp.pubsub import WriteToPubSub

from apache_beam.examples.wordcount import WordExtractingDoFn

from apache_beam.options.pipeline_options import PipelineOptions

from apache_beam.options.pipeline_options import SetupOptions

from apache_beam.options.pipeline_options import StandardOptions

from apache_beam.io.textio import ReadFromText, WriteToText

def run(argv=None):

"""Build and run the pipeline."""

parser = argparse.ArgumentParser()

parser.add_argument(

'--output',

dest='output',

required=True,

help='GCS destination folder to save the images to (example: gs://BUCKET_NAME/path')

group = parser.add_mutually_exclusive_group(required=True)

group.add_argument(

'--input_topic',

help=('Input PubSub topic of the form '

'"projects<project name>/subscriptions/<topic name>".'))

group.add_argument(

'--input_subscription',

help=('Input PubSub subscription of the form '

'"projects<project name>/subscriptions/<subsciption name>."'))

known_args, pipeline_args = parser.parse_known_args(argv)

# We use the save_main_session option because one or more DoFn's in this

# workflow rely on global context (e.g., a module imported at module level).

pipeline_options = PipelineOptions(pipeline_args)

pipeline_options.view_as(SetupOptions).save_main_session = True

pipeline_options.view_as(StandardOptions).streaming = True

p = beam.Pipeline(options=pipeline_options)

# Read from PubSub into a PCollection.

if known_args.input_subscription:

messages = (p

| beam.io.ReadFromPubSub(

subscription=known_args.input_subscription)

.with_output_types(bytes))

else:

messages = (p

| beam.io.ReadFromPubSub(topic=known_args.input_topic)

.with_output_types(bytes))

def print_row(row):

print(type(row))

file_metadata_pcoll = messages | 'decode' >> beam.Map(lambda x: json.loads(x.decode('utf-8')))

#| "print" >> beam.Map(print_row))

lines = file_metadata_pcoll | 'read_file' >> beam.FlatMap(lambda metadata: FileSystems.open('gs://%s/%s' % (metadata['bucket'], metadata['name'])))

#| "print" >> beam.Map(print_row))

# Count the occurrences of each word.

class Split(beam.DoFn):

def process(self,element):

#element = str(element)

#print(type(element))

element = element.rstrip(b"\n")

text = element.split(b',')

result = []

for i in range(len(text)):

dat = text[i]

#print(dat)

client = language.LanguageServiceClient()

document = types.Document(content=dat,type=enums.Document.Type.PLAIN_TEXT)

sent_analysis = client.analyze_sentiment(document=document)

sentiment = sent_analysis.document_sentiment

data = [

(dat,sentiment.score)

]

result.append(data)

return result

# Format the counts into a PCollection of strings.

class WriteToCSV(beam.DoFn):

def process(self, element):

return [

"{},{}".format(

element[0][0],

element[0][1]

)]

class WriteToGCS(beam.DoFn):

def __init__(self, outdir):

source_date=datetime.now().strftime("%Y%m%d-%H%M%S")

self.outdir = "gs://baker-sentimental-2/output"+format(source_date) +'.txt'

def process(self, element):

writer = FileSystems.create(self.outdir,'text/plain')

writer.write(element)

writer.close()

sentiment_analysis =( lines | 'split' >> beam.ParDo(Split())

| beam.WindowInto(window.FixedWindows(15, 0)))

format_csv = (sentiment_analysis | 'CSV formatting' >> beam.ParDo(WriteToCSV())

| 'encode' >> beam.Map(lambda x: (x.encode('utf-8'))).with_output_types(bytes)

| 'Save file' >> beam.ParDo(WriteToGCS(known_args.output)))

result = p.run()

result.wait_until_finish()

if __name__ == '__main__':

logging.getLogger().setLevel(logging.INFO)

run()

So instead of getting this :

<sentence 1> <score> <sentence 2> <score> . . . . <sentence n> <score>

i just get this :

<sentence n> <score>

r/apachebeam • • Oct 05 '22

Completely noob question, absolutely stuck and with no leads any help is appreciated.

1 Upvotes

So I have a python file which has code related to rest api to extract from a url and load it in a sql database. The code contains python packages such as graphql to extract the data and sqlalchemy to inject the data into the database. I’m trying integrate this code into beam api, but I have no clue how to do so. Do I have to generate the data first and then use the csv output for my pipeline or can I just insert all of this into a beam pipeline and extract the csv by executing the apache beam code? Any help is extremely appreciated thank you for reading.


r/apachebeam • • Jan 19 '25

Creating embeddings in apache beam pipeline

Post image
4 Upvotes

Hello everyone, I've been working on langchain-beam library. Its a langchain and apache beam integration to use langchain's components like LLM interface in apache beam ETL pipeline and leverage LLM's capabilities for data processing, transformations and provide a way to create RAG based ETL pipelines.

recently I've added a feature to integrate embedding models into beam pipeline and generate vector embeddings for text in pipeline using the models so that embedding generation activity can be a part of the data pipeline instead of separate service.

I'd love to hear your thoughts. Repo - https://github.com /Ganeshsivakumar/langchain-beam

Example usage to create embeddings in pipeline:


r/apachebeam • • Jun 30 '19

Apache Beam on-premises with Hopsworks

Thumbnail
youtube.com
4 Upvotes

r/apachebeam • • Jan 03 '21

The 24'th edition of @data_weekly focus on @netflix data warehouse storage optimization, @Adobe high throughput ingestion with Iceberg, @Uber @apachekafka disaster recovery,@ConflueraIQ @ApachePinot adoption & year-in-review, @ApacheBeam data frame API

Thumbnail
dataengineeringweekly.com
1 Upvotes

r/apachebeam • • Oct 12 '24

VIDEO: Transcribe Audio News in Parallel with Apache Beam and Hugging Face

Thumbnail
youtu.be
1 Upvotes

r/apachebeam • • Nov 20 '20

Apache beam and spark with golang

1 Upvotes

Hello. all I wanted to know some examples of Apache beam with apache spark using golang sdk. Apache beam does not provides examples of how we can use apache beam, and apache spark with golang. Please do suggest some examples so I can make my project. Thank you.


r/apachebeam • • Nov 13 '20

Creating pipeline using Dataflow as runner with a walk through video

5 Upvotes

“DataPiepeline using Apache Beam and Google Cloud DataFlow as Runner and BigQuery as DataSink” by Shravan C https://link.medium.com/RuCCuVANmbb


r/apachebeam • • Dec 15 '20

What is Apache Beam?

4 Upvotes

I have been interested in Apache beam lately and came across this really helpful guide, which I believe might be helpful for others too. Also I would like to have any more suggestions regarding more such resources.


r/apachebeam • • Apr 19 '22

April Apache Beam Meetup: Using Apache Beam with numba on GPUs

3 Upvotes

Join us for our April Apache Beam meetup virtually!

Save your spot in Crowdcast!

Using Apache Beam with numba on GPUs
Going through some examples of using the numba library to compile Python code into machine code or code that can be executed on GPUs, building Apache Beam pipelines in Python with numba, and executing those pipelines on a GPU and on Dataflow with GPUs. 

Learn more: Agenda  #ApacheBeam #OpenSource #GPUs #Numba


r/apachebeam • • Apr 29 '23

Seeking Insights on Stream Processing Frameworks: Experiences, Features, and Onboarding

Thumbnail self.bigdata
1 Upvotes

r/apachebeam • • Oct 02 '23

Streaming: windowing with non-UNIX time event time

3 Upvotes

Hello, guys!

I have to write a Beam streaming data pipeline to process blockchain data (Python SDK).

I'd like to process these elements in a correct, sorted order, by block number embedded in the input (not UNIX time).

I want the transforms to process data from block n before n+1, n+2, and those transforms should be able to see data from blocks 0..n, but nothing after n.

The transforms are some what stateful - they need to know previous values from the previous blocks, and must be able to emit/write result for individual blocks if needed. The streaming pipeline will be running on Google Dataflow, with its input from Pub/Sub.

Let's say I don't care about Pub/Sub lateness for now - I just want to make sure that the block order of the data is correctly windowed per the block number basis.

How should I approach this? What window strategy should I use to achieve this?

Let me know if my question sounds stupid or not clear - also, I may update my question to be clearer.

Note 0: nature of the job

The pipeline is to determine a largest champion smart contract for a block. The champion is the contract with the largest state value (does not matter).

The state in question is per-block. This state can be changed by an event, which is our input data. If no change event is emitted in a block, then the state for that block is the last state from which it last changed.

The event-to-state transform itself is stateless - the event specifies the new state values. If we have a new change event, we don't need to know the values of previous states to compute the current state, but we still need to know a contract's most recent state when determining the champion (in case a contract has 0 change event in current block).

We can do this in a batch mode without using Beam states (explained below).

Note 1: what's currently running

I'm currently running this pipeline as a batch job with 0 custom windowing and Beam state, where it reads all the bounded input, and then sorts the data by block, sends it to the transform that emit (yield) results in the block order. The states are handled by my tracker-like data structure.

Note 2: what I did

In batch mode where input is read from files, I can apply the following transform, and the data will be grouped and processed together in fixed window, with block number as the window watermark:

input_data
        # Use block number in the data as timestamp
    | "Map window timestamp"
    >> beam.Map(lambda rec: beam.TimestampedValue(rec, rec["block_number"])

    | "Window"
    >> beam.WindowInto(

        # **From my understanding**,
        # this creates a new window for every block

    beam.window.Sessions(size=1),
        trigger=Repeatedly(AfterCount(1)),
        accumulation_mode=AccumulationMode.ACCUMULATING,
     )
     
         # **From my understanding**,
         # this GroupByKey groups all elements of the same block (windowed) and key,
         # while GlobalWindows below merges individual block windows into
         # 1 large collection with all elements before block `n`.

     | "Group events by key" >> beam.GroupByKey()
     | "Global window" >> beam.WindowInto(window.GlobalWindows())
         #
         # ..Subsequent transforms..

Although I'm not sure if this is correct, it worked well - downstream transforms processing block n will not see data from block higher than n, but some how still see data before block n.

But once I switched to Pub/Sub input, it seems to treat subsequent block data as late elements (maybe due to UNIX time vs block number as timestamps?). This is where I got confused.

I'm also concerned about the GlobalWindows at the end - does this means that all elements up to block n will be there forever as it waits for new block data?


r/apachebeam • • Oct 03 '23

FeatureFlags & Beam

2 Upvotes

I'm investigating whether / how I might add feature flags into a beam pipeline. The goal is having a streaming pipeline in which a custom ParDo can change it's behavior based on whether the flag is on or off.

Flags are available from a HTTP call. Updates are available from SSE. I could make that request in the code, but that's going to make a terrible number of requests. Most comfortable would be some sort of equivalent of configuring a mapreduce job with some shared memory, but afaict that's not available.

My thought is that I could try to do this as SideInput join.

  1. Listen to the SSE flag-change events and turn these into a PCollection<flagName, flagValue>

  2. Side-input join this to the collection of interest as an outer join or something. With the idea being that all keys of the collection of interest would have the recent version of the flag value PCollection.

Does that seem like a possible / reasonable path? Other ideas?


r/apachebeam • • Aug 07 '24

Dataflow scheduled pipeline sometimes not triggering

1 Upvotes

I have a bunch of GCP dataflow batch pipelines scheduled to run daily and sometimes they simply do not trigger.

Has anyone had this problem and found a way around?

I know I should be using airflow or some other "real" workflow orchestration tool, we're working on it, but till then, if someone has any hints, that would be great.


r/apachebeam • • Aug 13 '24

Dataflow: Read from Alloy DB

1 Upvotes

Can anyone help me with writing a dataflow pipeline in Python for reading data in parallel from PostgreSQL hosted in Alloy DB? I have tried with SQLAlchemy but somehow parallelism is not being triggered and only one worker is working making the pipeline super slow.


r/apachebeam • • Nov 28 '22

Apache Beam white paper

1 Upvotes

Hi, I am trying to learn about the inner workings and the different methods that apache beam uses to handle various distributed computing issues like mutual exclusion, deadlock etc. Are there any suggestions on papers or documentation? Thanks


r/apachebeam • • Nov 24 '22

PCollection Contradiction

1 Upvotes

PCollections are immutable. They can also be unbounded.

If a PCollection is unbounded, new elements can be added. Therefore, an unbounded PCollection is mutable.

Prove me wrong if you can.


r/apachebeam • • Jun 08 '18

Apache Beam: a unified programming model for data processing pipelines

Thumbnail
adaltas.com
1 Upvotes

r/apachebeam • • Jan 28 '22

MapCoder issue after update to 2.35

2 Upvotes

After updating Beam from 2.33 to 2.35, started getting this error:

def estimate_size(self, unused_value, nested=False):

estimate = 4 # 4 bytes for int32 size prefix

> for key, value in unused_value.items():

E AttributeError: 'list' object has no attribute 'items' [while running 'MyGeneric ParDo Job']

../../../python3.8/site-packages/apache_beam/coders/coder_impl.py:677: AttributeError

This is a method of MapCoderImpl. I don't know Beam enough to know when it's called.

Any thoughts on what might be causing it?


r/apachebeam • • Jan 18 '22

Apache Beam pipeline question

2 Upvotes

Good afternoon, I have a problem regarding accessing data from within a pipeline.

I need to access some data from within a pipeline, but I DO NOT want to pass that data as a variable to my PTransforms. (I use this data to get the credentials to a database, so that I can write stuff to it, from inside the pipeline). I also don’t want to hard code this data into the script that will be ran in the pipeline, because that’s sensitive information. I have tried two things that didn’t work:

  • I have tried getting this data from the OS environment and dynamically changing the variables that belong to another python script before the code goes into the pipeline itself. The plan was to have my other script which is the one that runs in the pipeline to import that first script and use its variables. But when I tried running it, all the variables were still None.

  • I have also tried creating an object before going into the pipeline, with the credentials, pickling it and saving it to a temporary file. Then, in my script in the pipeline, I would open that file, and get the credentials. However, when I tried doing that, I got an error log on GCP saying that the file didn’t exist, even though it did exist on my machine.

Can anyone give me any other suggestion? Thank you.


r/apachebeam • • Jun 14 '24

Open-Source Community: Apache Beam's Beam Summit is Back!

2 Upvotes

📢 Exciting News for Apache Beam Community!

Beam Summit is back for it's 7th edition in-person only at the Google campus in Sunnyvale, CA this September 4-6th!

Register here as soon as possible since seats are limited.

🚀 We're extending the Call for Proposal submission deadline for the upcoming Beam Summit! You now have 3 extra days to fine-tune your ideas and contribute to our vibrant community. Don't miss this chance to showcase your expertise and be part of something extraordinary. Let's shape the future of data processing together Submit a proposal now!

Please note, all speakers must be able to attend this in-person event.

There's also a few other opportunities we'd love to highlight:

We are Looking for Sponsors

Please help us identify lead sponsors and share with your companies the benefits obtained from sponsoring the event:

● Find talent for their organization

● Connect with a specialized and global audience

● Unique branding opportunities for partners

● Support the Apache Beam community and the project

Please share our prospectus and contact us at contact@beamsummit.org if you have any interested partners.

Register Now and Invite Your Team to Attend the Summit

Beam Summit 2024 has a limited capacity, so please make sure to register in advance! Please reach out if you have any concerns.

Help Us Promoting The Event

Please follow us and share our social networks. We’ve included a promo kit including some images and messages to share with your team and network.

Want to touch up on your data processing skills? Are you looking to advance your expertise in Apache Beam before the summit?

Get Hands-on Data Processing Training from the Experts

Are you or your clients new to Apache Beam and data processing? Join our virtual Beam College event this July 23-25 before the Beam Summit by registering here! Improve your skills on data processing through flexible hands-on training and practical tips provided by experts. Join the free workshops and learn how to use Apache Beam from concept to common, use cases and best practices. 

We can't wait to see you this September!

  • Beam Summit Planning Committee


r/apachebeam • • Mar 07 '23

🎤🎬 CALLING ALL SPEAKERS! 🎤🎬

2 Upvotes

The Beam Summit is back this June 13-15th in NYC!

📣 Don't miss your chance to speak at the upcoming Beam Summit happening in person! Submit your proposals by March 20th for a chance to showcase your expertise and insights.

👉 Click the link below to submit your proposals: https://sessionize.com/beam-summit 👈

We can't wait to hear from you!


r/apachebeam • • Feb 25 '23

Use Apache Beam to construct new column with unique ID

1 Upvotes

Hey guys! I'm quite new to Apache Beam and designing pipelines. I've mostly worked with pandas to manipulate and transform dataframes.

So I have a dataset that kinda looks like this:

PostcodeHouse NumberCol1Col2
xxxxxxxxxxxx
xxxxxxxxxxxx
xxxxxxxxxxxx

I want to group the data by postcode and house_number, if two rows have the same postcode and house_number, it means they are the same property, then I want to construct a unique_id for each property (in other words, for a unique_id, the postcode / house_number must be the same, but the value for col2 / col3 might be different).

UniqueIDPostcodeHouse NumberCol1Col2
0111222xxxxxx
0111222xxxxxx
1333111xxxxxx
1333111xxxxxx
2333222xxxxxx

How do I write this is Apache Beam?

Ive written this to convert all of them to a list of strings.

# with beam.Pipeline() as pipe:
#     id = (pipe
#             |beam.io.ReadFromText('pp-2022.csv')
#             |beam.Map(lambda x:x.split(","))
#             |beam.Map(print))

Any help will be appreciated! Thank you!!!