From bc75182d0f0901c03f4a71957412b102bf3da61e Mon Sep 17 00:00:00 2001 From: Ivanildo Barauna de Souza Junior Date: Sun, 11 Aug 2024 05:44:36 +0000 Subject: [PATCH 1/3] feat: update to Python 10 --- Dockerfile | 2 +- pipeline/launcher.py | 6 +++--- pipeline_runner.sh | 15 +-------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3ddc29..831934a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM apache/beam_python3.9_sdk:2.57.0 +FROM apache/beam_python3.10_sdk:2.57.0 WORKDIR /app diff --git a/pipeline/launcher.py b/pipeline/launcher.py index b23b457..2691aef 100644 --- a/pipeline/launcher.py +++ b/pipeline/launcher.py @@ -10,8 +10,8 @@ metrics_client = MetricsClient() -def increment_metric(element): - metrics_client.incr(metric_name=f"{APPLICATION_NAME}.extracted", value=1) +def increment_metric(element, metric_name: str): + metrics_client.incr(metric_name=f"{APPLICATION_NAME}.{metric_name}", value=1) return element @@ -20,7 +20,7 @@ def run(): ( p | "ReadTopic" >> beam.io.ReadFromPubSub(subscription=PUBSUB_SUBSCRIPTION) - | "ExtractMetric" >> beam.Map(lambda x: increment_metric(x)) + | "ExtractMetric" >> beam.Map(lambda x: increment_metric(x, "extracted")) | "Decode" >> beam.Map(lambda x: x.decode("utf-8")) | "CreateKey" >> beam.Map(set_key, "created_at", 8) | "Window" >> beam.WindowInto(beam.window.FixedWindows(5)) diff --git a/pipeline_runner.sh b/pipeline_runner.sh index c04b209..be051da 100644 --- a/pipeline_runner.sh +++ b/pipeline_runner.sh @@ -1,15 +1,3 @@ -## Using setup.py - -#python main.py --project ivanildobarauna \ -# --region us-east4 \ -# --runner Dataflowrunner \ -#--setup_file ./setup.py \ -#--staging_location gs://gcp-streaming-pipeline-dataflow/staging \ -#--temp_location gs://gcp-streaming-pipeline-dataflow/temp \ -#--save_main_session - -## Using container - python main.py --project ivanildobarauna \ --region us-east4 \ --runner DataflowRunner \ @@ -20,5 +8,4 @@ python main.py --project ivanildobarauna \ --worker_machine_type=n1-standard-1 \ --num_workers=1 \ --max_num_workers=1 \ - --autoscaling_algorithm=NONE - + --autoscaling_algorithm=NONE \ No newline at end of file From 067b9d4b49019cf1b98071db303f51997e5bb519 Mon Sep 17 00:00:00 2001 From: Ivanildo Barauna de Souza Junior Date: Tue, 13 Aug 2024 10:39:53 -0300 Subject: [PATCH 2/3] feature: increment writed_metric --- .../{BuildImage.xml => Build.xml} | 2 +- .idea/runConfigurations/PipelineDeploy.xml | 8 ++++ .../runConfigurations/PipelineDeployment.xml | 17 ++++++++ .../{PipelineRunner.xml => PipelineTest.xml} | 4 +- .../{PushImage.xml => Push.xml} | 2 +- Dockerfile | 2 + main.py | 3 ++ pipeline/launcher.py | 40 +++++++++++++------ pipeline/utils/send_metrics.py | 9 ++++- pipeline_runner.sh => pipeline_deployment.sh | 0 pipeline_test.sh | 11 +++++ 11 files changed, 80 insertions(+), 18 deletions(-) rename .idea/runConfigurations/{BuildImage.xml => Build.xml} (77%) create mode 100644 .idea/runConfigurations/PipelineDeploy.xml create mode 100644 .idea/runConfigurations/PipelineDeployment.xml rename .idea/runConfigurations/{PipelineRunner.xml => PipelineTest.xml} (81%) rename .idea/runConfigurations/{PushImage.xml => Push.xml} (91%) rename pipeline_runner.sh => pipeline_deployment.sh (100%) create mode 100644 pipeline_test.sh diff --git a/.idea/runConfigurations/BuildImage.xml b/.idea/runConfigurations/Build.xml similarity index 77% rename from .idea/runConfigurations/BuildImage.xml rename to .idea/runConfigurations/Build.xml index ae1be5b..af720d9 100644 --- a/.idea/runConfigurations/BuildImage.xml +++ b/.idea/runConfigurations/Build.xml @@ -1,5 +1,5 @@ - +