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

Adds recursive func to delete all 'Unknown' enums #33

Open
wants to merge 28 commits into
base: llm-extraction-schema
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a7e4b9e
First version of edit extraction schema
Pepe-Marquez Nov 5, 2024
2e7e4d1
feat: migrate extraction schema to new version (#27)
kjappelbaum Nov 6, 2024
6abfcf4
Draft of app for the extracted entries
Pepe-Marquez Nov 6, 2024
33d025c
Fixed key in app.
Pepe-Marquez Nov 6, 2024
7f3ff50
Polishing some annotations in the ELN
Pepe-Marquez Nov 6, 2024
0d4d2d7
Added proper radio ELN component
Pepe-Marquez Nov 7, 2024
73c6112
fix typo in key
Pepe-Marquez Nov 7, 2024
5c306f5
Changed the enum of the device architecture.
Pepe-Marquez Nov 7, 2024
ef6ed19
Unsaved fixes in pyproject
Pepe-Marquez Nov 7, 2024
d538def
Changed atmosphese from section to enum
Pepe-Marquez Nov 8, 2024
5260813
Replaced Perovskite composition
Pepe-Marquez Nov 8, 2024
b085255
Organized imports
Pepe-Marquez Nov 8, 2024
da73e46
Added app for the extracted solar cells review
Pepe-Marquez Nov 8, 2024
668e98f
Changed coefficient to str
hampusnasstrom Nov 8, 2024
6e7fb6b
Changed descriptive formula to long form
hampusnasstrom Nov 8, 2024
feef2ea
Changed edit quantity for coefficient
hampusnasstrom Nov 8, 2024
8e986bd
feat: update schema to match the pydantic model and add field for upd…
kjappelbaum Nov 10, 2024
3a65614
chore: update signature of normalizer function
kjappelbaum Nov 10, 2024
54ad88d
fix: bug in normalizer
kjappelbaum Nov 10, 2024
fa208a7
chore: use better code from sourcery
kjappelbaum Nov 10, 2024
b893b2f
Update src/perovskite_solar_cell_database/llm_extraction_schema.py
kjappelbaum Nov 11, 2024
61d221f
Merge pull request #30 from kjappelbaum/20241110-layer-stack-updates
hampusnasstrom Nov 11, 2024
a009295
Added missing super normalize call and corrected default display unit
hampusnasstrom Nov 13, 2024
7f02142
Implements all feedback from Jesper
sherjeelshabih Nov 15, 2024
b894fd8
ruff
sherjeelshabih Nov 15, 2024
a1b512f
Changed empty strings to Unknown and changed solvent ratio to volume_…
hampusnasstrom Nov 15, 2024
dc2f410
Ruff
hampusnasstrom Nov 15, 2024
8082c52
Adds recursive func to delete all 'Unknown' enums
sherjeelshabih Nov 15, 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 @@ -134,4 +134,6 @@ where = ["src"]
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"
ion_parser = "perovskite_solar_cell_database:ion_parser"
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.',
)
11 changes: 11 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.solar_cell_app import solar_cell_app

solar_cells = AppEntryPoint(
Expand All @@ -12,3 +15,11 @@
""",
app=solar_cell_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':
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