Skip to content

Conversation

@curquiza
Copy link
Member

@curquiza curquiza commented Nov 13, 2020

Related to meilisearch/integration-guides#48

Here is the list of changes you have to check:

  • Change code-samples.
  • Change the Getting Started as described in the main issue.
  • get_index() does an HTTP call and is not the main method to use anymore.
  • Add the index() method
  • Add tests for index() method
  • Update get_or_create_index with the new way of using index()
  • Add a primary_key attribute in Index class. This attribute is updated when an HTTP call to the index is done (creation, update, or fetch the info). The attribute is obviously not up-to-date when using the index() method: the method does not do any HTTP call. Refer to the limitation section in the main issue.
  • Rename info() method into fetch_info() to make the HTTP call explicit. Now, the right usage to get the index information is client.get_index('movies') or client.index('movies').fetch_info().
  • Remove the internal method get_index from the Index class because not used anymore.

⚠️ the index.py changes might be not visible if you don't click on load diff:
Capture d’écran 2020-11-10 à 18 32 56

@curquiza curquiza added the breaking-change The related changes are breaking for the users label Nov 13, 2020
@curquiza curquiza mentioned this pull request Nov 13, 2020
Copy link
Contributor

@eskombro eskombro left a comment

Choose a reason for hiding this comment

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

This is a great work @curquiza , thank you so much!

I did a quite intense code review, sorry if there is a lot of pain in going through my review :)

I do like a lot the robust testing!

I don't actually agree with using objects in a test that are coming from (or modified by) another test, I think this is not consistent, and a test should be independet and always behave in the same way if it is called alone or in a test set. Not saying this is your fault, but maybe we can fix that or at least not introduce more entangled tests :)

Copy link
Contributor

@eskombro eskombro left a comment

Choose a reason for hiding this comment

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

suggestions :)

@curquiza
Copy link
Member Author

curquiza commented Nov 17, 2020

@eskombro

I don't actually agree with using objects in a test that are coming from (or modified by) another test, I think this is not consistent, and a test should be independet and always behave in the same way if it is called alone or in a test set. Not saying this is your fault, but maybe we can fix that or at least not introduce more entangled tests :)

There is already #170 😉

@curquiza
Copy link
Member Author

About the removal of assert isinstance(response, object):
This is not really the purpose of this PR since it could be removed from all the other tests in all the test files. I accept your changes but it should definitely be removed from the other tests that are not changed in this PR. If I have time I will do it today.

@eskombro
Copy link
Contributor

eskombro commented Nov 17, 2020

@eskombro

I don't actually agree with using objects in a test that are coming from (or modified by) another test, I think this is not consistent, and a test should be independet and always behave in the same way if it is called alone or in a test set. Not saying this is your fault, but maybe we can fix that or at least not introduce more entangled tests :)

There is already #170 😉

I am sorry, I didn't see #170. But I'm glad, it means we saw both that this is clearly an issue. Feel free to ignore my comments about independent tests as they all belong to that issue!

@eskombro
Copy link
Contributor

eskombro commented Nov 17, 2020

About the removal of assert isinstance(response, object):
This is not really the purpose of this PR since it could be removed from all the other tests in all the test files. I accept your changes but it should definitely be removed from the other tests that are not changed in this PR. If I have time I will do it today.

great, let me know if you don't and I'll do a quick PR :)

do you agree with those changes @bidoubiwa ?

What could be the purpose of this asserts: assert isinstance(response, object)

bidoubiwa
bidoubiwa previously approved these changes Nov 17, 2020
Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

LGTM

@curquiza
Copy link
Member Author

I did the changes about assert isinstance in #176 since it concerns all the Index methods tests and not only the methods related to this PR.

@curquiza curquiza force-pushed the implicit-index-creation-v2 branch from c37ee08 to ed86de1 Compare November 17, 2020 15:33
@curquiza curquiza requested a review from bidoubiwa November 17, 2020 15:35
Copy link
Contributor

@eskombro eskombro left a comment

Choose a reason for hiding this comment

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

Many thanks for this!

🌮 🌮 🌮

Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

Great !!

@curquiza
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build succeeded:

@bors bors bot merged commit 8f57cf0 into master Nov 17, 2020
@bors bors bot deleted the implicit-index-creation-v2 branch November 17, 2020 15:58
bors bot added a commit that referenced this pull request Nov 18, 2020
176: Restructure code r=curquiza a=curquiza

⚠️ Should be merged after the merge of #175

Breaking change:
- Make the internal method `Index.create(...)` a `@classmethod` instead of a `@staticmethod`. Why? Put the logic related to an index in the `Index` class instead of the `Client` class.
See the difference between static and class methods in Python: https://stackabuse.com/pythons-classmethod-and-staticmethod-explained/.
- Remove the internal method `Index.get_indexes()`. Since it's not related to only one index, this method should not be present in the `Index` class.
- Make the `update()` method returns an `Index` object instead of a `dict` because it's more convenient to manipulate object instead of dict. This is consitent with `client.index('movies').fetch_info()` and `client.create_index('movies)` and `client.index('movies')`

Changes:
- Check the type of the responses more accurately: `assert isinstance(response, Index)`

Co-authored-by: Clementine Urquizar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change The related changes are breaking for the users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants