Skip to content

Releases: localstack/verdin

v0.5.0

18 Dec 09:33

Choose a tag to compare

Summary

API Clients

This release introduces more low-level tinybird api clients that can be used to programmatically interact with APIs.

For example, to query a pipe, use the client.api.pipes object:

from verdin import tinybird

client = tinybird.Client(...)

response = client.api.pipes.query("my_pipe", parameters={"my_param": "..."}, query="SELECT * FROM _ LIMIT 10")

for record in response.data:
    # each record is a dictionary
    ...

Or ingest data through client.api.events:

from verdin import tinybird

client = tinybird.Client(...)

response = client.api.events.send("my_datasource", records=[
    {"id": "...", "value": "..."},
    ...
])
assert response.quarantined_rows == 0

The following APIs are (partially) supported:

  • /v0/datasources: client.api.datasources
  • /v0/events: client.api.events
  • /v0/pipes: client.api.pipes
  • /v0/tokens: client.api.tokens
  • /v0/variables: client.api.variables

tinybird-local test harness

For testing purposes, verdin now provides verdin.test, which features two main classes:

  • TinybirdLocalContainer - an abstraction to start/stop and interact with the tinybird local container
  • TinybirdCli - a wrapper around tb which allows you to programmatically run the most important CLI commands

Together with these tools, you can build your own pytest test harness that uses tinybird-local. For example, you can create a fixture that automatically starts and stops the tb local container:

@pytest.fixture(scope="session", autouse=True)
def tinybird_local_container():
    """
    Starts a tinybird local container in the background and waits until it becomes available.
    """
    container = TinybirdLocalContainer()
    container.start()
    container.wait_is_up()

    yield container
    
    container.stop()

What's Changed

  • modernize python project configuration by @thrau in #3
  • add integration test harness with tinybird-local by @thrau in #4
  • add type hints and more inline pydoc by @thrau in #5
  • add tinybird api clients by @thrau in #6

Full Changelog: https://github.com/localstack/verdin/commits/v0.5.0