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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spark jobs #10340

Merged
merged 4 commits into from Nov 10, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions mlflow/utils/environment.py
Expand Up @@ -214,9 +214,13 @@ def _mlflow_conda_env(
:return: ``None`` if ``path`` is specified. Otherwise, the a dictionary representation of the
Conda environment.
"""
pip_deps = ([f"mlflow=={VERSION}"] if install_mlflow else []) + (
additional_pip_deps if additional_pip_deps else []
additional_pip_deps = additional_pip_deps or []
mlflow_deps = (
[f"mlflow=={VERSION}"]
if install_mlflow and not _contains_mlflow_requirement(additional_pip_deps)
else []
)
pip_deps = mlflow_deps + additional_pip_deps
conda_deps = additional_conda_deps if additional_conda_deps else []
if pip_deps:
pip_version = _get_pip_version()
Expand Down Expand Up @@ -554,7 +558,6 @@ def _process_conda_env(conda_env):
# User-specified `conda_env` may contain requirements/constraints file references
pip_reqs = _get_pip_deps(conda_env)
pip_reqs, constraints = _parse_pip_requirements(pip_reqs)

if not _contains_mlflow_requirement(pip_reqs):
pip_reqs.insert(0, _generate_mlflow_version_pinning())

Expand Down
6 changes: 4 additions & 2 deletions tests/spark/test_spark_model_export.py
Expand Up @@ -57,7 +57,7 @@
@pytest.fixture
def spark_custom_env(tmp_path):
conda_env = os.path.join(tmp_path, "conda_env.yml")
additional_pip_deps = ["pyspark", "pytest"]
additional_pip_deps = ["/opt/mlflow", "pyspark", "pytest"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smart fix :)

if Version(pyspark.__version__) <= Version("3.3.2"):
# Versions of PySpark <= 3.3.2 are incompatible with pandas >= 2
additional_pip_deps.append("pandas<2")
Expand Down Expand Up @@ -355,7 +355,9 @@ def test_model_deployment(spark_model_iris, model_path, spark_custom_env):
reason="The dev version of pyspark built from the source doesn't exist on PyPI or Anaconda",
)
def test_sagemaker_docker_model_scoring_with_default_conda_env(spark_model_iris, model_path):
mlflow.spark.save_model(spark_model_iris.model, path=model_path)
mlflow.spark.save_model(
spark_model_iris.model, path=model_path, extra_pip_requirements=["/opt/mlflow"]
)

scoring_response = score_model_in_sagemaker_docker_container(
model_uri=model_path,
Expand Down