-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add dry run mode for Python SDK #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
52d21b6 to
8546c70
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a “dry run” mode to the Python SDK so that ingestion requests can be generated locally without contacting a Diode server.
- Introduces
DiodeDryRunClientandload_dryrun_entitiesfor JSON output and reloading - Updates public API exports and documentation (README)
- Adds comprehensive tests for dry-run functionality
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| netboxlabs/diode/sdk/client.py | Implements DiodeDryRunClient and load_dryrun_entities |
| netboxlabs/diode/sdk/client.pyi | Adds DiodeClientInterface protocol |
| netboxlabs/diode/sdk/init.py | Exposes dry-run classes in public API |
| tests/test_client.py | Adds tests for dry-run stdout/file output |
| README.md | Documents DIODE_DRY_RUN_OUTPUT_DIR and dry-run usage |
Comments suppressed due to low confidence (2)
netboxlabs/diode/sdk/client.py:41
- [nitpick] The docstring mentions "concatenated JSON messages" but the function expects a single JSON object representing an IngestRequest. Consider updating the docstring to accurately describe the input format.
"""Yield entities from a file with concatenated JSON messages."""
netboxlabs/diode/sdk/client.py:40
- The function uses
json.loadbutimport jsonis missing at the top of the file, leading to a NameError at runtime. Addimport jsonto the module imports.
def load_dryrun_entities(file_path: str | Path) -> Iterable[Entity]:
mfiedorowicz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This pull request introduces a new "dry run" mode for the Diode SDK, allowing users to generate ingestion requests without contacting a Diode server. It includes updates to the SDK's core functionality, documentation, and tests. The most important changes are grouped below by theme.
OUTPUT DATA
{"stream": "latest", "entities": [{"timestamp": "2025-06-10T13:11:08.754276Z", "vlan": {"site": {"name": "siteA"}, "vid": "1", "name": "default"}}, {"timestamp": "2025-06-10T13:11:08.754329Z", "vlan": {"site": {"name": "siteB"}, "vid": "1", "name": "default"}}], "id": "c9a00044-8dc7-47a1-8ed5-7f53e588fd9c","sdkName": "diode-sdk-python-dry-run", "sdkVersion": "0.0.0"}New Dry Run Functionality:
DiodeDryRunClientclass that outputs ingestion requests to stdout or JSON files instead of sending them to a Diode server. This includes support for specifying an output directory via theDIODE_DRY_RUN_OUTPUT_DIRenvironment variable or theoutput_dirparameter. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyR311-R381)load_dryrun_entitiesfunction to read and parse entities from JSON files generated during dry runs. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyR34-R55)Documentation Updates:
README.mdto document the newDIODE_DRY_RUN_OUTPUT_DIRenvironment variable and provide examples of usingDiodeDryRunClientandload_dryrun_entities. (README.md, [1] [2]SDK Enhancements:
DiodeClientInterfaceprotocol, which is implemented by bothDiodeClientandDiodeDryRunClient. This ensures consistent behavior across client implementations. (netboxlabs/diode/sdk/client.pyi, netboxlabs/diode/sdk/client.pyiR1-R25)Testing Improvements:
load_dryrun_entitiesfunction with both generated and fixture-based JSON files. (tests/test_client.py, tests/test_client.pyR676-R757)tests/test_client.py, [1] [2]Other Changes:
__init__.pyto exposeDiodeDryRunClientandload_dryrun_entitiesas part of the public API. (netboxlabs/diode/sdk/__init__.py, netboxlabs/diode/sdk/init.pyL5-R13)