Package: boum
Boum Python SDKStatus:OverviewThis project provides an api client to interact with theBoum APIand abstractions to
simplify interactions with the underlying resources.InstallationThe package is available on PyPI, and can be installed with pip or similar tools:python-mpipinstallboumpoetryaddboumpipenvinstallboum...UsageAPI ClientThe API client models the topology of the API and provides a class hierarchy that is organized in the same way as the
endpoint paths. Email and password or a token are required to use it.The client can either connect to the API withclient.connect()andclient.disconnect()methods or it can be used
as a context manager aswith client: ...In the former case the disconnect method should be called explicitly in the
end.>>>fromboum.api_client.v1.clientimportApiClient>>>fromboum.api_client.v1.modelsimportDeviceModel>>>>>>client=ApiClient(email,password,base_url=base_url)>>># or ApiClient(refresh_token='token', base_url=base_url)>>>>>>withclient:...# Get call to the devices collection...device_ids=client.root.devices.get()...# Get call to a specific device...device_states=client.root.devices(device_id).get()...# Patch call to a specific device...client.root.devices(device_id).patch(DeviceModel())...# Get call to a devices data...data=client.root.devices(device_id).data.get()Resource AbstractionsThe resource abstractions provide a more intuitive interface to interact with the underlying resources.>>>fromdatetimeimporttime,datetime,timedelta>>>importpandasaspd>>>fromboum.api_client.v1.clientimportApiClient>>>fromboum.resources.deviceimportDevice>>>fromboum.api_client.v1.modelsimportDeviceStateModel>>>>>>client=ApiClient(email,password,base_url=base_url)>>># or ApiClient(refresh_token='token', base_url=base_url)>>>>>>withclient:...# Get available device ids...device_ids=Device.get_device_ids(client)...# Create a device instance...device=Device(device_id,client)...# Remove device claim...# device.unclaim()...# Claim a device...# device.claim()...# Set desired device state...desired_device_State=DeviceStateModel(...pump_state=True,...refill_time=time(3,32),...refill_interval_days=3,...max_pump_duration_minutes=5...)...device.set_desired_device_state(desired_device_State)...# Get reported and desired device state...reported,desired=device.get_device_states()...# Get device telemetry data...data=device.get_telemetry_data(start=datetime.now()-timedelta(days=1),...end=datetime.now())...# Convert telemetry data to pandas dataframe...df=pd.DataFrame(data)Jupyter Notebook DemoA Jupyter notebook demo is availablehere.LogingThe SDK uses the standard python logging module.DevelopmentDependecy managementPoetryis used for depency management and publishing.VersioningVersioning is done usingbumpverwithsemantic versioningWhen the version is updated, a new tag is created and pushed to the remote repository.TestingUnit testsThese are completely self-contained and have no external dependencies.IMPORTANT: There are fixtures that model the API responses and expected calls. These mnust be kept up to date with
the API, otherwise the unit tests will not test the correct behavior.End-to-end testsThese test the entire flow from user facing python classes to the underlying api calls. They require an instance
(fake or real) of the API to run against. They also require a registered user with a clamied device.
API Base URL, email and password are required as environmental variables.BOUM_SDK_TEST_BASE_URLBOUM_SDK_TEST_EMAILBOUM_SDK_TEST_PASSWORDBOUM_SDK_TEST_DEVICE_IDBOUM_SDK_TEST_USER_IDDoctestsPart of the end-to-end tests are document tests executed usingdoctest.
These tests ensure that all the examples in this README and in the docstrings are up-to-date and working.CI/CDIntegrationThe GitHub action workflow.github/workflows/checks_on_push_to_branch.ymlis triggered on every push on a branch
except main. It provides the following checks:Unit and end-to-end/contract tests with pytestLinting with pylintSecurity checks with banditThe repository settings require that all checks pass before a pull request can be merged.DeploymentThe GitHub action workflow.github/workflows/deploy_on_push_to_main.ymlis triggered on every push to main. It runs a
test deployment to the test PyPI repository.The GitHub action workflow.github/workflows/deploy_on_release.ymlis triggered on a tag with the formatv*.*.*and
runs a deployment to the production PyPI. It is recommended to set these tags using the GitHub release feature.Technical debtDoctest requires a specific format to make examples in documentation executable. This makes the examples in this
README harder to copy and paste. There exist other packages and add-ons that could be used to make the examples easier
to manage.