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

Add support for uri inputs in audio models for transformers #8495

Merged
merged 8 commits into from
May 24, 2023

Conversation

BenWilson2
Copy link
Member

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Add support for uri inputs for audio models in transformers

How is this patch tested?

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

Manual validation of multiple audio formats from multiple public domain audio clip repositories

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.

Audio pipelines for transformers now support uri references as input to pyfunc flavor

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: Ben Wilson <benjamin.wilson@databricks.com>
@pytest.mark.skipif(
Version(transformers.__version__) < Version("4.29.0"), reason="Feature does not exist"
)
@pytest.mark.skipif(RUNNING_IN_GITHUB_ACTIONS, reason="url dependency")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is marked as a non-CI test due to the url dependency

docs/source/models.rst Outdated Show resolved Hide resolved
BenWilson2 and others added 2 commits May 22, 2023 21:22
Signed-off-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
@github-actions github-actions bot added area/models MLmodel format, model serialization/deserialization, flavors rn/feature Mention under Features in Changelogs. labels May 23, 2023
@mlflow-automation
Copy link
Collaborator

mlflow-automation commented May 23, 2023

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

More info

will be thrown at inference time.

.. warning:: If using a uri (`str`) as an input type for a `pyfunc` model, you *must* specify a custom model signature when logging or saving the model.
The default signature value of ``bytes`` will, in `MLflow Model serving`, force the conversion of the string to ``bytes``, which will cause an Exception
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Can we avoid automatically converting string input to bytes but raising error instead ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I'll see if I can make this work!

def test_whisper_model_with_url(whisper_pipeline):
artifact_path = "whisper_url"

url = "https://www.nasa.gov/mp3/590325main_ringtone_kennedy_WeChoose.mp3"
Copy link
Member

@harupy harupy May 23, 2023

Choose a reason for hiding this comment

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

Can we commit an audio file in this repo, use it, and remove skipif?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah good point. I'll convert to pulling the .wav file I added in the last audio PR :)

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
Signed-off-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
@BenWilson2
Copy link
Member Author

@mlflow-automation autoformat

Comment on lines +1641 to +1648
if "Malformed soundfile" in str(e):
raise MlflowException(
"Failed to process the input audio data. Either the audio file is "
"corrupted or a uri was passed in without overriding the default model "
"signature. If submitting a string uri, please ensure that the model has "
"been saved with a signature that defines a string input type.",
error_code=INVALID_PARAMETER_VALUE,
) from e
Copy link
Member

@harupy harupy May 24, 2023

Choose a reason for hiding this comment

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

Is this testable? If yes, can we add a test?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's currently tested in test_whisper_model_using_uri_with_default_signature_raises(). I'll add another test explicitly for the direct usage in pyfunc just to make it more obvious that we're validating this logic instead of allowing the highly cryptic and difficult to understand underlying exception from ffmpeg to throw if the user calls the pyfunc model with an invalid audio file.

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.

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
@BenWilson2 BenWilson2 enabled auto-merge (squash) May 24, 2023 15:50
@BenWilson2
Copy link
Member Author

@mlflow-automation autoformat

@BenWilson2 BenWilson2 merged commit a8e77b2 into mlflow:master May 24, 2023
36 checks passed
@BenWilson2 BenWilson2 deleted the support-blob-transformers branch May 25, 2023 00:11
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/feature Mention under Features in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants