adc-streaming 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. adc-streaming-0.0.0/.github/workflows/build.yml +31 -0
  2. adc-streaming-0.0.0/.gitignore +107 -0
  3. adc-streaming-0.0.0/LICENSE +29 -0
  4. adc-streaming-0.0.0/Makefile +70 -0
  5. adc-streaming-0.0.0/PKG-INFO +67 -0
  6. adc-streaming-0.0.0/README.md +50 -0
  7. adc-streaming-0.0.0/adc/__init__.py +11 -0
  8. adc-streaming-0.0.0/adc/auth.py +87 -0
  9. adc-streaming-0.0.0/adc/consumer.py +362 -0
  10. adc-streaming-0.0.0/adc/errors.py +102 -0
  11. adc-streaming-0.0.0/adc/io.py +74 -0
  12. adc-streaming-0.0.0/adc/kafka.py +30 -0
  13. adc-streaming-0.0.0/adc/producer.py +164 -0
  14. adc-streaming-0.0.0/adc_streaming.egg-info/PKG-INFO +67 -0
  15. adc-streaming-0.0.0/adc_streaming.egg-info/SOURCES.txt +34 -0
  16. adc-streaming-0.0.0/adc_streaming.egg-info/dependency_links.txt +1 -0
  17. adc-streaming-0.0.0/adc_streaming.egg-info/not-zip-safe +1 -0
  18. adc-streaming-0.0.0/adc_streaming.egg-info/requires.txt +22 -0
  19. adc-streaming-0.0.0/adc_streaming.egg-info/top_level.txt +1 -0
  20. adc-streaming-0.0.0/doc/Makefile +20 -0
  21. adc-streaming-0.0.0/doc/_static/css/my_theme.css +29 -0
  22. adc-streaming-0.0.0/doc/_templates/layout.html +2 -0
  23. adc-streaming-0.0.0/doc/api/api.rst +10 -0
  24. adc-streaming-0.0.0/doc/api/streaming.rst +7 -0
  25. adc-streaming-0.0.0/doc/conf.py +179 -0
  26. adc-streaming-0.0.0/doc/index.rst +26 -0
  27. adc-streaming-0.0.0/doc/user/installation.rst +29 -0
  28. adc-streaming-0.0.0/doc/user/quickstart.rst +25 -0
  29. adc-streaming-0.0.0/pyproject.toml +5 -0
  30. adc-streaming-0.0.0/recipe/meta.yaml +35 -0
  31. adc-streaming-0.0.0/setup.cfg +21 -0
  32. adc-streaming-0.0.0/setup.py +48 -0
  33. adc-streaming-0.0.0/tests/test_auth.py +36 -0
  34. adc-streaming-0.0.0/tests/test_kafka.py +70 -0
  35. adc-streaming-0.0.0/tests/test_kafka_integration.py +653 -0
@@ -0,0 +1,31 @@
1
+ name: build
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
11
+
12
+ steps:
13
+ - name: Check out the code
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Python ${{ matrix.python-version }}
17
+ uses: actions/setup-python@v1
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+
21
+ - name: Check that the package is pip-installable
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install --upgrade setuptools setuptools_scm wheel
25
+ pip install .[dev]
26
+
27
+ - name: Lint
28
+ run: make lint
29
+
30
+ - name: Test
31
+ run: make test
@@ -0,0 +1,107 @@
1
+ DEADJOE
2
+ *~
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+
62
+ # Flask stuff:
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff:
67
+ .scrapy
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # pyenv
79
+ .python-version
80
+
81
+ # celery beat schedule file
82
+ celerybeat-schedule
83
+
84
+ # SageMath parsed files
85
+ *.sage.py
86
+
87
+ # Environments
88
+ .env
89
+ .venv
90
+ env/
91
+ venv/
92
+ ENV/
93
+ env.bak/
94
+ venv.bak/
95
+
96
+ # Spyder project settings
97
+ .spyderproject
98
+ .spyproject
99
+
100
+ # Rope project settings
101
+ .ropeproject
102
+
103
+ # mkdocs documentation
104
+ /site
105
+
106
+ # mypy
107
+ .mypy_cache/
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2019, Mario Juric
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,70 @@
1
+ .PHONY: help
2
+ help :
3
+ @echo
4
+ @echo 'Commands:'
5
+ @echo
6
+ @echo ' make test run tests'
7
+ @echo ' make test-quick run tests, but not integration tests'
8
+ @echo ' make lint run linter'
9
+ @echo ' make format run code formatter'
10
+ @echo ' make doc make documentation'
11
+ @echo ' make changelog update changelog based on version'
12
+ @echo ' make pypi-dist make binary and source packages for PyPI'
13
+ @echo ' make pypi-dist-check verify binary and source packages for PyPI'
14
+ @echo ' make pypi-upload upload to PyPI'
15
+ @echo ' make conda-build make binary and source packages for conda-forge'
16
+ @echo ' make conda-upload upload to conda-forge'
17
+ @echo
18
+
19
+ VERSION ?= $(shell python setup.py --version)
20
+ REPO_URL = https://github.com/astronomy-commons/adc-streaming
21
+
22
+ .PHONY: test
23
+ test :
24
+ python -m pytest -v
25
+
26
+ .PHONY: test-quick
27
+ test-quick :
28
+ python -m pytest -v --without-integration
29
+
30
+ .PHONY: lint
31
+ lint :
32
+ # stop the build if there are Python syntax errors or undefined names
33
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34
+ # exit-zero treats all errors as warnings
35
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
36
+
37
+ .PHONY: format
38
+ format :
39
+ autopep8 --recursive --in-place .
40
+ isort
41
+
42
+ .PHONY: doc
43
+ doc :
44
+ cd doc && make html
45
+
46
+ .PHONY: changelog
47
+ changelog :
48
+ sed -i 's@## \[Unreleased]@## \[Unreleased]\n\n## \[$(VERSION)] - $(shell date +'%Y-%m-%d')@' CHANGELOG.md
49
+ sed -i 's@.*\[Unreleased]:.*@\[Unreleased]: $(REPO_URL)/compare/v$(VERSION)...HEAD\n[$(VERSION)]: $(REPO_URL)/releases/tag/v$(VERSION)@' CHANGELOG.md
50
+
51
+
52
+ .PHONY: pypi-dist
53
+ pypi-dist :
54
+ python setup.py sdist bdist_wheel
55
+
56
+ .PHONY: pypi-dist-check
57
+ pypi-dist-check:
58
+ twine check dist/*
59
+
60
+ .PHONY: pypi-upload
61
+ pypi-upload:
62
+ twine upload dist/*
63
+
64
+ .PHONY: conda-build
65
+ conda-build:
66
+ conda build -c defaults -c conda-forge ./recipe
67
+
68
+ .PHONY: conda-upload
69
+ conda-upload:
70
+ anaconda upload $(shell conda build ./recipe --output)
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.1
2
+ Name: adc-streaming
3
+ Version: 0.0.0
4
+ Summary: Astronomy Data Commons streaming client libraries
5
+ Home-page: https://github.com/astronomy-commons/adc-streaming
6
+ Author: Astronomy Data Commons Team
7
+ Author-email: swnelson@uw.edu
8
+ License: BSD
9
+ Description: # Astronomy Data Commons Streaming Client Libraries
10
+
11
+ Libraries making it easy to access astronomy data commons resources.
12
+
13
+ ## Developer notes
14
+
15
+ ### Setup
16
+
17
+ To prepare for development, run `pip install --editable ".[dev]"` from within
18
+ the repo directory. This will install all dependencies, including those using
19
+ during development workflows.
20
+
21
+ This project expects you to use a `pip`-centric workflow for development on the
22
+ project itself. If you're using conda, then use the conda environment's `pip` to
23
+ install development dependencies, as described above.
24
+
25
+ Integration tests require Docker to run a Kafka broker. The broker might have
26
+ network problems on OSX if you use Docker Desktop; run the tests in a Linux
27
+ virtual machine (like with VirtualBox) to get around this.
28
+
29
+ ### Code Workflow
30
+
31
+ Write code, making changes.
32
+
33
+ Use `make format` to reformat your code to comply with PEP8.
34
+
35
+ Use `make lint` to catch common mistakes.
36
+
37
+ Use `make test-quick` to run fast unit tests.
38
+
39
+ Use `make test` to run the full slow test suite, including integration tests.
40
+
41
+ Once satisfied with all four of those, push your changes and open a PR.
42
+
43
+ ### Tag, build, and upload to PyPI and Conda
44
+
45
+ Tag a new version:
46
+ ```
47
+ git tag -s -a v0.x.x
48
+ ```
49
+
50
+ Build and release:
51
+
52
+ ```
53
+ make pypi-dist
54
+ make pypi-dist-check
55
+ make pypi-upload
56
+ make conda-build
57
+ make conda-upload
58
+ ```
59
+
60
+ Platform: UNKNOWN
61
+ Classifier: Programming Language :: Python :: 3
62
+ Classifier: License :: OSI Approved :: BSD License
63
+ Classifier: Development Status :: 3 - Alpha
64
+ Classifier: Operating System :: POSIX :: Linux
65
+ Classifier: Operating System :: MacOS :: MacOS X
66
+ Description-Content-Type: text/markdown
67
+ Provides-Extra: dev
@@ -0,0 +1,50 @@
1
+ # Astronomy Data Commons Streaming Client Libraries
2
+
3
+ Libraries making it easy to access astronomy data commons resources.
4
+
5
+ ## Developer notes
6
+
7
+ ### Setup
8
+
9
+ To prepare for development, run `pip install --editable ".[dev]"` from within
10
+ the repo directory. This will install all dependencies, including those using
11
+ during development workflows.
12
+
13
+ This project expects you to use a `pip`-centric workflow for development on the
14
+ project itself. If you're using conda, then use the conda environment's `pip` to
15
+ install development dependencies, as described above.
16
+
17
+ Integration tests require Docker to run a Kafka broker. The broker might have
18
+ network problems on OSX if you use Docker Desktop; run the tests in a Linux
19
+ virtual machine (like with VirtualBox) to get around this.
20
+
21
+ ### Code Workflow
22
+
23
+ Write code, making changes.
24
+
25
+ Use `make format` to reformat your code to comply with PEP8.
26
+
27
+ Use `make lint` to catch common mistakes.
28
+
29
+ Use `make test-quick` to run fast unit tests.
30
+
31
+ Use `make test` to run the full slow test suite, including integration tests.
32
+
33
+ Once satisfied with all four of those, push your changes and open a PR.
34
+
35
+ ### Tag, build, and upload to PyPI and Conda
36
+
37
+ Tag a new version:
38
+ ```
39
+ git tag -s -a v0.x.x
40
+ ```
41
+
42
+ Build and release:
43
+
44
+ ```
45
+ make pypi-dist
46
+ make pypi-dist-check
47
+ make pypi-upload
48
+ make conda-build
49
+ make conda-upload
50
+ ```
@@ -0,0 +1,11 @@
1
+ try:
2
+ from importlib.metadata import PackageNotFoundError, version
3
+ except ImportError:
4
+ # NOTE: remove after dropping support for Python < 3.8
5
+ from importlib_metadata import PackageNotFoundError, version
6
+
7
+ try:
8
+ __version__ = version("adc-streaming")
9
+ except PackageNotFoundError:
10
+ # package is not installed
11
+ pass
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env python
2
+
3
+ from enum import Enum
4
+
5
+ import certifi
6
+
7
+
8
+ class SASLMethod(Enum):
9
+ """SASL method to use for authentication.
10
+ """
11
+
12
+ PLAIN = 1
13
+ SCRAM_SHA_256 = 2
14
+ SCRAM_SHA_512 = 3
15
+ OAUTHBEARER = 4
16
+
17
+ def __str__(self):
18
+ return self.name.replace("_", "-")
19
+
20
+
21
+ class SASLAuth(object):
22
+ """Attach SASL-based authentication to a client.
23
+
24
+ Returns client-based auth options when called.
25
+
26
+ Parameters
27
+ ----------
28
+ user : `str`
29
+ Username to authenticate with.
30
+ password : `str`
31
+ Password to authenticate with.
32
+ ssl : `bool`, optional
33
+ Whether to enable SSL (enabled by default).
34
+ method : `SASLMethod`, optional
35
+ The SASL method to authenticate. The default is SASLMethod.OAUTHBEARER
36
+ if token_endpoint is provided, or SASLMethod.PLAIN otherwise.
37
+ See valid SASL methods in SASLMethod.
38
+ ssl_ca_location : `str`, optional
39
+ If using SSL via a self-signed cert, a path/location
40
+ to the certificate.
41
+ ssl_endpoint_identification_algorithm : `str`, optional
42
+ If using SSL, the algorithm used to verify that certificate is valid for the endpoint.
43
+ token_endpoint : `str`, optional
44
+ The OpenID Connect token endpoint URL.
45
+ Required for OAUTHBEARER / OpenID Connect, otherwise ignored.
46
+
47
+ """
48
+
49
+ def __init__(self, user, password, ssl=True, method=None, token_endpoint=None, **kwargs):
50
+ if method is None:
51
+ if token_endpoint is None:
52
+ method = SASLMethod.PLAIN
53
+ else:
54
+ method = SASLMethod.OAUTHBEARER
55
+ self._method = method
56
+
57
+ # set up SSL options
58
+ if ssl:
59
+ if "ssl_ca_location" in kwargs:
60
+ ssl_cert = kwargs["ssl_ca_location"]
61
+ else:
62
+ ssl_cert = certifi.where()
63
+
64
+ self._config = {
65
+ "security.protocol": "SASL_SSL",
66
+ "ssl.ca.location": ssl_cert,
67
+ "https.ca.location": ssl_cert,
68
+ }
69
+ if "ssl_endpoint_identification_algorithm" in kwargs:
70
+ self._config["ssl.endpoint.identification.algorithm"] = \
71
+ kwargs["ssl_endpoint_identification_algorithm"]
72
+ else:
73
+ self._config = {"security.protocol": "SASL_PLAINTEXT"}
74
+
75
+ # set up SASL options
76
+ self._config["sasl.mechanism"] = str(self._method)
77
+ if token_endpoint:
78
+ self._config["sasl.oauthbearer.client.id"] = user
79
+ self._config["sasl.oauthbearer.client.secret"] = password
80
+ self._config["sasl.oauthbearer.method"] = "oidc"
81
+ self._config["sasl.oauthbearer.token.endpoint.url"] = token_endpoint
82
+ else:
83
+ self._config["sasl.username"] = user
84
+ self._config["sasl.password"] = password
85
+
86
+ def __call__(self):
87
+ return self._config