You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "charlespnh (via GitHub)" <gi...@apache.org> on 2025/08/07 13:38:28 UTC

[PR] YAML A Batch ML Pipeline Example [beam]

charlespnh opened a new pull request, #35810:
URL: https://github.com/apache/beam/pull/35810

   Part of the larger effort https://github.com/apache/beam/issues/35068 and https://github.com/apache/beam/issues/35070 to add more examples involving ML workloads and Iceberg.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/actions/workflows/build_wheels.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/actions/workflows/python_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/actions/workflows/java_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/actions/workflows/go_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "derrickaw (via GitHub)" <gi...@apache.org>.
derrickaw commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3180166788

   LGTM
   
   CC @shunping - anomaly detection


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3176819972

   Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3177777630

   Assigning reviewers:
   
   R: @jrmccluskey for label python.
   
   
   Note: If you would like to opt out of this review, comment `assign to next reviewer`.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "charlespnh (via GitHub)" <gi...@apache.org>.
charlespnh commented on code in PR #35810:
URL: https://github.com/apache/beam/pull/35810#discussion_r2280003705


##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/batch_log_analysis.sh:
##########
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Usage:
+# With DirectRunner:
+# ./batch_log_analysis.sh --runner DirectRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+# With DataflowRunner:
+# ./batch_log_analysis.sh --runner DataflowRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --temp_location gs://YOUR-BUCKET/temp \
+#   --num_workers 1 \
+#   --worker_machine_type n1-standard-2 \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+set -e
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    --runner) RUNNER="$2"; shift 2 ;;
+    --project) PROJECT="$2"; shift 2 ;;
+    --region) REGION="$2"; shift 2 ;;
+    --temp_location) TEMP_LOCATION="$2"; shift 2 ;;
+    --num_workers) NUM_WORKERS="$2"; shift 2 ;;
+    --worker_machine_type) WORKER_MACHINE_TYPE="$2"; shift 2 ;;
+    --warehouse) WAREHOUSE="$2"; shift 2 ;;
+    --bq_table) BQ_TABLE="$2"; shift 2 ;;
+    *) echo "Unknown argument: $1"; exit 1 ;;
+  esac
+done
+
+if [[ "$RUNNER" == "DataflowRunner" ]]; then
+  DATAFLOW_COMMON_ARGS="--job_name batch-log-analysis-$(date +%Y%m%d-%H%M%S)
+    --project $PROJECT --region $REGION
+    --temp_location $TEMP_LOCATION
+    --num_workers $NUM_WORKERS --worker_machine_type $WORKER_MACHINE_TYPE
+    --disk_size_gb 50"
+else
+  DATAFLOW_COMMON_ARGS=""
+fi
+
+echo "Running iceberg_migration.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file iceberg_migration.yaml \

Review Comment:
   I've updated README.md instead with setting up the virtual env. The script can be run multiple times, and also I think it's a better separation of concerns where instructions for environment set up (GCS, BigQuery, virtual env) is on the README, and the script is purely for the workflow.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "charlespnh (via GitHub)" <gi...@apache.org>.
charlespnh commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3176156414

   CC @chamikaramj 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3186772941

   ## [Codecov](https://app.codecov.io/gh/apache/beam/pull/35810?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `64.28571%` with `10 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 56.70%. Comparing base ([`0e47f80`](https://app.codecov.io/gh/apache/beam/commit/0e47f80865e038f3fb3cc53c09e8b607c072cf52?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f4fd1c5`](https://app.codecov.io/gh/apache/beam/commit/f4fd1c5322e9ef2eaa8d377d8ce8c0543ef3d031?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/beam/pull/35810?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...on/apache\_beam/yaml/examples/testing/input\_data.py](https://app.codecov.io/gh/apache/beam/pull/35810?src=pr&el=tree&filepath=sdks%2Fpython%2Fapache_beam%2Fyaml%2Fexamples%2Ftesting%2Finput_data.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0veWFtbC9leGFtcGxlcy90ZXN0aW5nL2lucHV0X2RhdGEucHk=) | 64.28% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/beam/pull/35810?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #35810      +/-   ##
   ============================================
   + Coverage     56.69%   56.70%   +0.01%     
     Complexity     3380     3380              
   ============================================
     Files          1204     1205       +1     
     Lines        184118   184191      +73     
     Branches       3507     3507              
   ============================================
   + Hits         104383   104452      +69     
   - Misses        76406    76410       +4     
     Partials       3329     3329              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/beam/pull/35810/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [python](https://app.codecov.io/gh/apache/beam/pull/35810/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `80.99% <64.28%> (+0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/beam/pull/35810?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "charlespnh (via GitHub)" <gi...@apache.org>.
charlespnh commented on PR #35810:
URL: https://github.com/apache/beam/pull/35810#issuecomment-3179271454

   These errors seem to be unrelated to this PR change...
   
   For future reference, this workflow has been verified with the following Dataflow jobs:
   iceberg_migration.yaml https://console.cloud.google.com/dataflow/jobs/us-central1/2025-08-11_19_04_56-12798857769020762763;graphView=0?pageState=(%22dfTime%22:(%22s%22:%222025-08-12T02:04:57.389Z%22,%22e%22:%222025-08-12T02:08:01.605Z%22))&project=apache-beam-testing
   
   ml_preprocessing.yaml https://console.cloud.google.com/dataflow/jobs/us-central1/2025-08-11_19_13_40-12701512100050493448;bottomTab=WORKER_LOGS;expandBottomPanel=true;graphView=0;logsSeverity=INFO?pageState=(%22dfTime%22:(%22s%22:%222025-08-12T02:13:40.861Z%22,%22e%22:%222025-08-12T02:16:17.602Z%22))&project=apache-beam-testing
   
   anomaly_scoring.yaml https://console.cloud.google.com/dataflow/jobs/us-central1/2025-08-11_19_27_04-16453420012263502086;bottomTab=WORKER_LOGS;expandBottomPanel=true;graphView=0;logsSeverity=INFO?pageState=(%22dfTime%22:(%22s%22:%222025-08-12T02:27:05.378Z%22,%22e%22:%222025-08-12T02:27:38.054Z%22))&project=apache-beam-testing


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "chamikaramj (via GitHub)" <gi...@apache.org>.
chamikaramj commented on code in PR #35810:
URL: https://github.com/apache/beam/pull/35810#discussion_r2279532686


##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/iceberg_migration.yaml:
##########
@@ -0,0 +1,42 @@
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+

Review Comment:
   Could you add a small description to the beginning of each of the yaml pipeline files ?



##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/batch_log_analysis.sh:
##########
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Usage:
+# With DirectRunner:
+# ./batch_log_analysis.sh --runner DirectRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+# With DataflowRunner:
+# ./batch_log_analysis.sh --runner DataflowRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --temp_location gs://YOUR-BUCKET/temp \
+#   --num_workers 1 \
+#   --worker_machine_type n1-standard-2 \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+set -e
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    --runner) RUNNER="$2"; shift 2 ;;
+    --project) PROJECT="$2"; shift 2 ;;
+    --region) REGION="$2"; shift 2 ;;
+    --temp_location) TEMP_LOCATION="$2"; shift 2 ;;
+    --num_workers) NUM_WORKERS="$2"; shift 2 ;;
+    --worker_machine_type) WORKER_MACHINE_TYPE="$2"; shift 2 ;;
+    --warehouse) WAREHOUSE="$2"; shift 2 ;;
+    --bq_table) BQ_TABLE="$2"; shift 2 ;;
+    *) echo "Unknown argument: $1"; exit 1 ;;
+  esac
+done
+
+if [[ "$RUNNER" == "DataflowRunner" ]]; then
+  DATAFLOW_COMMON_ARGS="--job_name batch-log-analysis-$(date +%Y%m%d-%H%M%S)
+    --project $PROJECT --region $REGION
+    --temp_location $TEMP_LOCATION
+    --num_workers $NUM_WORKERS --worker_machine_type $WORKER_MACHINE_TYPE
+    --disk_size_gb 50"
+else
+  DATAFLOW_COMMON_ARGS=""
+fi
+
+echo "Running iceberg_migration.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file iceberg_migration.yaml \
+  --runner $RUNNER \
+  --jinja_variables '{ "WAREHOUSE":"'$WAREHOUSE'", "PROJECT":"'$PROJECT'", "REGION":"'$REGION'" }' \
+  $DATAFLOW_COMMON_ARGS
+
+echo "Running ml_preprocessing.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file ml_preprocessing.yaml \
+  --runner $RUNNER \
+  --jinja_variables '{ "WAREHOUSE":"'$WAREHOUSE'", "PROJECT":"'$PROJECT'", "REGION":"'$REGION'", "BQ_TABLE":"'$BQ_TABLE'" }' \
+  $DATAFLOW_COMMON_ARGS \
+  --requirements_file requirements.txt
+
+echo "Running train.py..."
+python train.py --bq_table $BQ_TABLE
+
+echo "Uploading trained model to GCS..."
+gcloud storage cp "./knn_model.pkl" "$WAREHOUSE/knn_model.pkl"

Review Comment:
   In the beginning of the script, check for the availability of binaries used here (gcloud, Python etc.) and fail with appropriate errors.



##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/batch_log_analysis.sh:
##########
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Usage:
+# With DirectRunner:
+# ./batch_log_analysis.sh --runner DirectRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+# With DataflowRunner:
+# ./batch_log_analysis.sh --runner DataflowRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --temp_location gs://YOUR-BUCKET/temp \
+#   --num_workers 1 \
+#   --worker_machine_type n1-standard-2 \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+set -e
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    --runner) RUNNER="$2"; shift 2 ;;
+    --project) PROJECT="$2"; shift 2 ;;
+    --region) REGION="$2"; shift 2 ;;
+    --temp_location) TEMP_LOCATION="$2"; shift 2 ;;
+    --num_workers) NUM_WORKERS="$2"; shift 2 ;;
+    --worker_machine_type) WORKER_MACHINE_TYPE="$2"; shift 2 ;;
+    --warehouse) WAREHOUSE="$2"; shift 2 ;;
+    --bq_table) BQ_TABLE="$2"; shift 2 ;;
+    *) echo "Unknown argument: $1"; exit 1 ;;
+  esac
+done
+
+if [[ "$RUNNER" == "DataflowRunner" ]]; then
+  DATAFLOW_COMMON_ARGS="--job_name batch-log-analysis-$(date +%Y%m%d-%H%M%S)
+    --project $PROJECT --region $REGION
+    --temp_location $TEMP_LOCATION
+    --num_workers $NUM_WORKERS --worker_machine_type $WORKER_MACHINE_TYPE
+    --disk_size_gb 50"
+else
+  DATAFLOW_COMMON_ARGS=""
+fi
+
+echo "Running iceberg_migration.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file iceberg_migration.yaml \

Review Comment:
   Could you update the script so that these run in a Python virtual machine ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "charlespnh (via GitHub)" <gi...@apache.org>.
charlespnh commented on code in PR #35810:
URL: https://github.com/apache/beam/pull/35810#discussion_r2279996220


##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/iceberg_migration.yaml:
##########
@@ -0,0 +1,42 @@
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+

Review Comment:
   Done.



##########
sdks/python/apache_beam/yaml/examples/transforms/ml/log_analysis/batch_log_analysis.sh:
##########
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Usage:
+# With DirectRunner:
+# ./batch_log_analysis.sh --runner DirectRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+# With DataflowRunner:
+# ./batch_log_analysis.sh --runner DataflowRunner \
+#   --project YOUR_PROJECT \
+#   --region YOUR_REGION \
+#   --temp_location gs://YOUR-BUCKET/temp \
+#   --num_workers 1 \
+#   --worker_machine_type n1-standard-2 \
+#   --warehouse gs://YOUR-BUCKET \
+#   --bq_table YOUR_PROJECT.YOUR_DATASET.YOUR_TABLE
+
+set -e
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    --runner) RUNNER="$2"; shift 2 ;;
+    --project) PROJECT="$2"; shift 2 ;;
+    --region) REGION="$2"; shift 2 ;;
+    --temp_location) TEMP_LOCATION="$2"; shift 2 ;;
+    --num_workers) NUM_WORKERS="$2"; shift 2 ;;
+    --worker_machine_type) WORKER_MACHINE_TYPE="$2"; shift 2 ;;
+    --warehouse) WAREHOUSE="$2"; shift 2 ;;
+    --bq_table) BQ_TABLE="$2"; shift 2 ;;
+    *) echo "Unknown argument: $1"; exit 1 ;;
+  esac
+done
+
+if [[ "$RUNNER" == "DataflowRunner" ]]; then
+  DATAFLOW_COMMON_ARGS="--job_name batch-log-analysis-$(date +%Y%m%d-%H%M%S)
+    --project $PROJECT --region $REGION
+    --temp_location $TEMP_LOCATION
+    --num_workers $NUM_WORKERS --worker_machine_type $WORKER_MACHINE_TYPE
+    --disk_size_gb 50"
+else
+  DATAFLOW_COMMON_ARGS=""
+fi
+
+echo "Running iceberg_migration.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file iceberg_migration.yaml \
+  --runner $RUNNER \
+  --jinja_variables '{ "WAREHOUSE":"'$WAREHOUSE'", "PROJECT":"'$PROJECT'", "REGION":"'$REGION'" }' \
+  $DATAFLOW_COMMON_ARGS
+
+echo "Running ml_preprocessing.yaml pipeline..."
+python -m apache_beam.yaml.main --yaml_pipeline_file ml_preprocessing.yaml \
+  --runner $RUNNER \
+  --jinja_variables '{ "WAREHOUSE":"'$WAREHOUSE'", "PROJECT":"'$PROJECT'", "REGION":"'$REGION'", "BQ_TABLE":"'$BQ_TABLE'" }' \
+  $DATAFLOW_COMMON_ARGS \
+  --requirements_file requirements.txt
+
+echo "Running train.py..."
+python train.py --bq_table $BQ_TABLE
+
+echo "Uploading trained model to GCS..."
+gcloud storage cp "./knn_model.pkl" "$WAREHOUSE/knn_model.pkl"

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] YAML A Batch ML Pipeline Example [beam]

Posted by "chamikaramj (via GitHub)" <gi...@apache.org>.
chamikaramj merged PR #35810:
URL: https://github.com/apache/beam/pull/35810


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org