zhengruifeng commented on code in PR #50324:
URL: https://github.com/apache/spark/pull/50324#discussion_r2007076480
##########
python/pyspark/ml/tuning.py:
##########
@@ -847,9 +850,23 @@ def _fit(self, dataset: DataFrame) ->
"CrossValidatorModel":
subModels = [[None for j in range(numModels)] for i in
range(nFolds)]
datasets = self._kFold(dataset)
+
+ tmp_dfs_path = _get_temp_dfs_path()
+ spark_session = SparkSession.getActiveSession()
for i in range(nFolds):
- validation = datasets[i][1].cache()
- train = datasets[i][0].cache()
+ validation = datasets[i][1]
+ train = datasets[i][0]
+
+ if tmp_dfs_path:
Review Comment:
let's define a helper function:
```
def _cache(df):
if ...:
df.cache()
else:
spark = df._session
df.save
spark.read...
```
##########
python/pyspark/ml/tuning.py:
##########
@@ -847,9 +850,23 @@ def _fit(self, dataset: DataFrame) ->
"CrossValidatorModel":
subModels = [[None for j in range(numModels)] for i in
range(nFolds)]
datasets = self._kFold(dataset)
+
+ tmp_dfs_path = _get_temp_dfs_path()
+ spark_session = SparkSession.getActiveSession()
Review Comment:
in other issues, we found `SparkSession` operation maybe pretty slow
```suggestion
spark_session = dataset._session
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]