Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper Python worker reuse for test_model_cache. #3863

Merged
merged 5 commits into from Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions tests/pyfunc/test_spark.py
Expand Up @@ -263,10 +263,8 @@ def get_model(_):
# Note that we can't necessarily expect an even split, or even that there were only
# exactly 2 python processes launched, due to Spark and its mysterious ways, but we do
# expect significant reuse.
results = spark.sparkContext.parallelize(range(0, 100), 30).map(get_model).collect()

# TODO(tomas): Looks like spark does not reuse python workers with python==3.x
assert sys.version[0] == "3" or max(results) > 10
results = spark.sparkContext.parallelize(range(100), 30).map(get_model).collect()
assert max(results) > 10
# Running again should see no newly-loaded models.
results2 = spark.sparkContext.parallelize(range(0, 100), 30).map(get_model).collect()
assert sys.version[0] == "3" or min(results2) > 0
results2 = spark.sparkContext.parallelize(range(100), 30).map(get_model).collect()
assert min(results2) > 0