-
Notifications
You must be signed in to change notification settings - Fork 97
Return only objects from API #7072
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
📝 WalkthroughWalkthroughThe changes introduce structured response types for several REST API endpoints, update OpenAPI documentation to reflect these types, and refine Python SDK methods to extract specific fields from API responses. Build and test scripts are updated to use Changes
Sequence Diagram(s)REST API: Funding a Channel (Updated Response)sequenceDiagram
participant Client
participant REST-API
participant ChannelLogic
Client->>REST-API: POST /channels/fund
REST-API->>ChannelLogic: fund_channel()
ChannelLogic-->>REST-API: Hash (transaction hash)
REST-API-->>Client: JSON { "hash": "<transaction_hash>" }
REST API: Node Graph Retrieval (Updated Response)sequenceDiagram
participant Client
participant REST-API
participant NodeLogic
Client->>REST-API: GET /node/graph
REST-API->>NodeLogic: get_graph()
NodeLogic-->>REST-API: String (graph data)
REST-API-->>Client: JSON { "graph": "<graph_data>" }
Python SDK: Configuration and Metrics RetrievalsequenceDiagram
participant SDK
participant API
participant Server
SDK->>API: GET /config
API->>Server: Request config
Server-->>API: { "config": {...} }
API-->>SDK: Configuration object from "config" field
SDK->>API: GET /metrics
API->>Server: Request metrics
Server-->>API: { "metrics": {...} }
API-->>SDK: "metrics" field if successful, else None
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
I don't see such a problem with having types like |
Michal complains about having plain-text responses and objects. If everything is an object it's simpler to decode once the response is received. |
This pull request introduces several updates across the codebase, focusing on improving test execution, enhancing REST API responses, refining error handling, and updating dependencies. Below is a categorized summary of the most important changes:
Test Execution Updates:
Makefile
to replacesource .venv/bin/activate
withuv run
for running tests and local clusters, streamlining the test execution process. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L68-R72)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L100-R99)
)REST API Enhancements:
FundChannelResponse
struct to standardize the response for funding a channel. This replaces the plain string response with a structured JSON object. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-1df3f9bf9a8abe27e00d7f7721d0e8591f2e91f66c160bf2075d38895d759a63R464-R475)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-1df3f9bf9a8abe27e00d7f7721d0e8591f2e91f66c160bf2075d38895d759a63L487-R499)
,[[3]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-1df3f9bf9a8abe27e00d7f7721d0e8591f2e91f66c160bf2075d38895d759a63L512-R524)
)NodeGraphResponse
struct for the channel graph API, improving the clarity and structure of the response. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-5bf6b6849c16ea33849b2bfa103b6a590f9a63d21d204b3b730a5c873c03e366R308-R326)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-5bf6b6849c16ea33849b2bfa103b6a590f9a63d21d204b3b730a5c873c03e366L329-R341)
)HashMap<String, String>
wrapped in JSON instead of a plain string. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-5bf6b6849c16ea33849b2bfa103b6a590f9a63d21d204b3b730a5c873c03e366L56-R56)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-5bf6b6849c16ea33849b2bfa103b6a590f9a63d21d204b3b730a5c873c03e366L66-R66)
)Error Handling Improvements:
localcluster
module by including more descriptive runtime errors when nodes fail to connect or return addresses. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-bf5445bb6294f658842ba0530a55f4f2768ccb7ec59cfc3c1b5b4122460413acL80-R88)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-bf5445bb6294f658842ba0530a55f4f2768ccb7ec59cfc3c1b5b4122460413acL104-R102)
)RuntimeError
in thebringup
function to log errors more effectively. ([sdk/python/localcluster/main_process.pyR93-R95](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-fd306027f1b9a2d4cd8aa6774752b44d64b9aabc2059bd9370fb4e0ac17b3dc2R93-R95)
)Dependency and Configuration Updates:
pyproject.toml
files forsdk-api
andsdk-localcluster
to increment the version and add new dependencies (click
forsdk-localcluster
). ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-9b29183277b4bc5d50a3aab7ac0ced8e5312f131a7bb35c9c47f812d7c318ceaL3-R3)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-b59227696d090d8af77ffda26d7a4e5df1c9e8aaa6a4d6b2246f455563e307e6L3-R5)
)python39
dependency from theflake.nix
file, likely reflecting a migration to newer Python versions. ([flake.nixL370](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0L370)
)Logging Refinements:
logging.warning
instead oflogging.info
for missing snapshot files. ([[1]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-cd8a3595eb1086da0b25341ce323deb7b3c1548af6e1d119a4daa92658bc5c44L68-R68)
,[[2]](https://github.com/hoprnet/hoprnet/pull/7072/files#diff-eebeffea190caf0c5a0607cd56485da81d9d809ab8552f9c8a450dd3ccf80924L84-R84)
)