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

Use testing mode to raise errors during automatic signature inference #8866

Merged
merged 9 commits into from
Jun 30, 2023

Conversation

jerrylian-db
Copy link
Collaborator

@jerrylian-db jerrylian-db commented Jun 27, 2023

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

The automatic signature inference feature swallows failures. However, this makes it difficult to for contributors to debug during testing. This PR uses the MLFLOW_TESTING environment variable to disable failure swallowing of this feature in MLflow tests.

How is this patch tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests (describe details, including test results, below)

I manually added an exception to the signature inference code and verified that the exception was raised in an MLflow test. I manually removed the monkeypatch in that test suite, and the exception was no longer raised (instead the test failed because there was no inferred signature, as expected).

Does this PR change the documentation?

  • No. You can skip the rest of this section.
  • Yes. Make sure the changed pages / sections render correctly in the documentation preview.

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.

(Details in 1-2 sentences. You can just refer to another PR with a description if this PR is part of a larger change.)

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/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/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • 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/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

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
@jerrylian-db jerrylian-db self-assigned this Jun 27, 2023
@mlflow-automation
Copy link
Collaborator

mlflow-automation commented Jun 27, 2023

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

More info

@github-actions github-actions bot added area/models MLmodel format, model serialization/deserialization, flavors rn/none List under Small Changes in Changelogs. labels Jun 27, 2023
@jerrylian-db jerrylian-db changed the title Create testing mode for signature automatic inference that raises errors when set to true Create testing mode for automatic signature inference that raises errors when set to true Jun 27, 2023
@jerrylian-db jerrylian-db requested a review from harupy June 27, 2023 23:26
@harupy
Copy link
Member

harupy commented Jun 28, 2023

@jerrylian-db Can we use MLFLOW_TESTING instead? See #8869

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
@jerrylian-db jerrylian-db changed the title Create testing mode for automatic signature inference that raises errors when set to true Use testing mode to raise errors during automatic signature inference Jun 28, 2023
@jerrylian-db
Copy link
Collaborator Author

@harupy great idea! Done :)

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
Comment on lines 49 to 55
@pytest.fixture(autouse=True)
def set_envs(monkeypatch):
monkeypatch.setenvs(
{
"MLFLOW_TESTING": "true",
}
)
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this because the top-level conftest.py already has it:

mlflow/conftest.py

Lines 144 to 148 in 152063e

@pytest.fixture(scope="session", autouse=True)
def enable_mlflow_testing():
with pytest.MonkeyPatch.context() as mp:
mp.setenv(_MLFLOW_TESTING.name, "TRUE")
yield

Copy link
Collaborator Author

@jerrylian-db jerrylian-db Jun 29, 2023

Choose a reason for hiding this comment

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

Huh, so we can remove this from all individual test suites? If I remove it from the test suites, will running those test suites on their own have this environment variable set?

Copy link
Member

@harupy harupy Jun 29, 2023

Choose a reason for hiding this comment

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

Yes :) You can test it to confirm.

mlflow/spark.py Outdated Show resolved Hide resolved
Copy link
Member

@harupy harupy left a comment

Choose a reason for hiding this comment

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

LGTM once #8866 (comment) is addressed!

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
@jerrylian-db jerrylian-db enabled auto-merge (squash) June 29, 2023 05:58
@jerrylian-db jerrylian-db enabled auto-merge (squash) June 29, 2023 17:33
Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
Co-authored-by: Harutaka Kawamura <hkawamura0130@gmail.com>
Signed-off-by: Jerry Liang <66143562+jerrylian-db@users.noreply.github.com>
@jerrylian-db jerrylian-db merged commit 5f6542a into master Jun 30, 2023
BenWilson2 pushed a commit to BenWilson2/mlflow that referenced this pull request Jul 5, 2023
…mlflow#8866)

* implement it

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* change environment variable

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* fix test

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* adapt feedback

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

---------

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
BenWilson2 pushed a commit to BenWilson2/mlflow that referenced this pull request Jul 7, 2023
…mlflow#8866)

* implement it

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* change environment variable

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* fix test

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

* adapt feedback

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>

---------

Signed-off-by: Jerry Liang <jerry.liang@databricks.com>
@jerrylian-db jerrylian-db deleted the signature_testing_mode branch July 11, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/models MLmodel format, model serialization/deserialization, flavors rn/none List under Small Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants