Skip to content

Commit

Permalink
Limit mp_api import
Browse files Browse the repository at this point in the history
Only import `mp_api` - the API to access the materials project when needed. This accelerates the import by 69%
```
import time: self [us] | cumulative | imported package
import time:      2760 |   18156841 | pyiron_atomistics
import time:    123681 |    5643537 | pyiron_atomistics
```
  • Loading branch information
jan-janssen committed Feb 4, 2024
1 parent e81822b commit 6040026
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pyiron_atomistics/atomistics/structure/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
)
from pyiron_atomistics.atomistics.structure.factories.aimsgb import AimsgbFactory
from pyiron_atomistics.atomistics.structure.factories.compound import CompoundFactory
from pyiron_atomistics.atomistics.structure.factories.materialsproject import (
MaterialsProjectFactory,
)
from pyiron_atomistics.atomistics.structure.pyironase import (
publication as publication_ase,
)
Expand Down Expand Up @@ -73,7 +70,7 @@ def __init__(self):
if _ATOMSK_EXISTS:
self._atomsk = AtomskFactory()
self._aimsgb = AimsgbFactory()
self._materialsproject = MaterialsProjectFactory()
self._materialsproject = None
self._compound = CompoundFactory()

@property
Expand Down Expand Up @@ -566,4 +563,9 @@ def high_index_surface(

@property
def materialsproject(self):
if self._materialsproject is None:
from pyiron_atomistics.atomistics.structure.factories.materialsproject import (
MaterialsProjectFactory,
)
self._materialsproject = MaterialsProjectFactory()
return self._materialsproject

0 comments on commit 6040026

Please sign in to comment.