Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions other/materials_designer/workflows/band_gap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@
"id": "34",
Copy link
Member

@timurbazhirov timurbazhirov Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #8.        ppn=2

Let's keep default


Reply via ReviewNB

"metadata": {},
"source": [
"## 6. Create the compute configuration"
"## 6. Create the compute configuration\n",
"### 6.1. Get list of clusters"
]
},
{
Expand All @@ -475,18 +476,38 @@
"metadata": {},
"outputs": [],
"source": [
"from utils.api import get_cluster_name\n",
"clusters = client.clusters.list()"
]
},
{
"cell_type": "markdown",
"id": "36",
"metadata": {},
"source": [
"### 6.2. Create compute configuration for the job"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37",
"metadata": {},
"outputs": [],
"source": [
"from mat3ra.ide.compute import Compute, QueueName\n",
"\n",
"CLUSTER_NAME = get_cluster_name()\n",
"cluster = clusters[0]\n",
"\n",
"compute = client.jobs.build_compute_config(\n",
" cluster=CLUSTER_NAME\n",
"compute = Compute(\n",
" cluster=cluster,\n",
" queue=QueueName.D,\n",
" ppn=2\n",
")"
]
Comment on lines +497 to 506
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

clusters[0] raises IndexError when no clusters are available.

client.clusters.list() could return an empty list (no clusters provisioned for the account, API error, etc.), causing an unhandled IndexError on the next line.

🛡️ Proposed guard
 cluster = clusters[0]
+if not clusters:
+    raise RuntimeError("No clusters available for this account. Please provision a cluster first.")
+cluster = clusters[0]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@other/materials_designer/workflows/band_gap.ipynb` around lines 517 - 526,
The code assumes at least one cluster exists and directly indexes clusters[0],
which raises IndexError when client.clusters.list() returns an empty list; add a
guard that checks the clusters list (e.g., if not clusters or len(clusters) ==
0) before using clusters[0], and handle the empty case by raising a clear
exception or logging an error and aborting/using a fallback cluster; update the
block around the clusters variable and the Compute(...) instantiation (Compute,
cluster, QueueName.D, ppn) to only construct Compute when a valid cluster is
present.

},
{
"cell_type": "markdown",
"id": "36",
"id": "38",
"metadata": {},
"source": [
"## 7. Create the job with material and workflow configuration\n",
Expand All @@ -496,7 +517,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "37",
"id": "39",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -506,7 +527,7 @@
},
{
"cell_type": "markdown",
"id": "38",
"id": "40",
"metadata": {},
"source": [
"### 7.2. Create job"
Expand All @@ -515,7 +536,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "39",
"id": "41",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -533,7 +554,7 @@
" project_id=project_id,\n",
" prefix=JOB_NAME,\n",
" owner_id=ACCOUNT_ID,\n",
" compute=compute,\n",
" compute=compute.to_dict(),\n",
")\n",
"\n",
"job_dict = job_response[0]\n",
Expand All @@ -545,7 +566,7 @@
},
{
"cell_type": "markdown",
"id": "40",
"id": "42",
"metadata": {},
"source": [
"## 8. Submit the job and monitor the status"
Expand All @@ -554,7 +575,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "41",
"id": "43",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -564,7 +585,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "42",
"id": "44",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -575,7 +596,7 @@
},
{
"cell_type": "markdown",
"id": "43",
"id": "45",
"metadata": {},
"source": [
"## 9. Retrieve results"
Expand All @@ -584,7 +605,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "44",
"id": "46",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -598,7 +619,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "45",
"id": "47",
"metadata": {},
"outputs": [],
"source": []
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies = [
# otherwise on 3.21.1 we encountered negative number of atoms during supercell generation
"ase>=3.25.0",
# Use a valid PEP 508 URL for a local file dependency: file URIs must be absolute and include three slashes
"mat3ra-api-client @ git+https://github.com/Exabyte-io/api-client.git@a329f363893ee96832b5c1a3c514ade28f0839cb",
"mat3ra-api-client @ git+https://github.com/Exabyte-io/api-client.git@141d7dba220f07844e97557dda3ee74087b38c31",
"matplotlib>=3.4.1",
"pandas>=1.5.3",
"pymatgen==2024.4.13",
Expand Down