An overview of the different ways Lumos helps make implementation steps easier
There are many different “quality of life” utilities in the SDK. Generally most utilities can be found in theconnector.utils namespace.
These include utilities like:
- String manipulation, for example
split_nameandfull_name - Response utilities like
create_client_response BearerAuthfor simple httpx authentication setup- JWT signing utility (
sign_jwt) - A full suite of utilities for authorizing with an OAuth1 API
- Pagination and its related classes
- The
sync_to_asyncdecorator for handling sync method calls - Other utilities
HTTP Servers
Each connector has the ability to run as a traditional HTTP API server. This is beneficial especially for local testing, since each implemented capability is surfaced as an API endpoint. To run a HTTP server from a connector, run the following:--reload flag, the server will reload during any changes to the connector.
This also surfaces the documentation and self-describing nature of Lumos SDK connectors. You can access the docs by navigating to [http://127.0.0.1:8000](http://127.0.0.1:8000/) /docs or [http://127.0.0.1:8000](http://127.0.0.1:8000/)/redoc. Allowing you to see each capability clearly documented, and download the OpenAPI Specification.
As mention above, each capability is surfaced as an API endpoint. An example of calling such a capability:
Rate Limiting
One of the common pitfalls of API integrations is rate limiting. Traditionally, each service implements a rate limiting policy with a certain amount of requests available during a time window. These instances can be problematic when performing a large amount of fetching. For such purposes the SDK provides aRateLimitedClient class.
This class is tightly integrated with the above mentioned BaseIntegrationClient and extends its functionality on a per-code-block basis.
app_id, requests_per_window, and window_seconds. The max_delay argument in example serves as an increase in delay between calls, making the client wait longer before retrying the rate limited requests.
You can now either apply this configuration to your whole AbcClient or to selective capability calls.
FIXED which is a configuration combining sane defaults and supplied arguments.
Testing
Proper test coverage helps with connector maintenance. The scaffolded connector comes with some of the tests already prepared for finishing. To run tests for a connector, use the following command:pytest-cases to run it’s tests.
Each connector has a predefined structure:
common_mock_data.py file is used to contain any mocks, dummy data or any other constants that you might need to be using during the testing.
And lastly the test_all_capabilities.py is responsible for running all of the test case files and testing your implementation.
This way the cases can be extended, and the test runner can be modified to fit specific needs of the end system.