Skip to content

Add search() to the Python client - #3121

Open
NopeCharon wants to merge 1 commit into
MarquezProject:mainfrom
NopeCharon:feature/python-client-search
Open

NopeCharon wants to merge 1 commit into
MarquezProject:mainfrom
NopeCharon:feature/python-client-search

Conversation

@NopeCharon

Copy link
Copy Markdown

Problem

The Python client can't call the search endpoint (GET /api/v1/search), which the Java client already supports through MarquezClient.search().

Closes: #3080

Solution

  • Add MarquezClient.search(query, filter=None, sort=None, limit=None, namespace=None, before=None, after=None), covering every query parameter the endpoint accepts.
  • Add SearchFilter (DATASET, JOB) and SearchSort (NAME, UPDATE_AT) enums to marquez_client.models, matching the server values. They are checked with Utils.is_instance_of, the same way create_dataset() checks DatasetType.
  • Optional parameters left unset aren't sent, so the server uses its own defaults. limit falls back to DEFAULT_LIMIT, like the other client methods and the Java client.
  • Add a usage example to the client README.
from marquez_client import MarquezClient
from marquez_client.models import SearchFilter, SearchSort

client = MarquezClient(url='http://localhost:5000')
client.search('orders', filter=SearchFilter.JOB, sort=SearchSort.UPDATE_AT, namespace='my-namespace')

One-line summary: Client: Add search() to the Python client

Checklist

  • You've signed-off your work
  • Your changes are accompanied by tests (if relevant)
  • Your change contains a small diff and is self-contained
  • You've updated any relevant documentation (if relevant)
  • You've included a one-line summary of your change for the CHANGELOG.md (Depending on the change, this may not be necessary).
  • You've versioned your .sql database schema migration according to Flyway's naming convention (if relevant)
  • You've included a header in any source code files (if relevant)

Testing

  • New unit tests in tests/test_marquez_client.py cover the default request, a request with every option set, and invalid query, filter, and sort arguments. pytest tests/ (40 passed) and flake8 marquez_client tests pass.
  • Ran search() against a local Marquez API built from main with two jobs and three datasets ingested. The default, filter + sort, limit + namespace, and before/after (both a string and a datetime.date) calls all returned the expected results.

The Python client had no way to call the `GET /api/v1/search` endpoint,
which the Java client already supports.

Add `MarquezClient.search()` taking the query plus the optional
`filter`, `sort`, `limit`, `namespace`, `before` and `after` parameters
accepted by the endpoint, along with `SearchFilter` and `SearchSort`
enums matching the server-side values. Unset optional parameters are
not sent, so the server applies its defaults; `limit` defaults to
`DEFAULT_LIMIT` like the other client methods.

Closes: MarquezProject#3080
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for /search endpoint in python client

1 participant