-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Move utility functions used in sklearn autologging to reuse them in pyspark autologging #4252
Conversation
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
def _get_training_session(): | ||
""" | ||
Returns a session manager for nested autologging runs. | ||
""" | ||
# NOTE: The current implementation doesn't guarantee thread-safety, but that's okay for now | ||
# because: | ||
# 1. We don't currently have any use cases for allow_children=True. | ||
# 2. The list append & pop operations are thread-safe, so we will always clear the session stack | ||
# once all _SklearnTrainingSessions exit. | ||
class _TrainingSession(object): |
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.
Created this function to avoid using the same session manager across different flavors.
_SklearnSession = _get_training_session()
_PysparkSession = _get_training_session()
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@@ -15,3 +21,64 @@ def test_get_unique_resource_id_with_invalid_max_length_throws_exception(): | |||
|
|||
with pytest.raises(ValueError): | |||
get_unique_resource_id(max_length=0) | |||
|
|||
|
|||
def test_truncate_dict(): |
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.
Added a few tests for _chunk_dict
, _truncate_dict
, _get_fully_qualified_class_name
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@@ -16,7 +16,6 @@ sklearn: | |||
maximum: "0.24.1" | |||
requirements: ["matplotlib"] | |||
run: | | |||
pytest tests/sklearn/test_sklearn_training_session.py --large |
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.
tests/sklearn/test_sklearn_training_session.py
has been renamed to tests/autologging/test_training_session.py
which is executed in dev/run-python-flavor-tests.sh
.
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
…yspark autologging (mlflow#4252) * Reorganize utility functions used in sklearn Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * nit Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * add _get_fully_qualified_class_name Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Add tests Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * lint Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * move file Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * refactor Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * remove duplicated file Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * generate _TrainingSession in each test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Fix test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * run test_training_session in large test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * fix test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * docstrings Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Address comments Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * use util functions Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * fix Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> Signed-off-by: Yiqing Wang <yiqing@wangemail.com>
…yspark autologging (mlflow#4252) * Reorganize utility functions used in sklearn Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * nit Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * add _get_fully_qualified_class_name Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Add tests Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * lint Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * move file Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * refactor Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * remove duplicated file Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * generate _TrainingSession in each test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Fix test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * run test_training_session in large test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * fix test Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * docstrings Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Address comments Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * use util functions Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * fix Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy 17039389+harupy@users.noreply.github.com
What changes are proposed in this pull request?
Move the utility functions used in sklearn autologging to reuse them in pyspark autologging.
How is this patch tested?
Existing unit tests
Release Notes
Is this a user-facing change?
(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 loggingarea/build
: Build and test infrastructure for MLflowarea/docs
: MLflow documentation pagesarea/examples
: Example codearea/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models
: MLmodel format, model serialization/deserialization, flavorsarea/projects
: MLproject format, project running backendsarea/scoring
: Local serving, model deployment tools, spark UDFsarea/server-infra
: MLflow server, JavaScript dev serverarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, JavaScript, plottingarea/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/breaking-change
- The PR will be mentioned in the "Breaking Changes" sectionrn/none
- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" 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