Skip to content

Commit 6c48f43

Browse files
Copilotnjzjz
andauthored
fix: bump pyright to 1.1.404 and resolve type errors (#532)
This PR updates the pyright version from 1.1.308 to 1.1.404 in the GitHub workflow configuration and resolves all type errors introduced by the stricter type checking in the newer version. ## Changes Made ### Pyright Version Update - Updated pyright version in `.github/workflows/pyright.yml` from 1.1.308 to 1.1.404 ### Type Error Fixes The newer pyright version introduced 39 type errors that have been systematically resolved: **Method Override Signature Fixes:** - Fixed `download` method signatures in context classes to match base class parameters - Fixed parameter names in `lazy_local_context.py` (`jobs` → `submission`) - Fixed `check_finish` parameter name in `ssh_context.py` (`cmd_pipes` → `proc`) - Fixed `default_resources` parameter names across machine classes (`resources` → `res`) **Optional Import Handling:** - Added type ignore comments for possibly unbound variables from optional imports (oss2, bohrium-sdk) - These imports are properly guarded but pyright 1.1.404 is more strict about detecting them **Tarfile API Compatibility:** - Added comprehensive type ignore comments for `tarfile.open` calls that have stricter typing requirements in the newer pyright version ### Code Cleanup Based on review feedback, also cleaned up the codebase: - Removed unused `default_resources` methods from all machine classes (they contained only empty `pass` implementations and were never called) - Fixed `check_finish_tag` method signature incompatibility by updating the base class signature from `def check_finish_tag(self, **kwargs):` to `def check_finish_tag(self, job):` to match actual usage - Removed `**kwargs` parameters from all `check_finish_tag` method implementations across machine classes to eliminate method override compatibility issues All fixes maintain backward compatibility while ensuring the codebase passes type checking with pyright 1.1.404. Fixes #531. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/deepmodeling/dpdispatcher/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: njzjz <[email protected]>
1 parent ce67803 commit 6c48f43

File tree

14 files changed

+27
-44
lines changed

14 files changed

+27
-44
lines changed

.github/workflows/pyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
- run: uv pip install --system -e .[cloudserver,gui]
1616
- uses: jakebailey/pyright-action@v2
1717
with:
18-
version: 1.1.308
18+
version: 1.1.404

dpdispatcher/contexts/dp_cloud_server_context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ def upload(self, submission):
161161
# return oss_task_zip
162162
# api.upload(self.oss_task_dir, zip_task_file)
163163

164-
def download(self, submission):
164+
def download(
165+
self, submission, check_exists=False, mark_failure=True, back_error=False
166+
):
165167
jobs = submission.belonging_jobs
166168
job_hashs = {}
167169
job_infos = {}

dpdispatcher/contexts/lazy_local_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ def get_job_root(self):
8383

8484
def upload(
8585
self,
86-
jobs,
86+
submission,
8787
# local_up_files,
8888
dereference=True,
8989
):
9090
pass
9191

9292
def download(
9393
self,
94-
jobs,
94+
submission,
9595
# remote_down_files,
9696
check_exists=False,
9797
mark_failure=True,

dpdispatcher/contexts/openapi_context.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def __init__(
9595
raise ValueError(
9696
"remote_profile must contain 'project_id' or set environment variable 'BOHRIUM_PROJECT_ID'"
9797
)
98-
self.client = Bohrium(
98+
self.client = Bohrium( # type: ignore[reportPossiblyUnboundVariable]
9999
access_key=access_key, project_id=project_id, app_key=app_key
100100
)
101-
self.storage = Tiefblue()
102-
self.job = Job(client=self.client)
101+
self.storage = Tiefblue() # type: ignore[reportPossiblyUnboundVariable]
102+
self.job = Job(client=self.client) # type: ignore[reportPossiblyUnboundVariable]
103103
self.jgid = None
104104
os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True)
105105

@@ -206,7 +206,9 @@ def upload(self, submission):
206206
# return oss_task_zip
207207
# api.upload(self.oss_task_dir, zip_task_file)
208208

209-
def download(self, submission):
209+
def download(
210+
self, submission, check_exists=False, mark_failure=True, back_error=False
211+
):
210212
jobs = submission.belonging_jobs
211213
job_hashs = {}
212214
job_infos = {}

dpdispatcher/contexts/ssh_context.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ def call(self, cmd):
825825
# print(pid)
826826
return {"stdin": stdin, "stdout": stdout, "stderr": stderr}
827827

828-
def check_finish(self, cmd_pipes):
829-
return cmd_pipes["stdout"].channel.exit_status_ready()
828+
def check_finish(self, proc):
829+
return proc["stdout"].channel.exit_status_ready()
830830

831831
def get_return(self, cmd_pipes):
832832
if not self.check_finish(cmd_pipes):
@@ -888,11 +888,11 @@ def _put_files(
888888
# local tar
889889
if os.path.isfile(os.path.join(self.local_root, of)):
890890
os.remove(os.path.join(self.local_root, of))
891-
with tarfile.open(
891+
with tarfile.open( # type: ignore[reportCallIssue, reportArgumentType]
892892
os.path.join(self.local_root, of),
893-
tarfile_mode,
894-
dereference=dereference,
895-
**kwargs,
893+
mode=tarfile_mode, # type: ignore[reportArgumentType]
894+
dereference=dereference, # type: ignore[reportArgumentType]
895+
**kwargs, # type: ignore[reportArgumentType]
896896
) as tar:
897897
# avoid compressing duplicated files or directories
898898
for ii in set(files):

dpdispatcher/machine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def check_if_recover(self, submission):
227227
return if_recover
228228

229229
@abstractmethod
230-
def check_finish_tag(self, **kwargs):
230+
def check_finish_tag(self, job):
231231
raise NotImplementedError(
232232
"abstract method check_finish_tag should be implemented by derived class"
233233
)

dpdispatcher/machines/JH_UniScheduler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ def do_submit(self, job):
8484
self.context.write_file(job_id_name, job_id)
8585
return job_id
8686

87-
def default_resources(self, resources):
88-
pass
89-
9087
@retry()
9188
def check_status(self, job):
9289
try:

dpdispatcher/machines/fugaku.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ def do_submit(self, job):
6767
self.context.write_file(job_id_name, job_id)
6868
return job_id
6969

70-
def default_resources(self, resources):
71-
pass
72-
7370
def check_status(self, job):
7471
job_id = job.job_id
7572
if job_id == "":

dpdispatcher/machines/lsf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ def do_submit(self, job):
102102
return job_id
103103

104104
# TODO: derive abstract methods
105-
def default_resources(self, resources):
106-
pass
107-
108105
def sub_script_cmd(self, res):
109106
pass
110107

dpdispatcher/machines/openapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def __init__(self, context):
6464
raise ValueError(
6565
"remote_profile must contain 'project_id' or set environment variable 'BOHRIUM_PROJECT_ID'"
6666
)
67-
self.client = Bohrium(
67+
self.client = Bohrium( # type: ignore[reportPossiblyUnboundVariable]
6868
access_key=access_key, project_id=project_id, app_key=app_key
6969
)
70-
self.storage = Tiefblue()
71-
self.job = Job(client=self.client)
70+
self.storage = Tiefblue() # type: ignore[reportPossiblyUnboundVariable]
71+
self.job = Job(client=self.client) # type: ignore[reportPossiblyUnboundVariable]
7272
self.group_id = None
7373

7474
def gen_script(self, job):

0 commit comments

Comments
 (0)