You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2023/03/24 18:43:42 UTC

[beam] branch users/damccorm/sklearn_tests created (now d332d02d4ac)

This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a change to branch users/damccorm/sklearn_tests
in repository https://gitbox.apache.org/repos/asf/beam.git


      at d332d02d4ac Force version of sklearn in examples

This branch includes the following new commits:

     new d332d02d4ac Force version of sklearn in examples

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[beam] 01/01: Force version of sklearn in examples

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a commit to branch users/damccorm/sklearn_tests
in repository https://gitbox.apache.org/repos/asf/beam.git

commit d332d02d4ac76ed9fe54866c1285940f740fe011
Author: Danny McCormick <da...@google.com>
AuthorDate: Fri Mar 24 14:43:24 2023 -0400

    Force version of sklearn in examples
---
 .../inference/sklearn_examples_requirements.txt        | 18 ++++++++++++++++++
 .../inference/sklearn_japanese_housing_regression.py   |  4 ++++
 .../examples/inference/sklearn_mnist_classification.py |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/sdks/python/apache_beam/examples/inference/sklearn_examples_requirements.txt b/sdks/python/apache_beam/examples/inference/sklearn_examples_requirements.txt
new file mode 100644
index 00000000000..256e6be3b56
--- /dev/null
+++ b/sdks/python/apache_beam/examples/inference/sklearn_examples_requirements.txt
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+scikit-learn==1.0.2
\ No newline at end of file
diff --git a/sdks/python/apache_beam/examples/inference/sklearn_japanese_housing_regression.py b/sdks/python/apache_beam/examples/inference/sklearn_japanese_housing_regression.py
index 0d0adb0425a..e6a544c6a32 100644
--- a/sdks/python/apache_beam/examples/inference/sklearn_japanese_housing_regression.py
+++ b/sdks/python/apache_beam/examples/inference/sklearn_japanese_housing_regression.py
@@ -32,6 +32,7 @@ In order to set this example up, you will need two things.
 import argparse
 from typing import Iterable
 
+import os
 import pandas
 
 import apache_beam as beam
@@ -137,6 +138,9 @@ def run(
   known_args, pipeline_args = parse_known_args(argv)
   pipeline_options = PipelineOptions(pipeline_args)
   pipeline_options.view_as(SetupOptions).save_main_session = save_main_session
+  requirements_dir = os.path.dirname(os.path.realpath(__file__))
+  # Pin to the version that we trained the model on.
+  pipeline_options.view_as(SetupOptions).requirements_file = f'{requirements_dir}/sklearn_examples_requirements.txt'
 
   pipeline = test_pipeline
   if not test_pipeline:
diff --git a/sdks/python/apache_beam/examples/inference/sklearn_mnist_classification.py b/sdks/python/apache_beam/examples/inference/sklearn_mnist_classification.py
index e748166e6fd..fe46b280df7 100644
--- a/sdks/python/apache_beam/examples/inference/sklearn_mnist_classification.py
+++ b/sdks/python/apache_beam/examples/inference/sklearn_mnist_classification.py
@@ -90,6 +90,8 @@ def run(
   known_args, pipeline_args = parse_known_args(argv)
   pipeline_options = PipelineOptions(pipeline_args)
   pipeline_options.view_as(SetupOptions).save_main_session = save_main_session
+  # Pin to the version that we trained the model on.
+  pipeline_options.view_as(SetupOptions).requirements_file = f'{requirements_dir}/sklearn_examples_requirements.txt'
 
   # In this example we pass keyed inputs to RunInference transform.
   # Therefore, we use KeyedModelHandler wrapper over SklearnModelHandlerNumpy.