Skip to content

Redesign update API to task API #372

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

Merged
merged 15 commits into from
Dec 29, 2021
Merged

Conversation

alallema
Copy link
Contributor

@alallema alallema commented Dec 15, 2021

Breaking Changes

All the actions on indexes are now asynchronous:

  • create_index(), update_index(), delete_index() return a task response instead of an Index.
  • index.create and index.delete from index return a task.
  • wait_for_pending_update()
    • is renamed into wait_for_task
    • the current index.wait_for_task() method call /tasks/:uid
  • index.get_update_status is renamed index.get_task
  • index.get_all_update_status is renamed index.get_tasks

Notes: The only two methods that now return an Index are client.index() and client.get_index()

Enhancements

  • new method client.wait_for_task() call /tasks/:uid
  • new method client.get_tasks that calls /tasks
  • new method client.get_task that calls /tasks/:uid

Misc

  • delete_if_exists and get_or_create_index are commented since we don't know yet if we will remove them or not.

@alallema alallema added breaking-change The related changes are breaking for the users enhancement New feature or request labels Dec 15, 2021
@alallema alallema force-pushed the redesign-task branch 9 times, most recently from fe1d47b to faf9e90 Compare December 16, 2021 12:13
Copy link
Collaborator

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

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

In addition to the review comments, a couple of additional comments.

In conftest.py the clear_indexes fixture can have race conditions now that the delete of indexes is async. To prevent this the deleting should wait for the task to complete.

@fixture(autouse=True)
def clear_indexes(client):
    """
    Auto-clears the indexes after each test function run.
    Makes all the test functions independent.
    """
    # Yields back to the test function.
    yield
    # Deletes all the indexes in the MeiliSearch instance.
    indexes = client.get_indexes()
    for index in indexes:
        result = client.index(index.uid).delete()
        client.wait_for_task(result["uid"])

Just as a suggestion, the new task functionality, wait_for_task, get_task, and get_tasks, could be their own functions outside of the Client and Index. This would prevent the need to have and maintain the same code in two different places.

@alallema alallema force-pushed the redesign-task branch 5 times, most recently from c67afa0 to 0faa2e1 Compare December 21, 2021 15:00
@sanders41
Copy link
Collaborator

LGTM! Good job on this one, there were a lot of changes here.

BTW, if it is helpful I have already implemented the new auth key management here. Implementation itself was simple, it was more the tests and fixtures (all relevant fixtures are in the test file) around it that took some thinking.

@alallema
Copy link
Contributor Author

LGTM! Good job on this one, there were a lot of changes here.

BTW, if it is helpful I have already implemented the new auth key management here. Implementation itself was simple, it was more the tests and fixtures (all relevant fixtures are in the test file) around it that took some thinking.

Thank you so much for this review @sanders41! 🔥
I still need to modify the wait_for_task, get_task, and get_tasks I will probably do it tomorrow.

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 🔥🔥🔥

@alallema alallema marked this pull request as ready for review December 23, 2021 16:09
@alallema
Copy link
Contributor Author

bors merge

bors bot added a commit that referenced this pull request Dec 29, 2021
372: Redesign update API to task API r=alallema a=alallema

### Breaking Changes
All the actions on indexes are now asynchronous:
- `create_index()`, `update_index()`, `delete_index()` return a `task` response instead of an `Index`.
- `index.create` and `index.delete` from index return a `task`.
- `wait_for_pending_update()`
    - is renamed into `wait_for_task`
    - the current `index.wait_for_task()` method call `/tasks/:uid`
- `index.get_update_status` is renamed `index.get_task`
- `index.get_all_update_status` is renamed `index.get_tasks`

**Notes:** The only two methods that now return an `Index` are `client.index()` and `client.get_index()`

### Enhancements
- new method `client.wait_for_task()` call `/tasks/:uid`
- new method `client.get_tasks` that calls `/tasks`
- new method `client.get_task` that calls `/tasks/:uid`

### Misc
- `delete_if_exists` and `get_or_create_index` are commented since we don't know yet if we will remove them or not.


Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[email protected]>
@bors
Copy link
Contributor

bors bot commented Dec 29, 2021

Build failed:

@alallema alallema merged commit 36969e8 into bump-meilisearch-v0.25.0 Dec 29, 2021
@alallema alallema deleted the redesign-task branch December 29, 2021 12:35
bors bot added a commit that referenced this pull request Dec 30, 2021
382: Addition related to API keys r=alallema a=alallema

### Breaking Changes

Granular management of API keys is now added to MeiliSearch. New methods have been created to manage this:
- `http.patch` use by `update_key`
- `client.get_key` get information about a specific API key.
- `client.create_key` create a new API key.
- `client.delete_key` delete an API key.
- `client.update_key` update an API key.

Note: Thanks to `@sanders41` whose code is largely inspired by [his implementation](https://github.com/sanders41/meilisearch-python-async/blob/e44941b7bf5735c8e99f0a2a12b707db03ac048a/meilisearch_python_async/client.py#L298) and [here](#372 (comment)).

Co-authored-by: alallema <[email protected]>
bors bot added a commit that referenced this pull request Jan 12, 2022
370: Changes related to the next MeiliSearch release (v0.25.0) r=alallema a=meili-bot

Related to this issue: meilisearch/integration-guides#157

This PR:
- gathers the changes related to the next MeiliSearch release (v0.25.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases).
- might eventually contain test failures until the MeiliSearch v0.25.0 is out.

⚠️ This PR should NOT be merged until the next release of MeiliSearch (v0.25.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._

Done:
- #371 
- #381 
- #372 
- #382 
- #396 

Co-authored-by: meili-bot <[email protected]>
Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[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 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants