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

feat: [sc-26070] Disable adding ".eth" suffix to suggestions #327

Merged
merged 10 commits into from
Jan 26, 2025

Conversation

Byczong
Copy link
Contributor

@Byczong Byczong commented Jan 20, 2025

Story details: https://app.shortcut.com/ps-web3/story/26070

TODO:

  • Disable adding .eth for Collections API
  • Disable adding .eth for Suggestions/Generator API
  • Refactor models
  • Implement separate response formatting functions for Collections API
  • Remove namehash field from CollectionLabel

@Byczong Byczong marked this pull request as ready for review January 21, 2025 16:25
Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@Byczong @djstrong Hey thanks for these updates! Reviewed and shared feedback 👍



class CollectionName(BaseModel):
name: str = Field(title='name with `.eth`')
name: str = Field(title='name from a collection')
namehash: str = Field(title='namehash of the name')
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm trying to remember why we had this namehash field here?

Please note how if we are removing .eth from all name values, the related namehash value returned would also need to change.

Potentially we might change this to labelhash but not sure about the goal of this field? I think we can just remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know why we are returning namehashes.

Copy link
Contributor Author

@Byczong Byczong Jan 24, 2025

Choose a reason for hiding this comment

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

If we want to remove the namehash field, should we keep this model with a single field, or should we rather keep the names as a list of str inside Collection.top_names?

Also, if the second option is chosen, should we change Collection.top_names to Collection.top_labels?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe the first option. It will not need any changes in the client and in the future will be easy to include additional information about names/labels.

We can rename name to label in all places but we need to do it in namekit too.

models.py Outdated Show resolved Hide resolved
models.py Outdated Show resolved Hide resolved
collection_models.py Outdated Show resolved Hide resolved
collection_models.py Outdated Show resolved Hide resolved
collection_models.py Outdated Show resolved Hide resolved

class CollectionWithSuggestions(BaseModel):
suggestions: list[SuggestionFromCollection] = Field(title='suggestions from a collection')
name: str = Field(title='collection title', description='kept for backwards compatibility') # todo: remove field if not used
Copy link
Member

Choose a reason for hiding this comment

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

Please coordinate with @FrancoAguzzi If we need to update any code for this in the old NameHash app Instant Search feature (now at https://alpha.namekit.io). We're going to need to make some changes there no matter what based on the changes in this PR. It should be ok for us to implement those updates.

suggestions: list[SuggestionFromCollection] = Field(title='suggestions from a collection')
name: str = Field(title='collection title', description='kept for backwards compatibility') # todo: remove field if not used
type: Literal['related'] = Field('related', title='category type (always set to \'related\')',
description='kept for backwards compatibility') # todo: remove field if not used
Copy link
Member

Choose a reason for hiding this comment

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

Please see related comment above for us to remove this field.

collection_models.py Outdated Show resolved Hide resolved
web_api.py Outdated
)


def convert_to_suggestion_format(
names: List[GeneratedName],
include_metadata: bool = True
include_metadata: bool = True,
append_eth: bool = True
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if I understand this append_eth param? In my understanding it shouldn't exist inside NameGraph.

Instead the appending of root names would be left to a NameGraph client to implement.

If I'm missing something please let me know 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have removed .eth. only in collection related endpoints and this code is also used for generator endpoints where we are appending eth.

Copy link
Member

Choose a reason for hiding this comment

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

@djstrong Ok perfect! That sounds great 🚀

@Byczong Byczong changed the title feat: [sc-26070] Disable adding ".eth" suffix for Collections API feat: [sc-26070] Disable adding ".eth" suffix to suggestions Jan 23, 2025
models.py Outdated
description='label\'s status cached at the time of application startup')
categories: list[str] = Field(title='domain category',
description='can be either available, taken, recently released or on sale')
cached_interesting_score: Optional[float] = Field(title='cached interesting score',
Copy link
Contributor Author

@Byczong Byczong Jan 24, 2025

Choose a reason for hiding this comment

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

Should we rename this field to cached_sort_score?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

@@ -65,8 +65,8 @@ class BaseCollectionSearch(BaseCollectionSearchLimitOffsetSort):
description='* set to null if you want to disable the penalization\n'
'* if the penalization algorithm is turned on then 3 times more results (than max_related_collections) are retrieved from Elasticsearch')
name_diversity_ratio: Optional[float] = Field(None, examples=[0.5], ge=0.0, le=1.0,
Copy link
Contributor Author

@Byczong Byczong Jan 24, 2025

Choose a reason for hiding this comment

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

Should we rename this field to label_diversity_ratio?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

@djstrong djstrong force-pushed the byczong/sc-26070/support-other-root-names branch from 08bc309 to dc258b3 Compare January 24, 2025 20:37
Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@Byczong @djstrong Looks good! I found a few more places where it looks like we might rename from "name" to "label" or "member", but I think it's fine to action those in a separate future PR. Thanks for your efforts here. Approved 🚀

}
}

input_names = ['cat', 'zeus']
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
input_names = ['cat', 'zeus']
input_labels = ['cat', 'zeus']


input_names = ['cat', 'zeus']

CAT = set(
Copy link
Member

Choose a reason for hiding this comment

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

Should each of these be labels without ".eth"?

"categories": {
"related": {
"enable_learning_to_rank": True,
"max_names_per_related_collection": 10,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"max_names_per_related_collection": 10,
"max_labels_per_related_collection": 10,

r = self.client.post(self.URL, name='suggestions_by_category', json=json)
# print(r.json())
response = r.json()
names = []
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
names = []
labels = []

@djstrong djstrong merged commit a9bd549 into master Jan 26, 2025
1 check passed
@djstrong
Copy link
Collaborator

Ok, I will return to this tomorrow.

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.

3 participants