Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddhantSadangi committed Jan 15, 2024
1 parent b1b029e commit be80c06
Showing 1 changed file with 30 additions and 0 deletions.
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

run = init_run()

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

0 comments on commit be80c06

Please sign in to comment.