-
Notifications
You must be signed in to change notification settings - Fork 59
Compatible for bohrium OpenAPI sandbox #553
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
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Signed-off-by: zjgemi <liuxin_zijian@163.com>
Signed-off-by: zjgemi <liuxin_zijian@163.com>
Signed-off-by: zjgemi <liuxin_zijian@163.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #553 +/- ##
===========================================
- Coverage 60.40% 47.55% -12.86%
===========================================
Files 39 39
Lines 3905 3909 +4
===========================================
- Hits 2359 1859 -500
- Misses 1546 2050 +504 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughUpdates to OpenAPI context and machine interaction logic. Changes include ensuring directory creation at OpenAPIContext initialization, relaxing job group ID retrieval with safe defaults, renaming an image address parameter, conditionally including remote profile fields, gating log retrieval based on output_log flag, changing job URL retrieval source, and adjusting exit code handling in status mapping. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
dpdispatcher/machines/openapi.py (1)
232-251: Remove unusedexit_codeparameter.The
exit_codeparameter is no longer used in the method body after removing theexit_code != 0check on line 249. This makes the parameter misleading.Apply this diff to remove the unused parameter:
@staticmethod - def map_dp_job_state(status, exit_code, ignore_exit_code=True): + def map_dp_job_state(status, ignore_exit_code=True): if isinstance(status, JobStatus): return status map_dict = {Then update the caller on line 182-186:
job_state = self.map_dp_job_state( dp_job_status, - check_return.get("exitCode", 0), # type: ignore self.ignore_exit_code, )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dpdispatcher/contexts/openapi_context.py(2 hunks)dpdispatcher/machines/openapi.py(4 hunks)
🧰 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/contexts/openapi_context.pydpdispatcher/machines/openapi.py
🧬 Code graph analysis (1)
dpdispatcher/machines/openapi.py (2)
dpdispatcher/contexts/ssh_context.py (1)
get(432-448)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). (3)
- GitHub Check: build (ssh_rsync)
- GitHub Check: build (pbs)
- GitHub Check: build (slurm)
🔇 Additional comments (3)
dpdispatcher/contexts/openapi_context.py (1)
168-174: Good defensive coding, but add type hints.Using
.get()with a default preventsKeyErrorif the key is missing. However, per the coding guidelines, type hints should be added throughout the codebase.Consider adding type annotations to the
jgidattributes where they are declared (e.g., in class definitions).As per coding guidelines
dpdispatcher/machines/openapi.py (2)
188-190: LGTM!Gating log retrieval behind the
output_logflag avoids unnecessary API calls when logs are not needed, improving performance.
132-138: No action needed—the original review comment is incorrect.The code at lines 132-138 is safe and intentional:
Line 138 (
job.job_id): Thejob.job_idattribute is initialized to""(empty string) inJob.__init__(line 752 of submission.py). It is always defined beforedo_submitis called, so there is no risk of uninitialized access. On first submission, it is""; on resubmission, it holds the previous job ID—both are valid.Line 132 (
image_address→image_name): This mapping is intentional. The remote_profile uses the key"image_address"as configuration, while the OpenAPI backend expects the parameter key"image_name". This is confirmed by test cases (test_run_submission_bohrium.py) where different machine types use different key names, and the code correctly bridges them.Likely an incorrect or invalid review comment.
| self.init_remote_root = remote_root | ||
| self.temp_local_root = os.path.abspath(local_root) | ||
| self.remote_profile = remote_profile | ||
| os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate directory creation.
The directory creation on line 75 duplicates the identical call on line 105 within the same __init__ method.
Apply this diff to remove the duplicate:
- os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True)
access_key = (Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In dpdispatcher/contexts/openapi_context.py around line 75, there's a duplicate
call to os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True) that is repeated
later at line 105 in the same __init__ method; remove the earlier call at line
75 so the directory is only created once (keep the existing call at line 105),
and run tests/lint to ensure no other side-effects.
| def _download_job(self, job): | ||
| data = self.job.detail(job.job_id) | ||
| job_url = data["jobFiles"]["outFiles"][0]["url"] # type: ignore | ||
| job_url = data["resultUrl"] # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Use .get() for safer dictionary access.
Direct indexing data["resultUrl"] will raise KeyError if the key is missing. For consistency with the changes in openapi_context.py (lines 168, 174), use .get() with a default value.
Apply this diff:
- job_url = data["resultUrl"] # type: ignore
+ job_url = data.get("resultUrl", "") # type: ignore🤖 Prompt for AI Agents
In dpdispatcher/machines/openapi.py around line 199, the code uses direct
indexing data["resultUrl"] which can raise KeyError if the key is missing;
change it to use data.get("resultUrl", None) (or "" if an empty string is
preferable) to match the safer pattern used in openapi_context.py (lines 168,
174), and preserve any existing type comments (e.g., keep "# type: ignore" if
needed).
|
Is Ready for merge? |
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements