Skip to content

Commit f8bad59

Browse files
Remove IngestRecordResult and make multiple other utility additions (#2)
* Remove IngestRecordResult * Add SECURITY.md * Add CONTRIBUTING.md and DCO * Add dependabot.yml * Add PR template * Add feature and issues templates * Add formatting * Update JAR name and README
1 parent 3dd8107 commit f8bad59

24 files changed

+1569
-1269
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature or improvement for the Python SDK for Zerobus.
4+
title: "[FEATURE] "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Problem Statement**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Proposed Solution**
14+
A clear and concise description of what you want to happen.
15+
16+
**Additional Context**
17+
Add any other context, references or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: SDK Issue
3+
about: Use this to report an issue with the Python SDK for Zerobus.
4+
title: "[ISSUE] "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Description**
11+
A clear and concise description of what the bug is.
12+
13+
**Reproduction**
14+
A minimal code sample demonstrating the bug.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Is it a regression?**
20+
Did this work in a previous version of the SDK? If so, which versions did you try?
21+
22+
**Debug Logs**
23+
The SDK logs helpful debugging information when debug logging is enabled. Set the log level to debug by adding `logging.basicConfig(level=logging.DEBUG)` to your program, and include the logs here.
24+
25+
**Other Information**
26+
- OS: [e.g. macOS]
27+
- Version: [e.g. 0.1.0]
28+
29+
**Additional context**
30+
Add any other context about the problem here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## What changes are proposed in this pull request?
2+
3+
Provide the readers and reviewers with the information they need to understand
4+
this PR in a comprehensive manner.
5+
6+
Specifically, try to answer the two following questions:
7+
8+
- **WHAT** changes are being made in the PR? This should be a summary of the
9+
major changes to allow the reader to quickly understand the PR without having
10+
to look at the code.
11+
- **WHY** are these changes needed? This should provide the context that the
12+
reader might be missing. For example, were there any decisions behind the
13+
change that are not reflected in the code itself?
14+
15+
The "why part" is the most important of the two as it usually cannot be
16+
inferred from the code itself. A well-written PR description will help future
17+
developers (including your future self) to know how to interact and update your
18+
code.
19+
20+
## How is this tested?
21+
22+
Describe any tests you have done; especially if test tests are not part of
23+
the unit tests (e.g. local tests).
24+
25+
**ALWAYS ANSWER THIS QUESTION:** Answer with "N/A" if tests are not applicable
26+
to your PR (e.g. if the PR only modifies comments). Do not be afraid of
27+
answering "Not tested" if the PR has not been tested. Being clear about what
28+
has been done and not done provides important context to the reviewers.

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/push.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
merge_group:
7+
types: [checks_requested]
8+
9+
jobs:
10+
fmt:
11+
runs-on:
12+
group: databricks-protected-runner-group
13+
labels: linux-ubuntu-latest
14+
steps:
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Cache Maven packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.m2
27+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: ${{ runner.os }}-m2
29+
30+
- name: Check formatting
31+
run: mvn --errors spotless:check

CONTRIBUTING.md

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Contributing to Zerobus SDK for Python
2+
3+
We happily welcome contributions to the Zerobus SDK for Python. We use [GitHub Issues](https://github.com/databricks/zerobus-sdk-py/issues) to track community reported issues and [GitHub Pull Requests](https://github.com/databricks/zerobus-sdk-py/pulls) for accepting changes.
4+
5+
Contributions are licensed on a license-in/license-out basis.
6+
7+
## Communication
8+
9+
Before starting work on a major feature, please open a GitHub issue. We will make sure no one else is already working on it and that it is aligned with the goals of the project.
10+
11+
A "major feature" is defined as any change that is > 100 LOC altered (not including tests), or changes any user-facing behavior.
12+
13+
We will use the GitHub issue to discuss the feature and come to agreement. This is to prevent your time being wasted, as well as ours. The GitHub review process for major features is also important so that organizations with commit access can come to agreement on design.
14+
15+
If it is appropriate to write a design document, the document must be hosted either in the GitHub tracking issue, or linked to from the issue and hosted in a world-readable location.
16+
17+
Small patches and bug fixes don't need prior communication.
18+
19+
## Development Setup
20+
21+
### Prerequisites
22+
23+
- Python 3.7 or higher
24+
- Git
25+
- pip
26+
27+
### Setting Up Your Development Environment
28+
29+
1. **Clone the repository:**
30+
```bash
31+
git clone https://github.com/databricks/zerobus-sdk-py.git
32+
cd zerobus-sdk-py
33+
```
34+
35+
2. **Create and activate a virtual environment:**
36+
```bash
37+
make dev
38+
```
39+
40+
This will:
41+
- Create a virtual environment in `.venv`
42+
- Install the package in development mode with all dev dependencies
43+
44+
3. **Activate the virtual environment:**
45+
```bash
46+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
47+
```
48+
49+
## Coding Style
50+
51+
Code style is enforced by a formatter check in your pull request. We use [Black](https://github.com/psf/black) to format our code. Run `make fmt` to ensure your code is properly formatted prior to raising a pull request.
52+
53+
### Running the Formatter
54+
55+
Format your code before committing:
56+
57+
```bash
58+
make fmt
59+
```
60+
61+
This runs:
62+
- **Black**: Code formatting
63+
- **autoflake**: Remove unused imports
64+
- **isort**: Sort imports
65+
66+
### Running Linters
67+
68+
Check your code for issues:
69+
70+
```bash
71+
make lint
72+
```
73+
74+
This runs:
75+
- **pycodestyle**: Style guide enforcement
76+
- **autoflake**: Check for unused imports
77+
78+
## Pull Request Process
79+
80+
1. **Create a feature branch:**
81+
```bash
82+
git checkout -b feature/your-feature-name
83+
```
84+
85+
2. **Make your changes:**
86+
- Write clear, concise commit messages
87+
- Follow existing code style
88+
- Update documentation as needed
89+
90+
3. **Format your code:**
91+
```bash
92+
make fmt
93+
```
94+
95+
4. **Commit your changes:**
96+
```bash
97+
git add .
98+
git commit -m "Add feature: description of your changes"
99+
```
100+
101+
5. **Push to your fork:**
102+
```bash
103+
git push origin feature/your-feature-name
104+
```
105+
106+
6. **Create a Pull Request:**
107+
- Provide a clear description of changes
108+
- Reference any related issues
109+
- Ensure all CI checks pass
110+
111+
## Signed Commits
112+
113+
This repo requires all contributors to sign their commits. To configure this, you can follow [Github's documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) to create a GPG key, upload it to your Github account, and configure your git client to sign commits.
114+
115+
## Developer Certificate of Origin
116+
117+
To contribute to this repository, you must sign off your commits to certify that you have the right to contribute the code and that it complies with the open source license. The rules are pretty simple, if you can certify the content of [DCO](./DCO), then simply add a "Signed-off-by" line to your commit message to certify your compliance. Please use your real name as pseudonymous/anonymous contributions are not accepted.
118+
119+
```
120+
Signed-off-by: Joe Smith <[email protected]>
121+
```
122+
123+
If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`:
124+
125+
```bash
126+
git commit -s -m "Your commit message"
127+
```
128+
129+
## Code Review Guidelines
130+
131+
When reviewing code:
132+
133+
- Check for adherence to code style
134+
- Look for potential edge cases
135+
- Consider performance implications
136+
- Ensure documentation is updated
137+
138+
## Commit Message Guidelines
139+
140+
Follow these conventions for commit messages:
141+
142+
- Use present tense: "Add feature" not "Added feature"
143+
- Use imperative mood: "Fix bug" not "Fixes bug"
144+
- First line should be 50 characters or less
145+
- Reference issues: "Fix #123: Description of fix"
146+
147+
Example:
148+
```
149+
Add async stream creation example
150+
151+
- Add async_example.py demonstrating non-blocking ingestion
152+
- Update README with async API documentation
153+
154+
Fixes #42
155+
```
156+
157+
## Documentation
158+
159+
### Updating Documentation
160+
161+
- Update docstrings for all public APIs
162+
- Use Google-style docstrings
163+
- Include examples in docstrings where helpful
164+
- Update README.md for user-facing changes
165+
- Update examples/ for new features
166+
167+
Example docstring:
168+
```python
169+
def ingest_record(self, record) -> RecordAcknowledgment:
170+
"""
171+
Submits a single record for ingestion into the stream.
172+
173+
This method may block if the maximum number of in-flight records
174+
has been reached.
175+
176+
Args:
177+
record: The Protobuf message object to be ingested.
178+
179+
Returns:
180+
RecordAcknowledgment: An object to wait on for the server's acknowledgment.
181+
182+
Raises:
183+
ZerobusException: If the stream is not in a valid state for ingestion.
184+
185+
Example:
186+
>>> record = AirQuality(device_name="sensor-1", temp=25)
187+
>>> ack = stream.ingest_record(record)
188+
>>> ack.wait_for_ack()
189+
"""
190+
```
191+
192+
## Continuous Integration
193+
194+
All pull requests must pass CI checks:
195+
196+
- **fmt**: Runs formatting checks (black, autoflake, isort)
197+
198+
The formatting check runs `make dev fmt` and then checks for any git differences. If there are differences, the check will fail.
199+
200+
You can view CI results in the GitHub Actions tab of the pull request.
201+
202+
## Makefile Targets
203+
204+
Available make targets:
205+
206+
- `make dev` - Set up development environment
207+
- `make install` - Install package
208+
- `make build` - Build wheel package
209+
- `make fmt` - Format code with black, autoflake, and isort
210+
- `make lint` - Run linting with pycodestyle
211+
- `make clean` - Remove build artifacts
212+
- `make help` - Show available targets
213+
214+
## Versioning
215+
216+
We follow [Semantic Versioning](https://semver.org/):
217+
218+
- **MAJOR**: Incompatible API changes
219+
- **MINOR**: Backwards-compatible functionality additions
220+
- **PATCH**: Backwards-compatible bug fixes
221+
222+
## Getting Help
223+
224+
- **Issues**: Open an issue on GitHub for bugs or feature requests
225+
- **Discussions**: Use GitHub Discussions for questions
226+
- **Documentation**: Check the README and examples/
227+
228+
## Package Name
229+
230+
The package is published on PyPI as `databricks-zerobus-ingest-sdk`.
231+
232+
## Code of Conduct
233+
234+
- Be respectful and inclusive
235+
- Welcome newcomers
236+
- Focus on constructive feedback
237+
- Follow the [Python Community Code of Conduct](https://www.python.org/psf/conduct/)

DCO

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Developer's Certificate of Origin 1.1
2+
3+
By making a contribution to this project, I certify that:
4+
5+
(a) The contribution was created in whole or in part by me and I
6+
have the right to submit it under the open source license
7+
indicated in the file; or
8+
9+
(b) The contribution is based upon previous work that, to the best
10+
of my knowledge, is covered under an appropriate open source
11+
license and I have the right under that license to submit that
12+
work with modifications, whether created in whole or in part
13+
by me, under the same open source license (unless I am
14+
permitted to submit under a different license), as indicated
15+
in the file; or
16+
17+
(c) The contribution was provided directly to me by some other
18+
person who certified (a), (b) or (c) and I have not modified
19+
it.
20+
21+
(d) I understand and agree that this project and the contribution
22+
are public and that a record of the contribution (including all
23+
personal information I submit with it, including my sign-off) is
24+
maintained indefinitely and may be redistributed consistent with
25+
this project or the open source license(s) involved.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fmt:
2+
mvn spotless:apply

0 commit comments

Comments
 (0)