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

Supressing NeptuneUnsupportedType warning if expected metadata not found #21

Merged
merged 7 commits into from
Jan 17, 2024
30 changes: 30 additions & 0 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
except ImportError:
from neptune.new import init_run

import pytest
from sklearn import datasets
from sklearn.cluster import KMeans
from sklearn.linear_model import (
Expand Down Expand Up @@ -61,6 +62,35 @@ def test_kmeans_summary():
validate_run(run, log_charts=True)


@pytest.mark.filterwarnings("error::neptune.common.warnings.NeptuneUnsupportedType")
def test_unsupported_object():
"""This method checks if Neptune throws a `NeptuneUnsupportedType` warning if expected metadata
is not found or skips trying to log such metadata"""

from sklearn.model_selection import GridSearchCV
SiddhantSadangi marked this conversation as resolved.
Show resolved Hide resolved

run = init_run()
SiddhantSadangi marked this conversation as resolved.
Show resolved Hide resolved

X, y = datasets.load_diabetes(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)

model = LinearRegression()

param_grid = {
"copy_X": [True, False],
"fit_intercept": [True, False],
}

X, y = datasets.fetch_california_housing(return_X_y=True)[:10]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

grid_cv = GridSearchCV(model, param_grid, scoring="neg_mean_absolute_error", cv=2).fit(X_train, y_train)

run["regressor_summary"] = npt_utils.create_regressor_summary(grid_cv, X_train, X_test, y_train, y_test)

run.wait()


def validate_run(run, log_charts):
assert run.exists("summary/all_params")
assert run.exists("summary/pickled_model")
Expand Down
Loading