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
initpy and test_transformers_model_export #10538
initpy and test_transformers_model_export #10538
Conversation
Documentation preview for 3973ffb will be available here when this CircleCI job completes successfully. More info
|
Signed-off-by: swathi <konakanchi.swathi@gmail.com>
b9b4b2f
to
cfebd44
Compare
@BenWilson2 @serena-ruan Please review |
assert len(predictions) != 0 | ||
|
||
|
||
@pytest.mark.skipif(RUNNING_IN_GITHUB_ACTIONS, reason=GITHUB_ACTIONS_SKIP_REASON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line was added by mistake. Can you remove this please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenWilson2 Please review
Looking good! Once that typo is fixed, we can merge! :D |
removed line @pytest.mark.skipif(RUNNING_IN_GITHUB_ACTIONS, reason=GITHUB_ACTIONS_SKIP_REASON)
…/KonakanchiSwathi/mlflow into AddImageclassification_newbranch
…/KonakanchiSwathi/mlflow into AddImageclassification_newbranch
…/KonakanchiSwathi/mlflow into AddImageclassification_newbranch
removed line @pytest.mark.skipif(RUNNING_IN_GITHUB_ACTIONS, reason=GITHUB_ACTIONS_SKIP_REASON)
…/KonakanchiSwathi/mlflow into AddImageclassification_newbranch
mlflow/transformers/__init__.py
Outdated
@@ -2669,7 +2733,7 @@ def decode_audio(encoded): | |||
@staticmethod | |||
def _validate_str_input_uri_or_file(input_str): | |||
""" | |||
Validation of blob references to audio files, if a string is input to the ``predict`` | |||
Validation of blob references to audio/image files, if a string is input to the ``predict`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation of blob references to audio/image files, if a string is input to the ``predict`` | |
Validation of blob references to either audio or image files, if a string is input to the ``predict`` |
Let's not use shorthand in docstrings
with model_path.joinpath("requirements.txt").open() as file: | ||
requirements = file.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with model_path.joinpath("requirements.txt").open() as file: | |
requirements = file.read() | |
requirements = model_path.joinpath("requirements.txt").read_text() |
with model_path.joinpath("model_card.md").open(encoding="utf-8") as file: | ||
card_text = file.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with model_path.joinpath("model_card.md").open(encoding="utf-8") as file: | |
card_text = file.read() | |
card_text = model_path.joinpath("model_card.md").read_text(encoding="utf-8") |
@@ -1341,6 +1363,46 @@ def test_qa_pipeline_pyfunc_load_and_infer(small_qa_pipeline, model_path, infere | |||
assert all(isinstance(element, str) for element in inference) | |||
|
|||
|
|||
def read_image(filename): | |||
image_path = os.path.join(pathlib.Path(__file__).parent.parent, "datasets", filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we mixing pathlib.Path and os.path.join() ? Just use pathlib to traverse the paths and read the bytes of the file directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
"inference_payload", | ||
[ | ||
image_url, | ||
os.path.join(pathlib.Path(__file__).parent.parent, "datasets", "cat.png"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does an absolute path reference from the repo root not work here? Why is this evaluation path parsing logic in the parameter?
"inference_payload", | ||
[ | ||
[os.path.join(pathlib.Path(__file__).parent.parent, "datasets", "cat.png")], | ||
[image_url, image_url], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why two instances here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanted to try the list with more than one, but changed it one instance
], | ||
) | ||
def test_vision_pipeline_pyfunc_predict(small_vision_model, inference_payload): | ||
if inference_payload == "base64": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not embed complex logic like this that mutates the parameter based on string matching. Just create another test explicitly for this condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, moved this logic inside because if we do this as an input parameter a lengthy base64 string is being printed in the test suite. now we have to duplicate three tests if we want to create a new test for base64.
transformers_loaded_model = mlflow.transformers.load_model(model_uri) | ||
expected_predictions = transformers_loaded_model.predict(inference_payload) | ||
|
||
assert list(predictions.to_dict("records")[0].values()) == expected_predictions[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we only validating the first entry here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks
…/KonakanchiSwathi/mlflow into AddImageclassification_newbranch
Hi @serena-ruan , @BenWilson2 Thanks for reviewing the PR and giving us valuable feedback. IT's been quite some time since this effort has started. can we sort of connect and close this one out?? |
mlflow.transformers.log_model( | ||
transformers_model=small_vision_model, | ||
artifact_path=artifact_path, | ||
signature=infer_signature( | ||
image_url, | ||
mlflow.transformers.generate_signature_output(small_vision_model, image_url), | ||
params=parameters, | ||
), | ||
) | ||
model_uri = mlflow.get_artifact_uri(artifact_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here, let's use model_info.model_uri
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few nits. LGTM otherwise. Let's wait for Ben to take another look.
Signed-off-by: swathi <konakanchi.swathi@gmail.com> Co-authored-by: Serena Ruan <82044803+serena-ruan@users.noreply.github.com> Signed-off-by: Konakanchi Swathi <98085410+KonakanchiSwathi@users.noreply.github.com>
Signed-off-by: Konakanchi Swathi <98085410+KonakanchiSwathi@users.noreply.github.com>
…i.swathi@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the test fix (string concatenation typo with a trailing comma) is applied
Signed-off-by: swathi <konakanchi.swathi@gmail.com> Co-authored-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com> Signed-off-by: Konakanchi Swathi <98085410+KonakanchiSwathi@users.noreply.github.com>
Hi @BenWilson2/ @serena-ruan, is there a tentative date for next mlflow pypi release?? |
🛠 DevTools 🛠
Install mlflow from this PR
Checkout with GitHub CLI
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/artifacts
: Artifact stores and artifact loggingarea/build
: Build and test infrastructure for MLflowarea/docs
: MLflow documentation pagesarea/examples
: Example codearea/gateway
: AI Gateway service, Gateway client APIs, third-party Gateway integrationsarea/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models
: MLmodel format, model serialization/deserialization, flavorsarea/recipes
: Recipes, Recipe APIs, Recipe configs, Recipe Templatesarea/projects
: MLproject format, project running backendsarea/scoring
: MLflow Model server, model deployment tools, Spark UDFsarea/server-infra
: MLflow Tracking server backendarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/docker
: Docker use across MLflow's components, such as MLflow Projects and MLflow Modelsarea/sqlalchemy
: Use of SQLAlchemy in the Tracking Service or Model Registryarea/windows
: Windows supportLanguage
language/r
: R APIs and clientslanguage/java
: Java APIs and clientslanguage/new
: Proposals for new client languagesIntegrations
integrations/azure
: Azure and Azure ML integrationsintegrations/sagemaker
: SageMaker integrationsintegrations/databricks
: Databricks integrationsHow 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" sectionrn/breaking-change
- The PR will be mentioned in the "Breaking Changes" sectionrn/feature
- A new user-facing feature worth mentioning in the release notesrn/bug-fix
- A user-facing bug fix worth mentioning in the release notesrn/documentation
- A user-facing documentation change worth mentioning in the release notes