feature/SOF-7956 Feat: phonon DOS NB#347
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesPhonon Workflow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Notebook
participant Mat3ra API
participant Standata
participant Jobs API
participant Compute cluster
Notebook->>Mat3ra API: authenticate and select project
Notebook->>Standata: load phonon workflow
Notebook->>Mat3ra API: save material and customized workflow
Notebook->>Jobs API: create and submit job
Jobs API->>Compute cluster: run phonon calculation
Compute cluster-->>Jobs API: report completion
Jobs API-->>Notebook: return dispersion and DOS properties
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
other/materials_designer/workflows/phonon_dos_dispersion.ipynb (1)
411-422: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winFail when requested overrides cannot find their workflow units.
Each lookup silently does nothing when a unit name is missing, so the submitted job may use defaults despite the user explicitly setting grids, paths, or cutoffs. Raise a clear error—or at least warn—for requested overrides.
Example fail-fast handling
def set_grid(subworkflow, unit_name, dimensions, name=None): unit = subworkflow.get_unit_by_name(name=unit_name) - if unit: - unit.add_context(PointsGridDataProvider(dimensions=dimensions, isEdited=True, **({"name": name} if name else {})).get_context_item_data()) - subworkflow.set_unit(unit) + if unit is None: + raise ValueError(f"Workflow unit {unit_name!r} was not found") + unit.add_context(PointsGridDataProvider(dimensions=dimensions, isEdited=True, **({"name": name} if name else {})).get_context_item_data()) + subworkflow.set_unit(unit)Also applies to: 425-458
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@other/materials_designer/workflows/phonon_dos_dispersion.ipynb` around lines 411 - 422, Update set_grid, set_path, and the corresponding cutoff override helpers to detect when get_unit_by_name cannot find the requested workflow unit. For each explicitly requested override, raise a clear error (or emit a warning if that workflow requires non-fatal handling) identifying the missing unit name instead of silently returning; preserve the existing update behavior when the unit is found.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@other/materials_designer/workflows/phonon_dos_dispersion.ipynb`:
- Around line 232-234: Handle an empty result from client.projects.list in the
project-selection flow before accessing projects[0]. When no default project
exists, exit or report the missing project cleanly instead of raising
IndexError; preserve the existing project_id assignment and success message for
accounts with a default project.
- Around line 538-544: Validate the cluster selection before constructing
Compute: handle an empty clusters collection and an unmatched CLUSTER_NAME by
reporting an explicit error and stopping execution. Preserve the existing
hostname match and default-to-first-cluster behavior when a valid cluster is
available, and ensure Compute receives only a confirmed cluster.
---
Nitpick comments:
In `@other/materials_designer/workflows/phonon_dos_dispersion.ipynb`:
- Around line 411-422: Update set_grid, set_path, and the corresponding cutoff
override helpers to detect when get_unit_by_name cannot find the requested
workflow unit. For each explicitly requested override, raise a clear error (or
emit a warning if that workflow requires non-fatal handling) identifying the
missing unit name instead of silently returning; preserve the existing update
behavior when the unit is found.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e41f15d8-c41c-43e8-b892-5ac89a11022f
📒 Files selected for processing (2)
other/materials_designer/workflows/Introduction.ipynbother/materials_designer/workflows/phonon_dos_dispersion.ipynb
| "projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n", | ||
| "project_id = projects[0][\"_id\"]\n", | ||
| "print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Handle accounts without a default project.
projects[0] raises IndexError when the selected account has no default project, stopping the notebook before job creation.
Proposed fix
projects = client.projects.list({"isDefault": True, "owner._id": ACCOUNT_ID})
+if not projects:
+ raise RuntimeError(
+ f"No default project found for account {selected_account.name!r}."
+ )
project_id = projects[0]["_id"]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n", | |
| "project_id = projects[0][\"_id\"]\n", | |
| "print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")" | |
| "projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n", | |
| "if not projects:\n", | |
| " raise RuntimeError(\n", | |
| " f\"No default project found for account {selected_account.name!r}.\"\n", | |
| " )\n", | |
| "project_id = projects[0][\"_id\"]\n", | |
| "print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@other/materials_designer/workflows/phonon_dos_dispersion.ipynb` around lines
232 - 234, Handle an empty result from client.projects.list in the
project-selection flow before accessing projects[0]. When no default project
exists, exit or report the missing project cleanly instead of raising
IndexError; preserve the existing project_id assignment and success message for
accounts with a default project.
| "if CLUSTER_NAME:\n", | ||
| " cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n", | ||
| "else:\n", | ||
| " cluster = clusters[0]\n", | ||
| "\n", | ||
| "compute = Compute(cluster=cluster, queue=QUEUE_NAME, ppn=PPN)\n", | ||
| "print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Validate cluster selection before constructing Compute.
An empty cluster list causes clusters[0] to fail, while an unmatched CLUSTER_NAME passes None into Compute. Report either condition explicitly.
Proposed fix
if CLUSTER_NAME:
cluster = next((c for c in clusters if CLUSTER_NAME in c["hostname"]), None)
+ if cluster is None:
+ raise ValueError(f"No cluster matches {CLUSTER_NAME!r}")
else:
+ if not clusters:
+ raise RuntimeError("No compute clusters are available")
cluster = clusters[0]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "if CLUSTER_NAME:\n", | |
| " cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n", | |
| "else:\n", | |
| " cluster = clusters[0]\n", | |
| "\n", | |
| "compute = Compute(cluster=cluster, queue=QUEUE_NAME, ppn=PPN)\n", | |
| "print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")" | |
| "if CLUSTER_NAME:\n", | |
| " cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n", | |
| " if cluster is None:\n", | |
| " raise ValueError(f\"No cluster matches {CLUSTER_NAME!r}\")\n", | |
| "else:\n", | |
| " if not clusters:\n", | |
| " raise RuntimeError(\"No compute clusters are available\")\n", | |
| " cluster = clusters[0]\n", | |
| "\n", | |
| "compute = Compute(cluster=cluster, queue=QUEUE_NAME, ppn=PPN)\n", | |
| "print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@other/materials_designer/workflows/phonon_dos_dispersion.ipynb` around lines
538 - 544, Validate the cluster selection before constructing Compute: handle an
empty clusters collection and an unmatched CLUSTER_NAME by reporting an explicit
error and stopping execution. Preserve the existing hostname match and
default-to-first-cluster behavior when a valid cluster is available, and ensure
Compute receives only a confirmed cluster.
Summary by CodeRabbit
New Features
Documentation