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

if column.model not provided in visual app then set default model name #235

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Adiutant
Copy link

@Adiutant Adiutant commented Dec 21, 2024

Description

Set default model name in Column.Model column, when using VisualApp #118
Closes #118

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Optimization

How Has This Been Tested?

Before submitting a PR, please check yourself against the following list. It would save us quite a lot of time.

  • Have you read the contribution guide?
  • Have you updated the relevant docstrings? We're using Numpy format, please double-check yourself
  • Does your change require any new tests?
  • Have you updated the changelog file?

Copy link
Collaborator

@blondered blondered left a comment

Choose a reason for hiding this comment

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

Hi! Thank you so much for you contribution. I have suggested just a few tiny things to improve.

tests/visuals/test_visual_app.py Outdated Show resolved Hide resolved
is_u2i=True,
selected_requests=SELECTED_REQUESTS_U2I,
)
incorrect_reco = pd.DataFrame(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this to a separate test with test_happy_path_with_missing_model.
And please add assertion on expected_grouped_reco data.

Copy link
Author

@Adiutant Adiutant Dec 24, 2024

Choose a reason for hiding this comment

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

Hi, there is my suggestion, how to name this test - test_successful_path_with_missing_model. Added assertion on expected_grouped_reco

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Could you please name it happy? It's just our common naming everywhere in the tests. This way it'a a bit easier to navigate in the code.

I also added a few more comments. And we will be ready to merge.

rectools/visuals/visual_app.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@Adiutant Adiutant requested a review from blondered December 24, 2024 20:02
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (9b3992e) to head (3dc45d6).
Report is 86 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main      #235     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files           45        59     +14     
  Lines         2242      3877   +1635     
===========================================
+ Hits          2242      3877   +1635     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -71,7 +72,8 @@ def from_raw(
----------
reco : tp.Union[pd.DataFrame, TablesDict]
Recommendations from different models in a form of a pd.DataFrame or a dict.
In DataFrame form model names must be specified in `Columns.Model` column. In dict form
In DataFrame form model names must be specified in `Columns.Model` column.
If not, `Columns.Model` column will be created with default value ``model1``. In dict form
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
If not, `Columns.Model` column will be created with default value ``model1``. In dict form
If not, `Columns.Model` column will be created with default value ``model``. In dict form

@@ -21,7 +21,12 @@
import pytest

from rectools import Columns, ExternalId
from rectools.visuals.visual_app import AppDataStorage, ItemToItemVisualApp, StorageFiles, TablesDict, VisualApp
from rectools.visuals.visual_app import (AppDataStorage,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please run make format command in your terminal before pushing your changes. It will run isort and black to fix code style.
Also it is useful to run make lint command to check that all linters are passing locally. Right now they are failing because of unusual formatting.

)
}
}
assert expected_grouped_reco.keys() == ads.grouped_reco.keys()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great to see this added to the test!

Could you please move this block of code (lines 256-26) to a separate method of the class? You can call it assert_equal_data_in_grouped_reco_and_ads.
Right now we are copy-pasting this line 3 times in the file and it's too much.

is_u2i=True,
selected_requests=SELECTED_REQUESTS_U2I,
)
incorrect_reco = pd.DataFrame(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Could you please name it happy? It's just our common naming everywhere in the tests. This way it'a a bit easier to navigate in the code.

I also added a few more comments. And we will be ready to merge.

@@ -100,7 +102,7 @@ def from_raw(

if isinstance(reco, pd.DataFrame):
if Columns.Model not in reco.columns:
raise KeyError("Missing `{Columns.Model}` column in `reco` DataFrame")
reco[Columns.Model] = DEFAULT_MODEL_NAME
Copy link
Collaborator

@feldlime feldlime Jan 10, 2025

Choose a reason for hiding this comment

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

Hi, please add a warning here

warnings.warn("`{Columns.Model}` column in `reco` DataFrame is missing. All recommendations will be related to a single model")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing Columns.Model in reco processing to VisualApp
3 participants