Skip to content

cc1358/Data-Pipelines-with-Concurrency

Repository files navigation

Again, we conduct an assignment with concurrency to reduce processing tasks in a data pipeline. The original code is in this repository under main.go, and there are four new images that we replace in this assignment (Flower.jpeg, DeKooning.jpeg, MilanDuomo.jpeg, and Raphael.jpeg)

The enhanced file with new features is named mymain.go. The first adjustment is that we add error handling, which raises flags/errors if opening or decoding an image fails. This ensures that even if there are errors with some images, the program is able to log an error but not halt completely and continue processing other images. This happens in the loadImage function. Additionally, there is more error handling when writing the image to the output path in the saveImage function. If there is any error during writing the images, it's not explicitly handled here, but a successful write is assumed, and true is sent to the output channel.

The second adjustment is in the benchmarkPipeline function. This function is responsible for running the entire image processing pipeline and capturing the throughput time. It accepts a slice of image paths as input, uses a timer, and creates and chains the pipeline stages using channels, making sure that each stage processes the image concurrently. It waits for results with the writeResults channel and calculates the elapsed time.

The third adjustment creates unit tests in a separate file in mymain_test.go. Using Github Copilot, we create unit tests for each function. These verify the correctness of each function of the mymain.go code with the testing Go package. These tests ensure each function behaves as expected in isolation.

Again, we see Go as an efficient way to take advantage of multicore processors with concurrency to run a task as desired. In MSDS 430, I completed a similar task of converting images in Python, but, after completing this task in Go, I would prefer to use Go and all of its features to manage pipelines with concurrency.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages