Ejemplo n.º 1
0
 def setUpClass(cls):
     """
     Set up whole class for testing
     Returns:
     """
     # we assume everything working on sqlite, should also work on postgres in sqlalchemy
     cls.database = DatabaseAccess("sqlite:///test_database.db", "simulation")
Ejemplo n.º 2
0
 def open_connection(self):
     """
     Internal function to open the connection to the database. Only after this function is called the database is
     accessable.
     """
     if self._database is None and not self.database_is_disabled:
         self._database = DatabaseAccess(
             self._configuration["sql_connection_string"],
             self._configuration["sql_table_name"],
         )
Ejemplo n.º 3
0
 def open_connection(self):
     """
     Internal function to open the connection to the database. Only after this function is called the database is
     accessable.
     """
     if self._database is None and not self.database_is_disabled:
         self._database = DatabaseAccess(
             self.sql_connection_string,
             self.sql_table_name,
             timeout=self.connection_timeout,
         )
Ejemplo n.º 4
0
 def switch_to_user_mode(self):
     """
     Switch from viewer mode to user mode - if viewer_mode is enable pyiron has read only access to the database.
     """
     if self._configuration["sql_view_connection_string"] is not None and not self.database_is_disabled:
         if self._database.viewer_mode:
             self.close_connection()
             self._database = DatabaseAccess(
                 self._configuration["sql_connection_string"],
                 self._configuration["sql_table_name"],
             )
             self._database.viewer_mode = True
         else:
             print("Database is already in user mode!")
     else:
         print("Viewer Mode is not available on this pyiron installation.")
Ejemplo n.º 5
0
 def switch_to_viewer_mode(self):
     """
     Switch from user mode to viewer mode - if view_mode is enable pyiron has read only access to the database.
     """
     if (self.sql_view_connection_string is not None
             and not self.database_is_disabled):
         if self._database.view_mode:
             logger.log("Database is already in viewer mode!")
         else:
             self.close_connection()
             self._database = DatabaseAccess(
                 self.sql_view_connection_string,
                 self.sql_view_table_name,
             )
             self._database.view_mode = True
     else:
         print("Viewer Mode is not available on this pyiron installation.")
Ejemplo n.º 6
0
 def switch_to_central_database(self):
     """
     Switch to central database
     """
     if self._use_local_database:
         self.close_connection()
         self._database_is_disabled = self._configuration["disable_database"]
         if not self.database_is_disabled:
             self._database = DatabaseAccess(
                 self._configuration["sql_connection_string"],
                 self._configuration["sql_table_name"],
             )
         else:
             self._database = None
         self._use_local_database = False
     else:
         print("Database is already in central mode or disabled!")
Ejemplo n.º 7
0
 def setUpClass(cls):
     cls.sub_status = SubmissionStatus()
     cls.database = DatabaseAccess("sqlite:///test_sub_status.db", "simulation")
     par_dict = {
         "chemicalformula": "H",
         "computer": "localhost#1#3",
         "hamilton": "Test",
         "hamversion": "0.1",
         "job": "testing",
         "parentid": 0,
         "project": "database.testing",
         "projectpath": "/TESTING",
         "status": "suspended",
         "timestart": datetime(2016, 5, 2, 11, 31, 4, 253377),
         "timestop": datetime(2016, 5, 2, 11, 31, 4, 371165),
         "totalcputime": 0.117788,
         "username": "******",
     }
     cls.job_id = cls.database.add_item_dict(par_dict)
     cls.sub_status_database = SubmissionStatus(db=cls.database, job_id=cls.job_id)
Ejemplo n.º 8
0
 def open_local_sqlite_connection(self, connection_string):
     self._database = DatabaseAccess(connection_string, self.sql_table_name)
     self._use_local_database = True
     self._database_is_disabled = False
Ejemplo n.º 9
0
 def open_local_sqlite_connection(self, connection_string):
     self._database = DatabaseAccess(connection_string,
                                     self._configuration["sql_table_name"])
     self._use_local_database = True
     if self.database_is_disabled:
         self._database_is_disabled = False