feature/SOF-7957 Feat: dielectric Tensor NB#348
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Jupyter notebook that configures and submits a Quantum ESPRESSO dielectric tensor workflow through the Mat3ra API, waits for completion, and visualizes results. The introduction notebook now links to it. ChangesDielectric tensor workflow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant APIClient
participant Material
participant Workflow
participant Job
participant Results
User->>APIClient: Authenticate and select project
APIClient->>Material: Load and save material
APIClient->>Workflow: Configure and save dielectric workflow
APIClient->>Job: Create and submit job
APIClient->>Job: Poll until completion
APIClient->>Results: Retrieve dielectric tensor
Results-->>User: Visualize dielectric tensor
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
🤖 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/dielectric_tensor.ipynb`:
- Around line 513-540: Update the cluster selection before constructing Compute
so it handles an empty clusters list and requires exactly one explicit match for
CLUSTER_NAME, rather than defaulting to clusters[0] or using partial matching.
Fail fast when zero or multiple clusters match, and only create Compute after a
unique cluster has been selected.
- Around line 233-235: Validate the result of client.projects.list before
accessing projects[0] in the project selection flow. If no default project
matches, raise a clear error or require explicit project selection; only derive
project_id and print the project details after confirming a project exists.
🪄 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: e2db4bc9-12a3-4e82-b77e-a075d2785d04
📒 Files selected for processing (2)
other/materials_designer/workflows/Introduction.ipynbother/materials_designer/workflows/dielectric_tensor.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
🧩 Analysis chain
🏁 Script executed:
python3 - <<'PY'
import json, pathlib
nb_path = pathlib.Path('other/materials_designer/workflows/dielectric_tensor.ipynb')
nb = json.loads(nb_path.read_text())
for i, cell in enumerate(nb.get('cells', [])):
src = ''.join(cell.get('source', []))
if 'client.projects.list({"isDefault": True, "owner._id": ACCOUNT_ID})' in src or 'project_id = projects[0]["_id"]' in src:
print(f"\nCELL {i} [{cell.get('cell_type')}]")
print(src)
PYRepository: mat3ra/api-examples
Length of output: 347
Handle empty default-project results.
client.projects.list(...) can return no matches here, and projects[0] will raise IndexError. Raise a clear error or require an explicit project selection before indexing.
🤖 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/dielectric_tensor.ipynb` around lines 233
- 235, Validate the result of client.projects.list before accessing projects[0]
in the project selection flow. If no default project matches, raise a clear
error or require explicit project selection; only derive project_id and print
the project details after confirming a project exists.
| "clusters = client.clusters.list()\n", | ||
| "print(f\"Available clusters: {[c['hostname'] for c in clusters]}\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "36", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### 5.2. Create compute configuration" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "37", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from mat3ra.ide.compute import Compute\n", | ||
| "\n", | ||
| "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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
python3 - <<'PY'
import json, pathlib
path = pathlib.Path('other/materials_designer/workflows/dielectric_tensor.ipynb')
nb = json.loads(path.read_text())
for i, cell in enumerate(nb.get('cells', [])):
src = ''.join(cell.get('source', []))
if 'clusters = client.clusters.list()' in src or 'CLUSTER_NAME' in src or 'Compute(cluster=cluster' in src:
print(f"\n--- cell {i} ({cell.get('cell_type')}) ---")
print(src)
PYRepository: mat3ra/api-examples
Length of output: 1372
Require a single, explicit cluster match before creating Compute. clusters[0] will fail when no clusters are available, and the partial-name lookup can silently select the wrong cluster if multiple entries match. Fail fast unless exactly one cluster matches CLUSTER_NAME, and handle the empty list case.
🤖 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/dielectric_tensor.ipynb` around lines 513
- 540, Update the cluster selection before constructing Compute so it handles an
empty clusters list and requires exactly one explicit match for CLUSTER_NAME,
rather than defaulting to clusters[0] or using partial matching. Fail fast when
zero or multiple clusters match, and only create Compute after a unique cluster
has been selected.
Summary by CodeRabbit