Skip to content

Conversation

jeandemeusy
Copy link
Contributor

The python autogenerated SDK isn't used by anyone within HOPR as it has been replaced by an async-compatible alternative.
In consequence, there's no need to generate the SDK anymore. Also, the hopr-sdk-python is being deprecated

Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

📝 Walkthrough

Walkthrough

This pull request involves the removal and modification of SDK generation infrastructure for the HOPR project. The changes include deleting the GitHub Actions workflow for SDK generation, removing the Makefile target for Python SDK generation, updating the SDK generation script, and modifying the README documentation. The primary focus is on streamlining and simplifying the process of generating Python SDKs for the HOPRd API.

Changes

File Change Summary
.github/workflows/generate-sdk.yaml Deleted GitHub Actions workflow for automated SDK generation
Makefile Removed generate-python-sdk target
hoprd_sdk/api_client.py Updated ApiClient with context management methods and improved resource handling
README.md Added new section "Generate the Python SDK" with generation instructions
scripts/generate-python-sdk.sh New Bash script for generating Python SDK using Swagger Codegen

Possibly related PRs

  • Fix withdraw endpoint #6522: The changes in the main PR involve the removal of the generate-python-sdk target from the Makefile, which is directly related to the functionality of generating a Python SDK, similar to the workflow defined in the deleted generate-sdk.yaml.
  • Pipeline improvements #6551: The modifications in the main PR include the deletion of the generate-sdk.yaml workflow, which was responsible for generating the Python SDK. This is relevant to the pipeline improvements that may affect how SDK generation is handled in the overall workflow.
  • Open release 3.0.0 #6774: The release of version 3.0.0 may include updates or changes that relate to the SDK generation process, as indicated by the overall focus on establishing components for the new release, which could encompass the SDK functionalities.

Suggested Labels

dependencies, crate:hopr-lib

Suggested Reviewers

  • Teebor-Choka
  • NumberFour8

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53581a7 and 4a8ecb5.

📒 Files selected for processing (1)
  • scripts/generate-python-sdk.sh (1 hunks)
🧰 Additional context used
📓 Learnings (1)
scripts/generate-python-sdk.sh (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6772
File: scripts/generate-python-sdk.sh:1-10
Timestamp: 2025-01-15T16:14:10.492Z
Learning: In shell scripts, make paths configurable by using environment variables with default values using parameter expansion (e.g., `${VAR:-default}`). This allows users to override the default behavior without modifying the script.
🪛 Shellcheck (0.10.0)
scripts/generate-python-sdk.sh

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: hoprd / docker
  • GitHub Check: tests-smoke-websocket
  • GitHub Check: tests-unit
🔇 Additional comments (8)
scripts/generate-python-sdk.sh (8)

1-5: LGTM! Well-structured script setup.

The script follows shell scripting best practices with proper error handling and configurable paths.


7-11: Add validation for hoprd-api-schema command.

The script should validate all required commands upfront.


17-18: Add validation for version script.

The script should validate the version script before using it.


20-22: Add safeguards for directory cleanup.

The current implementation of rm -rf could be dangerous if TARGET_DIR is empty or unset.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)


24-25: Add error handling for OpenAPI spec generation.

The hoprd-api-schema command needs validation and error handling.


27-35: LGTM! Proper SDK generation with error handling.

The SDK generation logic is well-implemented with appropriate error handling.


37-37: LGTM! Clear success message.

The success message clearly indicates where to find the generated SDK.


13-15: 🛠️ Refactor suggestion

Improve temporary file handling.

The script should handle all temporary files consistently using mktemp and cleanup traps.

Apply this diff:

 # Use mktemp for secure temporary file creation
 config_file=$(mktemp)
-trap 'rm -f "${config_file}"' EXIT
+spec_file=$(mktemp)
+trap 'rm -f "${config_file}" "${spec_file}"' EXIT

Likely invalid or redundant comment.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added dependencies Pull requests that update a dependency file toolchain Developer and product happiness labels Jan 15, 2025
@jeandemeusy jeandemeusy requested a review from a team January 15, 2025 12:42
@jeandemeusy jeandemeusy self-assigned this Jan 15, 2025
Copy link
Contributor

@Teebor-Choka Teebor-Choka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be worth extracting the makefile sequence with the swagger based generation into a script a point to it in README.md instead, so that anybody can take that as an example (even for a different language than python). Drop the patch though.

@jeandemeusy
Copy link
Contributor Author

Maybe it would be worth extracting the makefile sequence with the swagger based generation into a script a point to it in README.md instead, so that anybody can take that as an example (even for a different language than python). Drop the patch though.

Done.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eeaef79 and 7747a64.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • scripts/generate-python-sdk.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
scripts/generate-python-sdk.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 1-1: Quote this to prevent word splitting.

(SC2046)

🪛 LanguageTool
README.md

[typographical] ~340-~340: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...is available to connect to the HOPRd API, however it can be generated by using this [scri...

(HOWEVER_SENTENCE)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: hopli / docker
  • GitHub Check: Docs / Rust docs
  • GitHub Check: tests-unit-nightly
  • GitHub Check: tests-smart-contracts
  • GitHub Check: tests-unit
  • GitHub Check: tests-smoke-websocket
  • GitHub Check: Linter

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
hoprd/hoprd/example_cfg.yaml (1)

180-184: Document rationale for aggressive heartbeat settings.

The configuration changes align with the updates in other files, but the example configuration would benefit from additional comments explaining:

  • The reasoning behind the more aggressive probing strategy
  • Potential resource implications of increased parallel probes
  • Considerations for different network conditions

Consider adding these explanatory comments to the configuration:

  heartbeat:
    # The maximum number of concurrent heartbeat probes
+   # Note: Higher values increase responsiveness but also increase resource usage
    max_parallel_probes: 50
    # Interval in which the heartbeat is triggered in seconds
    interval: 60
    # The time interval for which to consider peer heartbeat renewal in seconds
+   # Note: Lower threshold values make the network more responsive but may increase churn
    threshold: 40

Also applies to: 227-227

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7747a64 and 3e8dbc8.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • hoprd/hoprd/example_cfg.yaml (2 hunks)
  • transport/network/Cargo.toml (1 hunks)
  • transport/network/src/constants.rs (1 hunks)
  • transport/protocol/Cargo.toml (1 hunks)
  • transport/protocol/src/heartbeat/config.rs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • transport/protocol/Cargo.toml
  • transport/network/Cargo.toml
🔇 Additional comments (3)
transport/protocol/src/heartbeat/config.rs (1)

13-13: Verify impact of reduced heartbeat timeout on network reliability.

The reduction of the heartbeat timeout from 15 to 7 seconds is significant. While this makes the heartbeat mechanism more responsive, it could potentially affect:

  • Nodes in high-latency networks
  • Nodes behind NAT
  • Nodes in regions with poor connectivity

Run this script to analyze historical network latencies and identify potential impact:

✅ Verification successful

Heartbeat timeout reduction to 7 seconds is appropriate for the system design

The reduced timeout aligns well with the system's other timing parameters:

  • Fits within the 40-second heartbeat threshold for node availability checks
  • Maintains good balance with the 10-second message acknowledgment timeout
  • Provides faster failure detection while still being conservative enough for typical network conditions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for latency-related issues in logs
# Look for timeout patterns or latency issues that might be affected by the reduced timeout

rg -i "timeout|latency|heartbeat.*fail" 

Length of output: 65994


Script:

#!/bin/bash
# Search for heartbeat protocol implementation and related code
echo "=== Heartbeat Protocol Implementation ==="
ast-grep --pattern 'struct $name {
  $$$
  timeout: $_
  $$$
}'

echo -e "\n=== Heartbeat Usage and Network Metrics ==="
rg -B2 -A2 "heartbeat.*timeout|network.*latency" --type rust

echo -e "\n=== Related Configuration Parameters ==="
rg -B1 -A1 "Duration::from_secs|TIMEOUT" transport/

Length of output: 12819

transport/network/src/constants.rs (2)

6-6: Consider network impact of reduced heartbeat threshold.

Reducing the heartbeat threshold from 60 to 40 seconds makes the network more responsive but could increase the frequency of peer availability checks.

Consider implementing a gradual rollout or monitoring system to track the impact of this change on network load.


13-13: Verify network capacity for increased parallel pings.

The significant increase in DEFAULT_MAX_PARALLEL_PINGS (14 → 50) could impact:

  • Network bandwidth consumption
  • Node resource utilization
  • Connection pool limits

Run this script to check for connection-related issues:

✅ Verification successful

Change is safe due to enforced hard limit of 14 parallel pings

The increase in DEFAULT_MAX_PARALLEL_PINGS to 50 does not impact system stability because:

  • The Pinger implementation enforces a hard limit of 14 parallel pings (MAX_PARALLEL_PINGS)
  • The actual number of parallel pings is capped using: config.max_parallel_pings.min(MAX_PARALLEL_PINGS)
  • The system implements proper backpressure and resource management through chunked stream processing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for connection pool or resource exhaustion patterns
# Look for evidence of connection-related issues that might be exacerbated

rg -i "connection.*limit|too many.*connect|resource.*exhaust"

Length of output: 89302


Script:

#!/bin/bash
# Search for usage of DEFAULT_MAX_PARALLEL_PINGS and ping-related code
# Exclude vendor directories to focus on project code

rg -g '!vendor' "DEFAULT_MAX_PARALLEL_PINGS|parallel.*ping" -A 5 -B 5

# Also search for ping configuration and limits
rg -g '!vendor' "ping.*config|max.*ping|ping.*limit" -A 3 -B 3

Length of output: 18983

@jeandemeusy jeandemeusy changed the base branch from master to release/singapore January 16, 2025 15:54
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Jan 16, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
scripts/generate-python-sdk.sh (1)

1-37: Add usage documentation to README.md.

Since this script replaces the auto-generation workflow, please add documentation to README.md explaining:

  • The deprecation of auto-generated Python SDK
  • Prerequisites (swagger-codegen3, hoprd-api-schema)
  • Usage examples with environment variables

Would you like me to help draft the documentation for README.md?

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8dbc8 and 80d5c28.

📒 Files selected for processing (2)
  • README.md (2 hunks)
  • scripts/generate-python-sdk.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
🧰 Additional context used
📓 Learnings (1)
scripts/generate-python-sdk.sh (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6772
File: scripts/generate-python-sdk.sh:1-10
Timestamp: 2025-01-15T16:14:10.492Z
Learning: In shell scripts, make paths configurable by using environment variables with default values using parameter expansion (e.g., `${VAR:-default}`). This allows users to override the default behavior without modifying the script.
🪛 Shellcheck (0.10.0)
scripts/generate-python-sdk.sh

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: tests-smoke-websocket
  • GitHub Check: Docs / Rust docs
  • GitHub Check: tests-unit
  • GitHub Check: tests-unit-nightly
  • GitHub Check: tests-smart-contracts
  • GitHub Check: Linter
🔇 Additional comments (2)
scripts/generate-python-sdk.sh (2)

1-5: LGTM! Well-structured script setup.

The script follows shell scripting best practices with proper error handling and configurable paths.


27-35: LGTM! Proper SDK generation with error handling.

The SDK generation segment is well-implemented with proper error handling and path quoting.

@jeandemeusy jeandemeusy enabled auto-merge (squash) January 16, 2025 17:23
@Teebor-Choka Teebor-Choka changed the title Get rid of the python-sdk auto-generation Remove the python-sdk auto-generation Jan 16, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d91b6a1 and 53581a7.

📒 Files selected for processing (1)
  • scripts/generate-python-sdk.sh (1 hunks)
🧰 Additional context used
📓 Learnings (1)
scripts/generate-python-sdk.sh (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6772
File: scripts/generate-python-sdk.sh:1-10
Timestamp: 2025-01-15T16:14:10.492Z
Learning: In shell scripts, make paths configurable by using environment variables with default values using parameter expansion (e.g., `${VAR:-default}`). This allows users to override the default behavior without modifying the script.
🪛 Shellcheck (0.10.0)
scripts/generate-python-sdk.sh

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests-smoke-websocket
  • GitHub Check: tests-unit-nightly
  • GitHub Check: tests-unit
  • GitHub Check: tests-smart-contracts
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: Docs / Rust docs
  • GitHub Check: Linter
🔇 Additional comments (7)
scripts/generate-python-sdk.sh (7)

1-6: LGTM! Well-structured script setup.

The script follows shell scripting best practices with proper error handling and configurable paths.


7-11: Add validation for hoprd-api-schema command.

While swagger-codegen3 is validated, the script also needs to validate the hoprd-api-schema command that's used later.


20-22: Add safeguards for directory cleanup.

The current directory cleanup is unsafe if TARGET_DIR is empty or unset.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 22-22: Use "${var:?}" to ensure this never expands to /* .

(SC2115)


24-25: Add error handling for OpenAPI spec generation.

The OpenAPI spec generation needs proper error handling and should use the temporary file created earlier.


27-36: LGTM! Proper error handling for SDK generation.

The SDK generation code follows best practices with proper error handling and output redirection.


38-38: LGTM! Clear success message.

The success message clearly indicates where the SDK was generated.


13-15: 🛠️ Refactor suggestion

Improve temporary file handling.

The trap should clean up all temporary files, including the OpenAPI spec file that's created later.

Apply this diff:

 # Use mktemp for secure temporary file creation
 config_file=$(mktemp)
-trap 'rm -f "${config_file}"' EXIT
+spec_file=$(mktemp)
+trap 'rm -f "${config_file}" "${spec_file}"' EXIT

Likely invalid or redundant comment.

@NumberFour8 NumberFour8 disabled auto-merge January 21, 2025 15:52
@jeandemeusy jeandemeusy merged commit 0168013 into release/singapore Jan 21, 2025
28 of 29 checks passed
@jeandemeusy jeandemeusy deleted the jean/remove-references-to-python-sdk branch January 21, 2025 17:15
@coderabbitai coderabbitai bot mentioned this pull request Jan 28, 2025
7 tasks
tolbrino pushed a commit that referenced this pull request Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain Developer and product happiness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants