Skip to content
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

Llm extraction schema #32

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ae2bc0d
First version of edit extraction schema
Pepe-Marquez Nov 5, 2024
d900bbc
feat: migrate extraction schema to new version (#27)
kjappelbaum Nov 6, 2024
3bcaac6
Draft of app for the extracted entries
Pepe-Marquez Nov 6, 2024
2e81450
Fixed key in app.
Pepe-Marquez Nov 6, 2024
c383627
Polishing some annotations in the ELN
Pepe-Marquez Nov 6, 2024
d6c5775
Added proper radio ELN component
Pepe-Marquez Nov 7, 2024
14314d5
fix typo in key
Pepe-Marquez Nov 7, 2024
0fd4a67
Changed the enum of the device architecture.
Pepe-Marquez Nov 7, 2024
6a7d6e9
Unsaved fixes in pyproject
Pepe-Marquez Nov 7, 2024
8d85166
Changed atmosphese from section to enum
Pepe-Marquez Nov 8, 2024
8405cb8
Replaced Perovskite composition
Pepe-Marquez Nov 8, 2024
e18a5c7
Organized imports
Pepe-Marquez Nov 8, 2024
b984969
Changed coefficient to str
hampusnasstrom Nov 8, 2024
b379b69
Changed descriptive formula to long form
hampusnasstrom Nov 8, 2024
32a571e
Changed edit quantity for coefficient
hampusnasstrom Nov 8, 2024
ab8cb7b
feat: update schema to match the pydantic model and add field for upd…
kjappelbaum Nov 10, 2024
9dfdf93
chore: update signature of normalizer function
kjappelbaum Nov 10, 2024
0d4ad8d
fix: bug in normalizer
kjappelbaum Nov 10, 2024
c238409
chore: use better code from sourcery
kjappelbaum Nov 10, 2024
43ed10f
Update src/perovskite_solar_cell_database/llm_extraction_schema.py
kjappelbaum Nov 11, 2024
bdea315
Added missing super normalize call and corrected default display unit
hampusnasstrom Nov 13, 2024
80c0d87
Implements all feedback from Jesper
sherjeelshabih Nov 15, 2024
4114360
ruff
sherjeelshabih Nov 15, 2024
a3b3923
Changed empty strings to Unknown and changed solvent ratio to volume_…
hampusnasstrom Nov 15, 2024
90a152a
Ruff
hampusnasstrom Nov 15, 2024
d56b9bb
Remove gas and antisolvent quenching quantities from ProcessingStep
hampusnasstrom Nov 18, 2024
6dba7cd
Fixes label for volume fraction
sherjeelshabih Nov 18, 2024
d144f3f
Adds hints for some appropriate fields that might require a quick check
sherjeelshabih Nov 18, 2024
3b2e581
ruff isort
sherjeelshabih Nov 19, 2024
d6f0be7
Removes bandgap at the top level
sherjeelshabih Nov 22, 2024
aa12679
Adds Evaporation to ProcessingStep Method
sherjeelshabih Nov 25, 2024
ca4221c
Updates the description for ReactionSolution Volume
sherjeelshabih Nov 25, 2024
489e22c
Fixes entry_type
sherjeelshabih Nov 28, 2024
5a74873
Adds mg/mL unit
sherjeelshabih Dec 2, 2024
bbf2608
Ruff
sherjeelshabih Dec 2, 2024
dfabf12
Adds lightsource fields to stability section
sherjeelshabih Dec 6, 2024
4b10f99
Moves up super()normalizer to get EntryType
sherjeelshabih Dec 19, 2024
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
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ perovskite_solar_cell = "perovskite_solar_cell_database:perovskite_solar_cell"
solar_cell_app = "perovskite_solar_cell_database.apps:solar_cells"
perovskite_composition = "perovskite_solar_cell_database:perovskite_composition"
ion_parser = "perovskite_solar_cell_database:ion_parser"
perovskite_ions_app = "perovskite_solar_cell_database.apps:perovskite_ions"
perovskite_ions_app = "perovskite_solar_cell_database.apps:perovskite_ions"
llm_extraction_schema = "perovskite_solar_cell_database:llm_extraction_schema"
llm_extracted_solar_cells = "perovskite_solar_cell_database.apps:llm_extracted_solar_cells"
15 changes: 15 additions & 0 deletions src/perovskite_solar_cell_database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,18 @@ def load(self):
},
},
)


class LLMSchemaExtractionPackageEntryPoint(SchemaPackageEntryPoint):
def load(self):
from perovskite_solar_cell_database.llm_extraction_schema import (
m_package,
)

return m_package


llm_extraction_schema = LLMSchemaExtractionPackageEntryPoint(
name='LLMExtractionSchema',
description='Schema package defined for the perovskite solar cells database LLM extraction.',
)
10 changes: 10 additions & 0 deletions src/perovskite_solar_cell_database/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from nomad.config.models.plugins import AppEntryPoint

from perovskite_solar_cell_database.apps.llm_extracted_solarcells import (
llm_extracted_solar_cells,
)
from perovskite_solar_cell_database.apps.perovskite_ions_app import perovskite_ions_app
from perovskite_solar_cell_database.apps.solar_cell_app import solar_cell_app

Expand All @@ -24,3 +27,10 @@
""",
app=perovskite_ions_app,
)
llm_extracted_solar_cells = AppEntryPoint(
name='LLM Extracted Solar Cells',
description="""
This app allows you to search **LLM extracted solar cell data** within NOMAD.
""",
app=llm_extracted_solar_cells,
)
215 changes: 215 additions & 0 deletions src/perovskite_solar_cell_database/apps/llm_extracted_solarcells.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import yaml
from nomad.config.models.ui import (
App,
Column,
Columns,
FilterMenu,
FilterMenus,
Filters,
)

llm_extracted_solar_cells = App(
# Label of the App
label='LLM Extracted Solar Cells',
# Path used in the URL, must be unique
path='llm-extracted-solar-cells',
# Used to categorize apps in the explore menu
category='LLM strcutured data extraction',
# Brief description used in the app menu
description="""
Explore the LLM extracted solar cells.
""",
# Longer description that can also use markdown
readme="""
Explore LLM extracted solar cells.
""",
# Controls the available search filters. If you want to filter by
# quantities in a schema package, you need to load the schema package
# explicitly here. Note that you can use a glob syntax to load the
# entire package, or just a single schema from a package.
filters=Filters(
include=[
'*#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell',
]
),
# Controls which columns are shown in the results table
columns=Columns(
selected=[
'authors',
# 'results.material.elements',
'entry_type',
'data.review_completed#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell',
'references',
# 'data.lab_id#nomad_material_processing.combinatorial.ThinFilmCombinatorialSample'
],
options={
'entry_type': Column(label='Entry type', align='left'),
'entry_name': Column(label='Name', align='left'),
'entry_create_time': Column(label='Entry time', align='left'),
'authors': Column(label='Authors', align='left'),
'upload_name': Column(label='Upload name', align='left'),
'references': Column(label='References', align='left'),
'data.review_completed#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell': Column(
label='Review completed', align='left'
), # noqa: E501
'data.publication_title#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell': Column(
label='Publication title', align='left'
), # noqa: E501
# 'data.lab_id#nomad_htem_database.schema_packages.htem_package.HTEMLibrary': Column( # noqa: E501
# label='Library ID', align='left'
# ),
'results.material.elements': Column(label='Elements', align='left'),
},
),
# Dictionary of search filters that are always enabled for queries made
# within this app. This is especially important to narrow down the
# results to the wanted subset. Any available search filter can be
# targeted here. This example makes sure that only entries that use
# MySchema are included.
filters_locked={
'entry_type': 'LLMExtractedPerovskiteSolarCell',
},
# Controls the filter menus shown on the left
filter_menus=FilterMenus(
options={
'material': FilterMenu(label='Material', level=0),
'elements': FilterMenu(label='Elements / Formula', level=1, size='xl'),
'eln': FilterMenu(label='Electronic Lab Notebook', level=0),
'custom_quantities': FilterMenu(
label='User Defined Quantities', level=0, size='l'
),
'author': FilterMenu(label='Author / Origin / Dataset', level=0, size='m'),
'metadata': FilterMenu(label='Visibility / IDs / Schema', level=0),
'optimade': FilterMenu(label='Optimade', level=0, size='m'),
}
),
# Controls the default dashboard shown in the search interface
dashboard=yaml.safe_load(
"""
widgets:
- type: terms
scale: linear
quantity: data.journal#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell
layout:
xxl:
minH: 3
minW: 3
h: 9
w: 6
y: 0
x: 6
xl:
minH: 3
minW: 3
h: 5
w: 6
y: 0
x: 6
lg:
minH: 3
minW: 3
h: 9
w: 6
y: 0
x: 6
md:
minH: 3
minW: 3
h: 5
w: 4
y: 0
x: 4
sm:
minH: 3
minW: 3
h: 5
w: 3
y: 0
x: 4
- type: terms
scale: linear
quantity: authors.name
title: Reviewer names
layout:
xxl:
minH: 3
minW: 3
h: 9
w: 6
y: 0
x: 0
xl:
minH: 3
minW: 3
h: 5
w: 6
y: 0
x: 0
lg:
minH: 3
minW: 3
h: 9
w: 6
y: 0
x: 0
md:
minH: 3
minW: 3
h: 5
w: 4
y: 0
x: 0
sm:
minH: 3
minW: 3
h: 5
w: 4
y: 0
x: 0
- type: histogram
autorange: false
nbins: 30
y:
scale: linear
x:
quantity: data.publication_date#perovskite_solar_cell_database.llm_extraction_schema.LLMExtractedPerovskiteSolarCell
layout:
xxl:
minH: 3
minW: 3
h: 3
w: 8
y: 0
x: 12
xl:
minH: 3
minW: 3
h: 3
w: 7
y: 0
x: 12
lg:
minH: 3
minW: 3
h: 3
w: 8
y: 0
x: 12
md:
minH: 3
minW: 3
h: 3
w: 7
y: 0
x: 8
sm:
minH: 3
minW: 3
h: 3
w: 5
y: 0
x: 7

"""
),
)
13 changes: 6 additions & 7 deletions src/perovskite_solar_cell_database/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ class PerovskiteIonComponent(SystemComponent, PerovskiteIonSection):
)
)
coefficient = Quantity(
type=float,
type=str,
description='The stoichiometric coefficient',
a_eln=ELNAnnotation(component=ELNComponentEnum.NumberEditQuantity),
a_eln=ELNAnnotation(component=ELNComponentEnum.StringEditQuantity),
shape=[],
)
system = Quantity(
Expand Down Expand Up @@ -692,7 +692,7 @@ class Impurity(PureSubstanceComponent, PerovskiteChemicalSection):
type=float,
description='The concentration of the additive or impurity.',
a_eln=ELNAnnotation(
component=ELNComponentEnum.NumberEditQuantity, defaultDisplayUnit='mol%'
component=ELNComponentEnum.NumberEditQuantity, defaultDisplayUnit='cm^-3'
),
unit='cm^-3',
shape=[],
Expand Down Expand Up @@ -831,12 +831,10 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
self.short_form += ion.abbreviation
if ion.coefficient is None:
continue
if ion.coefficient == 1:
if ion.coefficient == '1':
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:

  • Replace if statement with if expression (assign-if-exp)
  • Simplify conditional into switch-like form [×2] (switch)

coefficient_str = ''
elif ion.coefficient == int(ion.coefficient):
coefficient_str = str(int(ion.coefficient))
else:
coefficient_str = f'{ion.coefficient:.2}'
coefficient_str = ion.coefficient
self.long_form += f'{ion.abbreviation}{coefficient_str}'
if not isinstance(ion.molecular_formula, str):
continue
Expand All @@ -862,6 +860,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
label='Perovskite Composition',
description='A system describing the chemistry and components of the perovskite.',
system_relation=Relation(type='root'),
chemical_formula_descriptive=self.long_form,
)

parent_system.structural_type = archive.results.material.structural_type
Expand Down
Loading
Loading