mdsuite.database.calculator_database module

MDSuite: A Zincwarecode package.

License

This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zincwarecode Project.

Contact Information

email: zincwarecode@gmail.com github: https://github.com/zincware web: https://zincwarecode.com/

Citation

If you use this module please cite us with:

Summary

class mdsuite.database.calculator_database.Args[source]

Bases: object

Dummy Class for type hinting.

class mdsuite.database.calculator_database.CalculatorDatabase(experiment)[source]

Bases: object

Database Interactions of the calculator class.

This class handles the interaction of the calculator with the project database

get_computation_data() Computation[source]

Query the database for computation data.

This method used the self.args dataclass to look for matching calculator attributes and returns a db.Computation object if the calculation has already been performed

Return:

db.Computation

Returns the computation object from the database if available, otherwise returns None

prepare_db_entry()[source]

Prepare a database entry based on the attributes defined in the init.

queue_data(data, subjects)[source]

Queue data to be stored in the database.

Parameters:
  • data (dict) – A dictionary containing all the data that was computed by the computation

  • subjects (list) – A list of strings / subject names that are associated with the data, e.g. the pairs of the RDF

save_computation_args()[source]

Store the user args.

This method stored the user args from the self.args dataclass into SQLAlchemy objects and adds them to a list which will be written to the database after the calculation was successful.

save_db_data()[source]

Save all the collected computationattributes and computation data to the database.

This will be run after the computation was successful.

update_database(parameters, delete_duplicate: bool = True)[source]

Add data to the database.

Parameters:
  • parameters (dict) – Parameters to be used in the addition, i.e. {“Analysis”: “Green_Kubo_Self_Diffusion”, “Subject”: “Na”, “data_range”: 500, “data”: 1.8e-9}

  • delete_duplicate (bool) – If true, duplicate entries will be deleted.

Return type:

Updates the sql database

class mdsuite.database.calculator_database.ComputationResults(data: dict = <factory>, subjects: dict = <factory>)[source]

Bases: object

Computation Results dataclass.

data: dict
subjects: dict
mdsuite.database.calculator_database.conv_to_db(val)[source]

Convert the given value to something that can be stored in the database.