diff --git a/config.yml b/config.yml index bdecf3c9..8d1b7961 100644 --- a/config.yml +++ b/config.yml @@ -70,3 +70,4 @@ notebooks: - requests - mat3ra-ade - mat3ra-wode + - mat3ra-prode diff --git a/other/materials_designer/workflows/band_gap.ipynb b/other/materials_designer/workflows/band_gap.ipynb index 461ef434..a1f2489a 100644 --- a/other/materials_designer/workflows/band_gap.ipynb +++ b/other/materials_designer/workflows/band_gap.ipynb @@ -538,7 +538,7 @@ "\n", "job_dict = job_response[0]\n", "job = dict_to_namespace(job_dict)\n", - "\n", + "job_id = job._id\n", "print(\"✅ Job created successfully!\")\n", "display_JSON(job_response)" ] @@ -558,7 +558,7 @@ "metadata": {}, "outputs": [], "source": [ - "client.jobs.submit(job._id)" + "client.jobs.submit(job_id)" ] }, { @@ -570,7 +570,7 @@ "source": [ "from utils.api import wait_for_jobs_to_finish\n", "\n", - "wait_for_jobs_to_finish(client.jobs, [job._id], poll_interval=POLL_INTERVAL)" + "wait_for_jobs_to_finish(client.jobs, [job_id], poll_interval=POLL_INTERVAL)" ] }, { @@ -588,25 +588,11 @@ "metadata": {}, "outputs": [], "source": [ - "from utils.visualize import render_prove\n", - "\n", - "property_endpoints = client.properties\n", - "\n", - "workflow = Workflow.create(job_dict[\"workflow\"])\n", - "unit_flowchart_id = workflow.subworkflows[BAND_GAP_SWF_INDEX].get_unit_by_name(name=\"pw_nscf\").flowchart_id\n", - "band_gap_direct = property_endpoints.get_direct_band_gap(job._id, unit_flowchart_id)\n", - "band_gap_indirect = property_endpoints.get_indirect_band_gap(job._id, unit_flowchart_id)\n", - "\n", - "# Minimal ProDe-like property JSON for Prove MVP\n", - "band_gaps_property = {\n", - " \"name\": \"band_gaps\",\n", - " \"values\": [\n", - " {\"type\": \"direct\", \"value\": float(band_gap_direct), \"units\": \"eV\"},\n", - " {\"type\": \"indirect\", \"value\": float(band_gap_indirect), \"units\": \"eV\"},\n", - " ],\n", - "}\n", + "from utils.visualize import visualize_properties\n", + "from mat3ra.prode import PropertyName\n", "\n", - "render_prove([band_gaps_property], title=\"Band Gaps\")" + "band_gaps_property = client.properties.get_for_job(job_id, property_name=PropertyName.non_scalar.band_gaps)\n", + "visualize_properties(band_gaps_property, title=\"Band Gaps\")" ] }, { diff --git a/pyproject.toml b/pyproject.toml index 0bb1b00e..6d71bdfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,13 +8,15 @@ dependencies = [ # ase >=3.25.0 is required for supercell to be generated, # otherwise on 3.21.1 we encountered negative number of atoms during supercell generation "ase>=3.25.0", - "mat3ra-api-client>=2026.1.23.post0", + # 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", "matplotlib>=3.4.1", "pandas>=1.5.3", "pymatgen==2024.4.13", "mat3ra-made>=2025.8.13.post0", "mat3ra-utils>=2024.6.11.post0", - "mat3ra-wode" + "mat3ra-wode", + "mat3ra-prode @ git+https://github.com/Exabyte-io/prode.git@5b2e02ddbaf5dd473f0acaf1e1d76ddadc6bb184" ] [project.optional-dependencies] diff --git a/utils/visualize.py b/utils/visualize.py index c00d4913..a4082030 100644 --- a/utils/visualize.py +++ b/utils/visualize.py @@ -390,9 +390,9 @@ def visualize_workflow(workflow, level: int = 2) -> None: display_JSON(workflow_config, level=level) -def render_prove(results, width=900, title="Properties", extra_config=None): +def visualize_properties(results, width=900, title="Properties", extra_config=None): """ - Render Prove results viewer in a notebook (Jupyter / Colab / Pyodide). + Visualize properties using a Prove viewer. Args: results: List[dict] of property JSON objects (or a single dict). @@ -403,6 +403,9 @@ def render_prove(results, width=900, title="Properties", extra_config=None): if isinstance(results, dict): results = [results] + # Only keep the properties we can display + results = [r for r in results if "value" in r or "values" in r] + timestamp = time.time() div_id = f"prove-{timestamp}" results_json = json.dumps(results)