Skip to content

Commit 172a090

Browse files
committed
Merge Construct Additional Obelisks
2 parents 544ea2b + eec6213 commit 172a090

File tree

58 files changed

+2909
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2909
-43
lines changed

.gitignore

Lines changed: 97 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,108 @@
1-
# Temporary and binary files
2-
*~
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
33
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
47
*.so
5-
*.cfg
6-
!.isort.cfg
7-
!setup.cfg
8-
*.orig
9-
*.log
10-
*.pot
11-
__pycache__/*
12-
.cache/*
13-
.*.swp
14-
*/.ipynb_checkpoints/*
15-
.DS_Store
16-
17-
# Project files
18-
.ropeproject
19-
.project
20-
.pydevproject
21-
.settings
22-
.idea
23-
tags
248

25-
# Package files
26-
*.egg
27-
*.eggs/
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
2825
.installed.cfg
29-
*.egg-info
26+
*.egg
27+
MANIFEST
3028

31-
# Unittest and coverage
32-
htmlcov/*
29+
# Installer logs
30+
pip-log.txt
31+
pip-delete-this-directory.txt
32+
33+
# Unit test / coverage reports
34+
htmlcov/
35+
.tox/
36+
.nox/
3337
.coverage
34-
.tox
35-
junit.xml
38+
.coverage.*
39+
.cache
40+
nosetests.xml
3641
coverage.xml
42+
*.cover
43+
*.py,cover
44+
.hypothesis/
3745
.pytest_cache/
46+
cover/
3847

39-
# Build and docs folder/files
40-
build/*
41-
dist/*
42-
sdist/*
43-
docs/api/*
44-
docs/_rst/*
45-
docs/_build/*
46-
cover/*
47-
MANIFEST
48+
# Sphinx documentation
49+
docs/_build/
50+
docs/build/
51+
52+
# PyBuilder
53+
.pybuilder/
54+
target/
55+
56+
# pdm
57+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
58+
#pdm.lock
59+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
60+
# in version control.
61+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
62+
.pdm.toml
63+
.pdm-python
64+
.pdm-build/
65+
66+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
67+
__pypackages__/
68+
69+
# Environments
70+
.env
71+
.venv
72+
env/
73+
venv/
74+
ENV/
75+
env.bak/
76+
venv.bak/
77+
78+
# Spyder project settings
79+
.spyderproject
80+
.spyproject
81+
82+
# Rope project settings
83+
.ropeproject
84+
85+
# mkdocs documentation
86+
/site
87+
88+
# mypy
89+
.mypy_cache/
90+
.dmypy.json
91+
dmypy.json
92+
93+
# Pyre type checker
94+
.pyre/
95+
96+
# pytype static type analyzer
97+
.pytype/
98+
99+
# Cython debug symbols
100+
cython_debug/
101+
102+
.idea/
48103

49-
# Per-project virtualenvs
50-
.venv*/
104+
# Ruff stuff:
105+
.ruff_cache/
51106

52-
# Configuration file
53-
example/out/
54-
example/config.py
107+
# PyPI configuration file
108+
.pypirc

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Construct Additional Obelisks
2+
3+
After years of copy-pasting and modifying Obelisk client implementations all over,
4+
we've had enough of hearing "construct additional obelisks".
5+
Thus, we have decided to build the one client to rule them all.
6+
7+
## Usage
8+
9+
Take your pick of asynchronous or sync,
10+
import the relevant Producer or Consumer and go crazy.
11+
There is explicitly minimal documentation on actual filter values,
12+
read the [Obelisk docs](https://obelisk.docs.apiary.io/) for that.
13+
14+
Please never copy the repo into your own project,
15+
rather use `pip install construct-addditional-obelisks`.
16+
17+
### Retry strategies
18+
19+
Construct Additional Obelisks provides first class support for retry behaviours.
20+
These are defined in `strategies/retry.py`,
21+
we provide `NoRetryStrategy`, `ImmediateRetryStrategy`,
22+
and `ExponentialBackoffRetryStrategy.`
23+
These do exactly what it says on the tin,
24+
when provided in the constructor of your producer, consumer or client,
25+
they will cause the client to retry requests according to the strategy
26+
whenever the response status is not in the 2XX range.
27+
28+
The default strategy is no retry,
29+
we do recommend setting at least some form of retry
30+
as the token validity behaviour sometimes encounters edge cases.
31+
32+
### Async and Sync support
33+
34+
The library has an async and blocking edition.
35+
The async edition is contained in the module `asynchronous`
36+
due to `async` being a reserved keyword and invalid package name,
37+
synchronous can be found in `sync`.
38+
The `sync` edition is simply a wrapper around `asynchronous`,
39+
maintaining an own event loop.
40+
41+
### HFS and Classic support
42+
43+
All constructors take an optional `kind` argument,
44+
set this to the appropriate variety for you.
45+
46+
There is no special handling for HFS userId / patientId fields as those are never
47+
directly touched by the library.
48+
The only exception is that `Datapoint` has explicit support for userId
49+
and allows extra fields to provide naive support for other field names.
50+
51+
## Building and Docs
52+
53+
`uv` is used to manage this project.
54+
Tests can be run using `uv run pytest`, building and deployment are handled by `uv build` and `uv publish`.
55+
56+
Documentation uses the classic `sphinx` setup, with numpydoc for their lovely layouts and conventions.
57+
Building is as follows:
58+
59+
``` sh
60+
# uv run sphinx-build -M html docs/source/ docs/build/
61+
```
62+
63+
## Credits
64+
65+
Base implementation originally by Pieter Moens <[email protected]>,
66+
modified by Kyana Bosschaerts <[email protected]>
67+
and finally consolidated by Stef Pletinck <[email protected]>.
68+

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
construct\_additional\_obelisks.asynchronous.client.Client
2+
==========================================================
3+
4+
.. currentmodule:: construct_additional_obelisks.asynchronous.client
5+
6+
.. autoclass:: Client
7+
:members:
8+
:show-inheritance:
9+
:inherited-members:
10+
11+
12+
.. automethod:: __init__
13+
14+
15+
.. rubric:: Methods
16+
17+
.. autosummary::
18+
19+
~Client.__init__
20+
~Client.http_post
21+
22+
23+
24+
25+
26+
.. rubric:: Attributes
27+
28+
.. autosummary::
29+
30+
~Client.grace_period
31+
~Client.token
32+
~Client.token_expires
33+
~Client.retry_strategy
34+
~Client.kind
35+
~Client.log
36+
37+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
construct\_additional\_obelisks.asynchronous.client
2+
===================================================
3+
4+
.. automodule:: construct_additional_obelisks.asynchronous.client
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
:toctree:
11+
:template: custom-class-template.rst
12+
13+
Client
14+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
construct\_additional\_obelisks.asynchronous.consumer.Consumer
2+
==============================================================
3+
4+
.. currentmodule:: construct_additional_obelisks.asynchronous.consumer
5+
6+
.. autoclass:: Consumer
7+
:members:
8+
:show-inheritance:
9+
:inherited-members:
10+
11+
12+
.. automethod:: __init__
13+
14+
15+
.. rubric:: Methods
16+
17+
.. autosummary::
18+
19+
~Consumer.__init__
20+
~Consumer.http_post
21+
~Consumer.query
22+
~Consumer.query_time_chunked
23+
~Consumer.single_chunk
24+
25+
26+
27+
28+
29+
.. rubric:: Attributes
30+
31+
.. autosummary::
32+
33+
~Consumer.grace_period
34+
~Consumer.token
35+
~Consumer.token_expires
36+
~Consumer.retry_strategy
37+
~Consumer.kind
38+
~Consumer.log
39+
40+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
construct\_additional\_obelisks.asynchronous.consumer
2+
=====================================================
3+
4+
.. automodule:: construct_additional_obelisks.asynchronous.consumer
5+
6+
7+
.. rubric:: Classes
8+
9+
.. autosummary::
10+
:toctree:
11+
:template: custom-class-template.rst
12+
13+
Consumer
14+

0 commit comments

Comments
 (0)