Skip to content

Commit e9d5781

Browse files
authored
Merge pull request #26 from deepmodeling/master
fetch origin master
2 parents bfe4356 + 4816095 commit e9d5781

File tree

8 files changed

+98
-11
lines changed

8 files changed

+98
-11
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
# If you do not check out your code, Copilot will do this for you.
2727
steps:
2828
- name: Checkout code
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v5
3030

3131
- name: Set up Python
32-
uses: actions/setup-python@v5
32+
uses: actions/setup-python@v6
3333
with:
3434
python-version: "3.11"
3535

.github/workflows/pyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v5
15-
- uses: actions/setup-python@v5
15+
- uses: actions/setup-python@v6
1616
with:
1717
python-version: '3.11'
1818
- run: pip install uv

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v5
2020
- name: Setup python
21-
uses: actions/setup-python@v5
21+
uses: actions/setup-python@v6
2222
with:
2323
python-version: 3.x
2424
architecture: x64

.github/workflows/test-bohrium.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
ref: "${{ github.event.pull_request.merge_commit_sha }}"
2222
- name: Set up Python 3.12
23-
uses: actions/setup-python@v5
23+
uses: actions/setup-python@v6
2424
with:
2525
python-version: '3.12'
2626
cache: 'pip'

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828
platform: macos-latest
2929
include: # So run those legacy versions on Intel CPUs
3030
- python-version: "3.7"
31-
platform: macos-13
31+
platform: macos-15-intel
3232
steps:
3333
- uses: actions/checkout@v5
3434
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v5
35+
uses: actions/setup-python@v6
3636
with:
3737
python-version: ${{ matrix.python-version }}
38-
- uses: astral-sh/setup-uv@v6
38+
- uses: astral-sh/setup-uv@v7
3939
with:
4040
enable-cache: true
4141
cache-dependency-glob: |
File renamed without changes.

dpdispatcher/utils/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def rsync(
138138

139139
cmd = [
140140
"rsync",
141-
# -a: archieve
142-
# -z: compress
143-
"-az",
141+
# -r: recursive, -l: links, -p: perms, -t: times, -D: devices/specials
142+
# -z: compress (exclude -o: owner, -g: group to avoid permission issues)
143+
"-rlptDz",
144144
"-e",
145145
ssh_cmd_str,
146146
"-q",

tests/test_rsync_flags.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import os
2+
import sys
3+
import unittest
4+
from unittest.mock import patch
5+
6+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
7+
__package__ = "tests"
8+
9+
from dpdispatcher.utils.utils import rsync
10+
11+
12+
class TestRsyncFlags(unittest.TestCase):
13+
"""Test rsync function flags to ensure correct options are used."""
14+
15+
@patch("dpdispatcher.utils.utils.run_cmd_with_all_output")
16+
def test_rsync_flags_exclude_owner_group(self, mock_run_cmd):
17+
"""Test that rsync uses flags that exclude owner and group preservation."""
18+
# Mock successful command execution
19+
mock_run_cmd.return_value = (0, "", "")
20+
21+
# Call rsync function
22+
rsync("source_file", "dest_file", key_filename="test_key")
23+
24+
# Verify the command was called
25+
mock_run_cmd.assert_called_once()
26+
27+
# Get the command that was executed
28+
called_cmd = mock_run_cmd.call_args[0][0]
29+
30+
# Verify the command contains the correct flags
31+
self.assertIn("-rlptDz", called_cmd)
32+
self.assertNotIn("-az", called_cmd)
33+
34+
# Verify rsync command structure
35+
self.assertIn("rsync", called_cmd)
36+
self.assertIn("source_file", called_cmd)
37+
self.assertIn("dest_file", called_cmd)
38+
self.assertIn("-e", called_cmd)
39+
self.assertIn("-q", called_cmd)
40+
41+
@patch("dpdispatcher.utils.utils.run_cmd_with_all_output")
42+
def test_rsync_with_proxy_command_flags(self, mock_run_cmd):
43+
"""Test that rsync uses correct flags even with proxy command."""
44+
# Mock successful command execution
45+
mock_run_cmd.return_value = (0, "", "")
46+
47+
# Call rsync function with proxy command
48+
rsync(
49+
"source_file",
50+
"dest_file",
51+
key_filename="test_key",
52+
proxy_command="ssh -W target:22 jump_host",
53+
)
54+
55+
# Verify the command was called
56+
mock_run_cmd.assert_called_once()
57+
58+
# Get the command that was executed
59+
called_cmd = mock_run_cmd.call_args[0][0]
60+
61+
# Verify the command contains the correct flags
62+
self.assertIn("-rlptDz", called_cmd)
63+
self.assertNotIn("-az", called_cmd)
64+
65+
@patch("dpdispatcher.utils.utils.run_cmd_with_all_output")
66+
def test_rsync_error_handling(self, mock_run_cmd):
67+
"""Test that rsync properly handles errors."""
68+
# Mock failed command execution
69+
mock_run_cmd.return_value = (
70+
23,
71+
"",
72+
"rsync: chown failed: Operation not permitted",
73+
)
74+
75+
# Call rsync function and expect RuntimeError
76+
with self.assertRaises(RuntimeError) as context:
77+
rsync("source_file", "dest_file")
78+
79+
# Verify error message contains the command and error
80+
self.assertIn("Failed to run", str(context.exception))
81+
self.assertIn(
82+
"rsync: chown failed: Operation not permitted", str(context.exception)
83+
)
84+
85+
86+
if __name__ == "__main__":
87+
unittest.main()

0 commit comments

Comments
 (0)