-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/SOF-7759 Jode Mock NB #254
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
Open
VsevolodX
wants to merge
27
commits into
main
Choose a base branch
from
feature/SOF-7759
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9242fe6
update: bandgap nb prototype (wip)
VsevolodX 74069ac
update: add headers
VsevolodX 35aa49b
update: set pseudo
VsevolodX dfe43aa
update: wf from standata
VsevolodX 975cdbb
update: use CPs
VsevolodX c9bd9ee
Merge branch 'main' into feature/SOF-7759
VsevolodX 8ce197f
update: updates
VsevolodX 13f23e8
update: adjust max version
VsevolodX 8716dd8
update: cleanup
VsevolodX 1f7ff60
update: set model
VsevolodX 21301f5
update: model enums
VsevolodX be40a18
update: add min version
VsevolodX 8564836
update: min version
VsevolodX d3fd230
update: adjust values extraction
VsevolodX d5cb17b
update: use namespace
VsevolodX c030a11
update: adjust assignment
VsevolodX f244e20
chore: adjust
VsevolodX c786934
update: adjustments
VsevolodX d0a4209
update: context
VsevolodX da3c2a9
update: mvp works
VsevolodX 2eadf29
update: adjust
VsevolodX 069c8e2
update: adjust for more features to work
VsevolodX 15d8672
update: move functions to utils
VsevolodX c244989
update: add simple visualizer
VsevolodX c3adf54
update: use default compute
VsevolodX d1004b8
chore: import AX
VsevolodX cd8ce0b
update: fixes to run nb
VsevolodX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
242 changes: 242 additions & 0 deletions
242
other/materials_designer/specific_examples/run_bandgap_workflow.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,242 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Bandgap Workflow Example\n", | ||
| " This notebook demonstrates how to build and run a bandgap workflow for a material.\n", | ||
| "\n", | ||
| "## Process Overview\n", | ||
| "### 1. Set up the environment and parameters.\n", | ||
| "### 2. Log in to get the API token\n", | ||
| "### 3. Load the target material.\n", | ||
| "### 4. Import workflow builder and related analyzers.\n", | ||
| "### 5. Analyze material to get parameters for the workflow configuration.\n", | ||
| "### 6. Create the workflow configuration.\n", | ||
| "### 7. Create a job with material and workflow configuration.\n", | ||
| "### 8. Submit the job to the server.\n", | ||
| "### 9. Monitor the job status and retrieve results.\n", | ||
| "### 10. Display the results." | ||
| ], | ||
| "id": "ed24b225263ae3c3" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 1. Set up the environment and parameters", | ||
| "id": "598da5f8c4f507ec" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 2. Log in to get the API token", | ||
| "id": "51105b005c535ca" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.api import ApiClient\n", | ||
| "# Log in to get the API token\n", | ||
| "auth_config = await ApiClient().login()" | ||
| ], | ||
| "id": "23626cb27f6e7206", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 3. Load the target material", | ||
| "id": "ba816c64f28f6a3d" | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "collapsed": true | ||
| }, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from utils.visualize import visualize_materials as visualize\n", | ||
| "from utils.jupyterlite import load_material_from_folder\n", | ||
| "\n", | ||
| "material = load_material_from_folder(\"/uploads\", \"MoS2_twisted_interface_60_degrees.json\")\n", | ||
| "visualize(material)" | ||
| ], | ||
| "id": "initial_id", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 4. Import workflow builder and related analyzers", | ||
| "id": "f8d7e25a7c9cc2e" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.wode.context_providers import (\n", | ||
| " PointsGridFormDataProvider, # exists - for k-points\n", | ||
| " PlanewaveCutoffsContextProvider, # exists - for cutoffs\n", | ||
| " SmearingContextProvider, # no JS implementation yet\n", | ||
| " BandsContextProvider # no JS implementation yet\n", | ||
| ")\n", | ||
| "\n", | ||
| "\n", | ||
| "kgrid_provider = PointsGridFormDataProvider(material=material)\n", | ||
| "cutoffs_provider = PlanewaveCutoffsContextProvider(material=material)\n", | ||
| "smearing_provider = SmearingContextProvider(material=material)\n", | ||
| "bands_provider = BandsContextProvider(material=material)\n", | ||
| "\n", | ||
| "kpoints = kgrid_provider.get_dimensions() # or calculate_dimensions()\n", | ||
| "cutoff = cutoffs_provider.get_cutoff() # defaultECUTWFC, defaultECUTRHO\n", | ||
| "smearing = smearing_provider.get_smearing()\n", | ||
| "number_of_bands = bands_provider.get_number_of_bands()" | ||
VsevolodX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| "id": "5ead702c417eff62", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 5. Create workflow and set its parameters", | ||
| "id": "9bdd00f870caaeeb" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.standata.workflows import Workflows\n", | ||
| "from mat3ra.wode.workflows import Workflow\n", | ||
| "from mat3ra.wode.pseudopotentials import PseudopotentialEnum\n", | ||
| "\n", | ||
| "workflow_config = Workflows.get_by_name_first_match(\"band_structure\")\n", | ||
| "workflow = Workflow.create(workflow_config)\n", | ||
| "workflow.set_kpoints(kpoints)\n", | ||
| "workflow.set_pseudopotential(PseudopotentialEnum.PAW_HSE) # elements will be set automatically based on the material" | ||
| ], | ||
| "id": "68d43f6c797f2fc4", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 6. Create the compute configuration", | ||
| "id": "1f15e054ddb9a08c" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.ide.compute import ComputeConfiguration, QueueEnum\n", | ||
| "compute_config = ComputeConfiguration(\n", | ||
| " queue = QueueEnum.OR8,\n", | ||
| " nodes = 1,\n", | ||
| " cores = 8,\n", | ||
| ")" | ||
| ], | ||
| "id": "60e880dc581dafe1", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 7. Create the job with material and workflow configuration", | ||
| "id": "cbc16438ad5b0ce0" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "execution_count": null, | ||
| "source": [ | ||
| "from mat3ra.jode.job import create_job\n", | ||
| "job = create_job(workflow=workflow, material=material, compute = compute_config, auth_config=auth_config)" | ||
| ], | ||
| "id": "20b3bf702b6e084c" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 8. Submit the job and monitor the status", | ||
| "id": "8d5740e099512107" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "execution_count": null, | ||
| "source": [ | ||
| "from mat3ra.prode import PropertyEnum\n", | ||
| "job.run()\n", | ||
| "job.wait_for_complete()\n", | ||
| "# job.check_status()\n", | ||
| "# job.get_current_output()" | ||
| ], | ||
| "id": "df29a9065e8b5eae" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 9. Retrieve results", | ||
| "id": "349d46228a98bcd9" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "execution_count": null, | ||
| "source": [ | ||
| "# AFTER Finished\n", | ||
| "# A class from Prode to handle results\n", | ||
| "results = job.get_results(PropertyEnum.BAND_GAP, PropertyEnum.BAND_STRUCTURE)" | ||
| ], | ||
| "id": "ce79fc805900503a" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 10. Display results", | ||
| "id": "6f864b5134b53eac" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "execution_count": null, | ||
| "source": [ | ||
| "# Visual library that can visualize any property defined in Prode\n", | ||
| "from mat3ra.prove import visualize_property\n", | ||
| "visualize_property(results.band_structure)\n", | ||
| "print(results.band_gap)" | ||
| ], | ||
| "id": "978bb38b10c15976" | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 2 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython2", | ||
| "version": "2.7.6" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
VsevolodX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
jq '.metadata.language_info.version' other/materials_designer/specific_examples/run_bandgap_workflow.ipynbRepository: Exabyte-io/api-examples
Length of output: 74
Update Python version and use sync API call or enable async support.
Top-level
awaitis used in the code, but the notebook metadata specifies Python 2.7.6, which does not supportasync/awaitsyntax (introduced in Python 3.5+). Either update the notebook metadata to Python 3.5+, or replace the async call with a synchronous alternative.🤖 Prompt for AI Agents