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

Write eval results to delta #10659

Merged
merged 17 commits into from Dec 14, 2023
Merged

Conversation

prithvikannan
Copy link
Collaborator

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/deployments: MLflow Deployments client APIs, server, and third-party Deployments integrations
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

@prithvikannan prithvikannan added rn/feature Mention under Features in Changelogs. area/tracking Tracking service, tracking client APIs, autologging labels Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

Documentation preview for 57d7d2a will be available here when this CircleCI job completes successfully.

More info

@prithvikannan prithvikannan changed the title [WIP] Write eval results to delta Write eval results to delta Dec 11, 2023
@prithvikannan prithvikannan added rn/none List under Small Changes in Changelogs. and removed rn/feature Mention under Features in Changelogs. labels Dec 11, 2023
@prithvikannan prithvikannan marked this pull request as ready for review December 12, 2023 00:00
Comment on lines 1655 to 1657
eval_table_spark.write.mode("overwrite").format("delta").saveAsTable(
self.eval_results_path
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be an append operation and we should enable schema merge (by setting the spark.databricks.delta.schema.autoMerge.enabled) conf as well.

cc @alkispoly-db

Copy link
Contributor

Choose a reason for hiding this comment

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

We should definitely automerge the schema.

For append vs overwrite:

  • Append is the right thing to do if we add a new experiment to the same eval dataset.
  • Overwrite is the right thing to do if the eval dataset has changed since last processed.
    Can we differentiate between the two cases when the call is made?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense! I think we should add an evaluator conf this. Our RAG solution can decide how to populate it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. Introduced a new evaluator conf eval_results_mode to control that.

Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
This reverts commit c16ed30.

Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
tests/evaluate/test_default_evaluator_delta.py Outdated Show resolved Hide resolved
mlflow/models/evaluation/default_evaluator.py Outdated Show resolved Hide resolved
shutil.rmtree(tmpdir)


def test_write_to_delta_fails_with_invalid_mode(spark_session_with_tempdir):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems spark_session_with_tempdir is not used in this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its still passed into this test. the spark session fixture is not tied to the module, so that we can test test_write_to_delta_fails_without_spark above, and then in in this test spark available but an invalid mode.

Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Signed-off-by: Prithvi Kannan <prithvi.kannan@databricks.com>
Comment on lines +241 to +244
pytest tests/evaluate --ignore=tests/evaluate/test_default_evaluator_delta.py
- name: Run tests with delta
run: |
pytest tests/evaluate/test_default_evaluator_delta.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

making this change since the spark sessions from tests/evaluate/test_evaluation and tests/evaluate/test_default_evaluator are not fully isolated (ie. calling getOrCreate() in another file will pickup the spark session from these files).

for tests/evaluate/test_default_evaluator_delta.py we need to test the case with no spark session available, and test with a spark session that has the delta extension.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How are we testing this with both spark sessions and without it? We are ignoring it in the previous run?

Let me know if I am missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sunishsheth2009 , test_default_evaluator_delta has a different fixture to create a spark session with delta. we have a test with and without the fixture.

"mergeSchema", "true"
).format("delta").saveAsTable(self.eval_results_path)
except Exception as e:
_logger.info(f"Saving eval table to delta table failed. Reason: {e}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we change this to logger.warn instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i dont feel strongly either way, but figured that this might help with debugging during development.

@prithvikannan prithvikannan merged commit ccb0570 into mlflow:master Dec 14, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tracking Tracking service, tracking client APIs, autologging rn/none List under Small Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants