Skip to content

Conversation

@thangckt
Copy link
Contributor

@thangckt thangckt commented Oct 31, 2025

reopen PR #545 due to branch removed

Summary by CodeRabbit

  • New Features

    • Added configurable retry_count to machine instances (default: 3), persisted through serialization and visible in machine arguments.
  • Bug Fixes / Improvements

    • Improved machine constructors to accept flexible initialization options for various machine types.
  • Tests

    • Updated test suite to validate retry_count configuration and persistence.
  • Chores

    • Project configuration formatting refined.

thangckt and others added 30 commits March 26, 2024 16:25
- add option: "strategy": {"customized_script_header_template_file": ""},

- add option: `sge_pe_name`
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

📝 Walkthrough

Walkthrough

This PR moves retry_count into the base Machine class as a configurable constructor parameter (default 3), persists it in serialization/deserialization, and updates child machine constructors to accept and forward **kwargs so they inherit the centralized retry_count behavior.

Changes

Cohort / File(s) Summary
Core retry_count centralization
dpdispatcher/machine.py
Added retry_count: int = 3 to Machine.__init__, read retry_count in load_from_dict, include "retry_count" in serialize, and add retry_count to arginfo and its docstring.
Cloud / API machines forwarding
dpdispatcher/machines/dp_cloud_server.py, dpdispatcher/machines/openapi.py
Updated Bohrium and OpenAPI constructors to __init__(self, context, **kwargs) and call super().__init__(context=context, **kwargs); removed per-class self.retry_count assignments from remote profile.
Scheduler machines forwarding
dpdispatcher/machines/pbs.py
Reworked SGE (and related scheduler constructors) to accept generic **kwargs and forward them via super().__init__(**kwargs) (constructor signatures changed).
Test updates
tests/test_argcheck.py
Updated expected serialized machine dictionary to include "retry_count": 3 in the Slurm/local context test.
Project config formatting
pyproject.toml
Reformatted several TOML arrays to inline form and added [tool.ruff] line-length = 88; whitespace/comment reflow only.

Sequence Diagram

sequenceDiagram
    autonumber
    actor User
    User->>Machine: __init__(context, retry_count=3)
    Machine->>Machine: set self.retry_count = retry_count

    rect rgb(200,220,240)
      Note over ChildMachine: Old (per-class retry read)
      ChildMachine->>remote_profile: remote_profile.get("retry_count", 3)
    end

    rect rgb(220,240,200)
      Note over NewFlow: New (parent-managed)
      User->>Bohrium: __init__(context, retry_count=X, **kwargs)
      Bohrium->>Machine: super().__init__(context=context, retry_count=X, **kwargs)
      Machine->>Machine: set self.retry_count = X
    end

    User->>Machine: serialize()
    Machine-->>User: {..., "retry_count": 3}

    User->>Machine: load_from_dict({... "retry_count": N ...})
    Machine->>Machine: extract retry_count = N
    Machine->>ChildClass: ChildClass(context=ctx, retry_count=N)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Check dpdispatcher/machine.py changes: constructor default, load_from_dict parsing, serialize output, and arginfo documentation.
  • Verify child constructors (dp_cloud_server.py, openapi.py, pbs.py) correctly forward **kwargs and that no code still reads remote_profile.get("retry_count", ...).
  • Confirm tests (tests/test_argcheck.py) reflect new serialized shape.
  • Validate pyproject.toml remains valid TOML after formatting changes.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a configurable retry_count parameter to control job resubmission behavior across the Machine class and its subclasses.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2336f62 and c49374e.

📒 Files selected for processing (2)
  • dpdispatcher/machines/openapi.py (1 hunks)
  • dpdispatcher/machines/pbs.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dpdispatcher/machines/pbs.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Always add type hints in all Python code
Ensure code remains compatible with Python 3.7+ (avoid syntax/features newer than 3.7)
Use Ruff (via pre-commit) for linting and formatting

Files:

  • dpdispatcher/machines/openapi.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: test (3.12, macos-latest)
  • GitHub Check: test (3.10, macos-latest)
  • GitHub Check: test (3.7, macos-15-intel)
  • GitHub Check: build (slurm)
  • GitHub Check: build (pbs)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dpdispatcher/machine.py (1)

78-100: Add type hint for retry_count parameter.

The retry_count parameter is correctly added to the base Machine class with proper default value, serialization, and documentation. However, it's missing a type hint, which violates the coding guideline: "Always add type hints in all Python code".

Apply this diff to add the type hint:

     def __init__(
         self,
         batch_type=None,
         context_type=None,
         local_root=None,
         remote_root=None,
         remote_profile={},
-        retry_count=3,
+        retry_count: int = 3,
         *,
         context=None,
     ):

Note: While this change addresses the new parameter, consider adding type hints to all parameters in a follow-up refactor for full compliance with coding guidelines.

As per coding guidelines.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4816095 and e9d5781.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • .vscode/settings.json (1 hunks)
  • dpdispatcher/machine.py (6 hunks)
  • dpdispatcher/machines/dp_cloud_server.py (1 hunks)
  • dpdispatcher/machines/openapi.py (1 hunks)
  • dpdispatcher/machines/pbs.py (2 hunks)
  • tests/test_argcheck.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Always add type hints in all Python code
Ensure code remains compatible with Python 3.7+ (avoid syntax/features newer than 3.7)
Use Ruff (via pre-commit) for linting and formatting

Files:

  • dpdispatcher/machine.py
  • tests/test_argcheck.py
  • dpdispatcher/machines/dp_cloud_server.py
  • dpdispatcher/machines/pbs.py
  • dpdispatcher/machines/openapi.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use the unittest framework for tests with coverage reporting

Files:

  • tests/test_argcheck.py
.gitignore

📄 CodeRabbit inference engine (AGENTS.md)

Ensure temporary job execution artifacts remain ignored by version control

Files:

  • .gitignore
🧠 Learnings (1)
📚 Learning: 2025-10-02T19:23:22.456Z
Learnt from: CR
Repo: deepmodeling/dpdispatcher PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T19:23:22.456Z
Learning: Applies to .gitignore : Ensure temporary job execution artifacts remain ignored by version control

Applied to files:

  • .gitignore
🧬 Code graph analysis (1)
dpdispatcher/machine.py (1)
dpdispatcher/utils/dpcloudserver/client.py (1)
  • get (47-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.7, macos-15-intel)
  • GitHub Check: test (3.7, windows-latest)
  • GitHub Check: build (pbs)
  • GitHub Check: build (slurm)
🔇 Additional comments (5)
.gitignore (1)

43-43: LGTM! Selective VSCode settings tracking is appropriate.

The exception to track .vscode/settings.json while ignoring other VSCode files is a good practice for sharing project-specific editor configuration across the team.

tests/test_argcheck.py (1)

30-30: LGTM! Test correctly validates retry_count serialization.

The addition of "retry_count": 3 to the expected serialized output correctly reflects the new retry_count parameter added to the base Machine class with its default value of 3.

dpdispatcher/machine.py (3)

153-154: LGTM! Correct implementation of retry_count deserialization.

The code correctly reads retry_count from the configuration dictionary with a default of 3 and passes it to the machine constructor. This aligns well with the serialization logic at line 167.


167-167: LGTM! Correct implementation of retry_count serialization.

The serialization correctly includes retry_count in the output dictionary, maintaining symmetry with the deserialization logic at lines 153-154.


403-421: LGTM! Proper documentation and argument metadata for retry_count.

The retry_count parameter is well-documented with clear description, appropriate type (int), correct default value (3), and proper integration into the argument schema. This ensures users understand the purpose and usage of this configuration option.

Comment on lines +22 to +23
def __init__(self, context, **kwargs):
super().__init__(context=context, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to comply with coding guidelines.

The refactoring correctly delegates retry_count handling to the base class by accepting and forwarding **kwargs. However, the method signature is missing type hints, which violates the project's coding guideline: "Always add type hints in all Python code".

Apply this diff to add type hints:

-    def __init__(self, context, **kwargs):
+    def __init__(self, context: BaseContext, **kwargs: Any) -> None:
         super().__init__(context=context, **kwargs)

You may need to add the import at the top of the file if not already present:

from typing import Any

As per coding guidelines.

🤖 Prompt for AI Agents
In dpdispatcher/machines/dp_cloud_server.py around lines 22 to 23, the __init__
method lacks type hints; update the signature to include types for context and
kwargs (e.g., context: Any, **kwargs: Any) and ensure you import Any from typing
at the top of the file if not already present; keep the body unchanged and
continue forwarding kwargs to super().__init__(context=context, **kwargs).

Comment on lines +32 to +33
def __init__(self, context, **kwargs):
super().__init__(context=context, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to comply with coding guidelines.

The refactoring correctly delegates retry_count handling to the base class. However, type hints are missing from the method signature, violating the coding guideline: "Always add type hints in all Python code".

Apply this diff to add type hints:

-    def __init__(self, context, **kwargs):
+    def __init__(self, context: BaseContext, **kwargs: Any) -> None:
         super().__init__(context=context, **kwargs)

Add the import if not already present:

from typing import Any

As per coding guidelines.

🤖 Prompt for AI Agents
In dpdispatcher/machines/openapi.py around lines 32 to 33, the __init__ method
lacks type hints; add "from typing import Any" to the imports if missing, and
update the signature to include types (e.g., def __init__(self, context: Any,
**kwargs: Any) -> None:) so the method and its kwargs are properly annotated
while preserving the existing super() call.

Comment on lines 20 to 21
def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to comply with coding guidelines.

The PBS constructor correctly forwards keyword arguments to the base class. However, type hints are missing, violating the coding guideline: "Always add type hints in all Python code".

Apply this diff:

-    def __init__(self, **kwargs):
+    def __init__(self, **kwargs: Any) -> None:
         super().__init__(**kwargs)

Add the import at the top of the file if not already present:

from typing import Any

As per coding guidelines.

🤖 Prompt for AI Agents
In dpdispatcher/machines/pbs.py around lines 20 to 21, the __init__ method lacks
type hints; add "from typing import Any" at the top of the file (if missing) and
change the constructor signature to include types (for example: def
__init__(self, **kwargs: Any) -> None:) while leaving the super() call intact so
keyword args are forwarded.

Comment on lines +194 to +195
def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to comply with coding guidelines.

The SGE constructor correctly forwards keyword arguments to the base class. However, type hints are missing, violating the coding guideline: "Always add type hints in all Python code".

Apply this diff:

-    def __init__(self, **kwargs):
+    def __init__(self, **kwargs: Any) -> None:
         super().__init__(**kwargs)

Ensure the Any type is imported at the top of the file (should be added only once if not present):

from typing import Any

As per coding guidelines.

🤖 Prompt for AI Agents
In dpdispatcher/machines/pbs.py around lines 194 to 195, the __init__ method
lacks type hints; update its signature to include typed kwargs (e.g., def
__init__(self, **kwargs: Any) -> None:) and ensure you add from typing import
Any at the top of the file if it is not already imported; keep the call to
super().__init__(**kwargs) unchanged.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.64%. Comparing base (0b5dfd1) to head (c49374e).

Files with missing lines Patch % Lines
dpdispatcher/machines/openapi.py 50.00% 1 Missing ⚠️
dpdispatcher/machines/pbs.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #554       +/-   ##
===========================================
- Coverage   60.38%   47.64%   -12.75%     
===========================================
  Files          39       39               
  Lines        3908     3912        +4     
===========================================
- Hits         2360     1864      -496     
- Misses       1548     2048      +500     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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)
pyproject.toml (1)

87-94: Ruff configuration properly aligned with project standards.

The selection of rule categories (E, F, D, UP, I) and line-length = 88 align well with the existing black/isort configuration. However, the [tool.ruff] section placement at line 119 (after [tool.ruff.lint.pydocstyle]) is valid TOML but unconventional.

Consider consolidating ruff configuration by moving the [tool.ruff] section closer to the start of ruff-related settings (before [tool.ruff.lint]) for better readability, though the current structure is functionally valid:

-[tool.ruff.lint]
+[tool.ruff]
+line-length = 88
+
+[tool.ruff.lint]
 select = [

This keeps all ruff configuration together hierarchically.

Also applies to: 119-120

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9d5781 and 2336f62.

📒 Files selected for processing (1)
  • pyproject.toml (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pyproject.toml

📄 CodeRabbit inference engine (AGENTS.md)

pyproject.toml: Use setuptools as the build system configured via pyproject.toml
Configure and run Pyright for static type analysis via settings in pyproject.toml

Files:

  • pyproject.toml
🧠 Learnings (2)
📚 Learning: 2025-10-02T19:23:22.456Z
Learnt from: CR
Repo: deepmodeling/dpdispatcher PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T19:23:22.456Z
Learning: Applies to examples/dpdisp_run.py : Keep the example script examples/dpdisp_run.py as a runnable example using PEP 723 script metadata

Applied to files:

  • pyproject.toml
📚 Learning: 2025-10-02T19:23:22.456Z
Learnt from: CR
Repo: deepmodeling/dpdispatcher PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T19:23:22.456Z
Learning: Applies to **/*.py : Use Ruff (via pre-commit) for linting and formatting

Applied to files:

  • pyproject.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.7, macos-15-intel)
  • GitHub Check: build (slurm)
  • GitHub Check: build (ssh_rsync)
  • GitHub Check: build (pbs)
🔇 Additional comments (2)
pyproject.toml (2)

9-9: TOML inline array formatting looks good.

The reformatting from multi-line to inline arrays for authors, keywords, and optional dependencies maintains readability while improving compactness.

Also applies to: 33-41, 68-69


87-120: Ruff configuration addition aligns with project guidelines.

The addition of ruff linting rules and line-length configuration supports the learning guideline to "Use Ruff (via pre-commit) for linting and formatting." The configuration is well-structured and complements the existing Pyright type-checking setup (lines 77-82).

njzjz added a commit to njzjz/dpdispatcher that referenced this pull request Nov 4, 2025
@thangckt thangckt requested a review from njzjz November 15, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants