Skip to content

Commit

Permalink
Merge pull request #5 from FAIRmat-NFDI/3-improve-step-data-model
Browse files Browse the repository at this point in the history
3 improve step data model
  • Loading branch information
lauri-codes authored Nov 6, 2024
2 parents 4a22454 + 9c6bf79 commit 95b3e9e
Show file tree
Hide file tree
Showing 11 changed files with 2,557 additions and 1,133 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.12
- name: Install dependencies
run: |
pip install --upgrade pip
Expand All @@ -27,10 +27,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.12
- name: Build the package
run: |
pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NOMAD plugin for driving experiments/simulations using bayesian optimization

----

This `nomad`_ plugin was generated with `Cookiecutter`_ along with `@nomad`_'s `cookiecutter-nomad-plugin`_ template.
This `nomad` plugin was generated with `Cookiecutter` along with `@nomad`'s `cookiecutter-nomad-plugin` template.


### Install
Expand Down Expand Up @@ -70,7 +70,7 @@ on the [PyPI documentation](https://packaging.python.org/en/latest/tutorials/pac

### Documentation on Github pages

To deploy documentation on Github pages, make sure to [enable GitHub pages via the repo settings](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch).
To deploy documentation on Github pages, make sure to [enable GitHub pages via the repo settings](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch).

To view the documentation locally, install the documentation related packages using:

Expand All @@ -85,7 +85,7 @@ mkdocs serve

### Template update

We use cruft to update the project based on template changes. A `cruft-update.yml` is included in Github workflows to automatically check for updates and create pull requests to apply updates. Follow the [instructions](https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/) on how to enable Github Actions to create pull requests.
We use cruft to update the project based on template changes. A `cruft-update.yml` is included in Github workflows to automatically check for updates and create pull requests to apply updates. Follow the [instructions](https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/) on how to enable Github Actions to create pull requests.

To run the check for updates locally, follow the instructions on [`cruft` website](https://cruft.github.io/cruft/#updating-a-project).

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ maintainers = [
license = { file = "LICENSE" }
dependencies = [
"nomad-lab>=1.3.0",
"baybe",
"baybe>=0.11.2",
"structlog",
]

Expand Down Expand Up @@ -67,7 +67,6 @@ exclude = [
line-length = 88
indent-width = 4


[tool.ruff.lint]
select = [
# pycodestyle
Expand Down
50 changes: 6 additions & 44 deletions src/nomad_bayesian_optimization/apps/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@
search_quantities=SearchQuantities(include=[f'*#{schema_name}']),
columns=[
Column(quantity='entry_create_time', selected=True),
Column(quantity=f'data.optimization.finished#{schema_name}', selected=True),
Column(quantity=f'data.optimization.status#{schema_name}', selected=True),
Column(quantity=f'data.status#{schema_name}', selected=True),
Column(quantity=f'data.objective.target.name#{schema_name}', selected=True),
Column(
quantity=f'data.searchspace.continuous.parameters[*].name#{schema_name}',
selected=True,
),
Column(
quantity=f'data.steps[*].sources[*].materials[*].substance_name#{schema_name}',
quantity=f'data.parameters[*].name#{schema_name}',
selected=True,
),
],
menu=Menu(
items=[
MenuItemTerms(
quantity=f'data.optimization.status#{schema_name}',
quantity=f'data.status#{schema_name}',
show_input=False,
),
Menu(
Expand Down Expand Up @@ -67,33 +62,10 @@
),
Menu(
size='xs',
title='Search space',
title='Parameters',
items=[
Menu(
title='Discrete',
items=[
MenuItemTerms(
quantity=f'data.searchspace.discrete.parameters.name#{schema_name}',
)
],
),
Menu(
title='Continuous',
items=[
MenuItemTerms(
quantity=f'data.searchspace.continuous.parameters.name#{schema_name}',
),
MenuItemHistogram(
x=Axis(
search_quantity=f'data.searchspace.continuous.parameters.bounds.lower#{schema_name}'
)
),
MenuItemHistogram(
x=Axis(
search_quantity=f'data.searchspace.continuous.parameters.bounds.upper#{schema_name}'
)
),
],
MenuItemTerms(
quantity=f'data.parameters.name#{schema_name}',
),
],
),
Expand Down Expand Up @@ -124,16 +96,6 @@
),
],
),
Menu(
title='Optimization',
items=[
MenuItemHistogram(
x=Axis(
search_quantity=f'data.optimization.n_steps#{schema_name}'
)
)
],
),
]
),
filters_locked={'section_defs.definition_qualified_name': [schema_name]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/lauri/repositories/nomad-FAIR/nomad/datamodel/metainfo/simulation/__init__.py:52: DeprecationWarning: Usage of Environment is deprecated and will be removed in the future.\n",
" m_env = Environment()\n"
]
}
],
"source": [
"\n",
"import numpy as np\n",
"\n",
"from nomad_bayesian_optimization.schema_packages.experiments import CVDExperiment\n",
Expand Down Expand Up @@ -190,7 +198,20 @@
"metadata": {
"id": "4PSMvrp-sdDL"
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"New recommendation:\n",
" substrate gas_flow_rate temperature\n",
"0 Gallium nitride 0.388846 466.73735\n",
"Start testing recommendation...\n",
"Testing finished, refractive_index: 1.597450224449405\n",
"Optimization finished!\n"
]
}
],
"source": [
"import json\n",
"\n",
Expand Down Expand Up @@ -222,12 +243,19 @@
"\n",
"# At the end of the run, lets store the whole optimization run into an entry\n",
"archive = EntryArchive()\n",
"bopt = BayesianOptimization.from_baybe_campaign(campaign)\n",
"bopt = BayesianOptimization.from_baybe(campaign)\n",
"archive.data = bopt\n",
"bopt.normalize(archive, None)\n",
"with open('example.archive.json', 'w') as fout:\n",
" json.dump(archive.m_to_dict(), fout, indent=2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 95b3e9e

Please sign in to comment.