schnetpack icon indicating copy to clipboard operation
schnetpack copied to clipboard

Issue instantiating new Materials Project dataset

Open MrRobot2211 opened this issue 6 months ago • 1 comments

Hello, I am trying to instantiate a new Materials Project database

matprojdata = MaterialsProject('../matproj5/mp.db',apikey = "xJ13JFnTaMcEVGhmapOBLIUAucw1nEUK", batch_size=256 )
matprojdata.prepare_data()

I get the following issue :

 ---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
Cell In[4], line 1
----> 1 matprojdata.prepare_data()

File ~/schnetpack/src/schnetpack/datasets/materials_project.py:128, in MaterialsProject.prepare_data(self)
    120 if not os.path.exists(self.datapath):
    121     property_unit_dict = {
    122         MaterialsProject.EformationPerAtom: "eV",
    123         MaterialsProject.EPerAtom: "eV",
    124         MaterialsProject.BandGap: "eV",
    125         MaterialsProject.TotalMagnetization: "None",
    126     }
--> 128     dataset = create_dataset(
    129         datapath=self.datapath,
    130         format=self.format,
    131         distance_unit="Ang",
    132         property_unit_dict=property_unit_dict,
    133     )
    134     if len(self.apikey) == 16:
    135         self._download_data_legacy(dataset)

File ~/schnetpack/src/schnetpack/data/atoms.py:576, in create_dataset(datapath, format, distance_unit, property_unit_dict, **kwargs)
    561 """
    562 Create a new atoms dataset.
    563 
   (...)    573 
    574 """
    575 if format is AtomsDataFormat.ASE:
--> 576     dataset = ASEAtomsData.create(
    577         datapath=datapath,
    578         distance_unit=distance_unit,
    579         property_unit_dict=property_unit_dict,
    580         **kwargs,
    581     )
    582 else:
    583     raise AtomsDataError(f"Unknown format: {format}")

File ~/schnetpack/src/schnetpack/data/atoms.py:439, in ASEAtomsData.create(datapath, distance_unit, property_unit_dict, atomrefs, **kwargs)
    435     raise AtomsDataError(f"Dataset already exists: {datapath}")
    437 atomrefs = atomrefs or {}
--> 439 with connect(datapath) as conn:
    440     conn.metadata = {
    441         "_property_unit_dict": property_unit_dict,
    442         "_distance_unit": distance_unit,
    443         "atomrefs": atomrefs,
    444     }
    446 return ASEAtomsData(datapath, **kwargs)

File ~/anaconda3/envs/schnet5/lib/python3.12/site-packages/ase/db/sqlite.py:188, in SQLite3Database.__enter__(self)
    186 assert self.connection is None
    187 self.change_count = 0
--> 188 self.connection = self._connect()
    189 return self

File ~/anaconda3/envs/schnet5/lib/python3.12/site-packages/ase/db/sqlite.py:183, in SQLite3Database._connect(self)
    182 def _connect(self):
--> 183     return sqlite3.connect(self.filename, timeout=20)

OperationalError: unable to open database file ```

It looks like the dataset should be instantiated before calling the connection.

Thank you for your help.

MrRobot2211 avatar Jun 25 '25 02:06 MrRobot2211

Hallo, could you please tell me which version of schnetpack you are using (pypi version or git branch and commit?) Best regards, Jonas

jnsLs avatar Jun 25 '25 12:06 jnsLs

This is the current develop version. The latest pypi version is not compatible with latest Material Projects API

On Wed, Jun 25, 2025, 08:43 Jonas Lederer @.***> wrote:

jnsLs left a comment (atomistic-machine-learning/schnetpack#742) https://github.com/atomistic-machine-learning/schnetpack/issues/742#issuecomment-3004635230

Hallo, could you please tell me which version of schnetpack you are using (pypi version or git branch and commit?) Best regards, Jonas

— Reply to this email directly, view it on GitHub https://github.com/atomistic-machine-learning/schnetpack/issues/742#issuecomment-3004635230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTMVKCAFGSPCMASP7M76IT3FKKNPAVCNFSM6AAAAACAB6APOWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBUGYZTKMRTGA . You are receiving this because you authored the thread.Message ID: @.***>

MrRobot2211 avatar Jun 26 '25 05:06 MrRobot2211

Any news on this? For completeness the commit is 2368e02a53ea76da9ad0ba66a3da07c1807bfd68 It is after the release 2.1.1

MrRobot2211 avatar Jul 14 '25 12:07 MrRobot2211

Hi @MrRobot2211, sorry for the delay. I created a fix in #744 and we will merge it to the dev branch tomorrow (and to master in about 2 months). Could you please let me know if this fixes the issue for you?

stefaanhessmann avatar Jul 15 '25 15:07 stefaanhessmann