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-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org