Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

feat: migrate /api/_status endpoint to /api/v1/status #165

Conversation

jfcalvo
Copy link
Member

@jfcalvo jfcalvo commented May 10, 2024

Description

This PR add changes to migrate /api/_status endpoint to /api/v1/status endpoint.

The changes added in this PR compared to the endpoint from API v0:

  • Instead of mem_info attribute name we are using now memory.
  • I'm not using the info service code because it has a lot of accidental complexity. Instead I have created a new info context with three functions that returns the Argilla version, ElasticSearch and Memory status. (Once we delete old endpoints we can remove the service code).

Closes #164

Type of change

(Please delete options that are not relevant. Remember to title the PR according to the 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)
  • Refactor (change restructuring the codebase without changing functionality)
  • Improvement (change adding some improvement to an existing functionality)
  • Documentation update

How Has This Been Tested

(Please describe the tests that you ran to verify your changes. And ideally, reference tests)

  • Adding tests for the new endpoint.

Checklist

  • I added relevant documentation
  • follows the style guidelines of this project
  • I did a self-review of my code
  • I made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I filled out the contributor form (see text above)
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

@jfcalvo jfcalvo requested a review from frascuchon May 10, 2024 09:57
@jfcalvo jfcalvo linked an issue May 10, 2024 that may be closed by this pull request
async def get_status():
return Status(
version=info.argilla_version(),
elasticsearch=info.elasticsearch_status(),
Copy link
Member

Choose a reason for hiding this comment

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

We could change this to search_engine since in the code we have a lot of references to the search engine (which internally is an elasticsearch/openseach instance

Copy link
Member

Choose a reason for hiding this comment

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

Also, I think using the SearchEngine for this would be better.

Suggested change
elasticsearch=info.elasticsearch_status(),
elasticsearch=info.engine_status(search_engine),

And internally:

def engine_status(search_engine):
   return search_engine.client.get_cluster_info() # In the future we can wrap this as a public interface method (.status) or something. 

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok to both suggestions. I will change them.

Comment on lines 27 to 28
def elasticsearch_status() -> dict:
return GenericElasticEngineBackend.get_instance().client.get_cluster_info()
Copy link
Member

Choose a reason for hiding this comment

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

Just to not reuse old code:

Suggested change
def elasticsearch_status() -> dict:
return GenericElasticEngineBackend.get_instance().client.get_cluster_info()
def elasticsearch_status(search_engine: SearchEngine) -> dict:
return search_engine.client.get_cluster_info()

Base automatically changed from feat/migrate-info-v0-endpoint-to-version-v1 to feat/move-api-v0-functionality-to-v1 May 13, 2024 11:39
@jfcalvo jfcalvo merged commit 630ca2c into feat/move-api-v0-functionality-to-v1 May 13, 2024
12 checks passed
@jfcalvo jfcalvo deleted the feat/migrate-status-v0-endpoint-to-v1 branch May 13, 2024 12:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TASK] Migrate GET /api/_status endpoint to GET /api/v1/status
2 participants