LILY-QML / LLY-DML

LLY-DML is part of the LILY project and is a Quantum Machine Learning model. It uses so-called L-Gates. These gates are Machine Learning gates that modify their state based on an input to map to a desired state of an input.
https://www.lilyqml.de
2 stars 5 forks source link

Class Description: Start #41

Open xleonplayz opened 2 weeks ago

xleonplayz commented 2 weeks ago

Class: Start

The Start class is responsible for loading essential references and verifying that all necessary files and logs are correctly present at the start of the program. It coordinates the initialization process by conducting various checks and responds accordingly if any issues are detected. All important events and errors are documented in a log file.

Attributes

Methods

1. __init__(self, reader)

Description:

Initializes the Start class and sets the train_json_exists flag to False.

Parameters:

Functionalities:

2. run(self)

Description:

The run() method is the main execution method that coordinates the initialization process. It performs the following steps:

  1. File Check:

    • Action: Calls the fileCheck() method from the Reader class to verify the presence of essential files and directories.
    • Log Message: "Initiating file check..."
    • Result Handling:

      • Error Code: 'var' Folder is Missing

        Error Code: 1001 - 'var' folder is missing.
        Log Message: "ERROR: 'var' folder is missing. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
      • Error Code: 'data.json' Missing

        Error Code: 1002 - 'data.json' file is missing in 'var' folder.
        Log Message: "ERROR: 'data.json' file is missing. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
      • Error Code: 'config.json' Missing

        Error Code: 1003 - 'config.json' file is missing in 'var' folder.
        Log Message: "ERROR: 'config.json' file is missing. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
      • Success Code: All Files Present, 'train.json' Exists

        Success Code: 2001 - All files are present. 'train.json' exists.
        Log Message: "SUCCESS: All files are present. 'train.json' exists."
        • Action: Sets the train_json_exists flag to True and logs a corresponding message:

          Log Message: "'train.json' found. Proceeding with initialization."
      • Success Code: All Files Present, 'train.json' Missing

        Success Code: 2002 - All files are present. 'train.json' is missing.
        Log Message: "SUCCESS: All files are present. 'train.json' is missing."
        • Action: Leaves the train_json_exists flag as False and logs a corresponding message. The program is not terminated if train.json is missing.

          Log Message: "'train.json' missing. Proceeding without training file."
      • Unexpected Error Code:

        Error Code: 100105 - Unexpected error during file check.
        Log Message: "ERROR: Unexpected error during file check. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
  2. Logfile Check:

    • Action: Calls the checkLog() method from the Reader class to ensure an up-to-date log file exists.
    • Log Message: "Checking for an existing log file..."
    • Result Handling:

      • If the log file is valid and up-to-date:

        Log Message: "Log file is valid and up-to-date."
      • If the log file cannot be created or accessed:

        Error Code: 100106 - Failed to create or access log file.
        Log Message: "ERROR: Failed to create or access log file. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
  3. Data Consistency Check:

    • Action: Calls the dataConsistency() method from the Reader class to ensure the data.json file is consistent.
    • Log Message: "Verifying data consistency for 'data.json'..."
    • Result Handling:

      • If data.json is inconsistent:

        Error Code: 100104 - 'data.json' file is inconsistent.
        Log Message: "ERROR: 'data.json' file is inconsistent. Terminating program."
        • Action: Logs the error and terminates the program with the corresponding error code.
      • If data.json is consistent:

        Success Code: 200103 - 'data.json' is consistent. Proceeding with execution.
        Log Message: "'data.json' is consistent. Proceeding with execution."
        • Action: Logs the successful consistency check and allows the program to continue.

Process Overview

  1. Initialization:

    • A Reader instance is created.
    • A Start instance is created, which receives the Reader instance.
  2. Execution (Start.run()):

    • File Check:

      • Calls fileCheck() to ensure all necessary files and directories are present.
      • Depending on the outcome, appropriate error or success codes are logged, and the program may be terminated.
    • Logfile Check:

      • Calls checkLog() to verify the existence and currency of the log file.
      • If there are issues, the program terminates with the corresponding error.
    • Data Consistency Check:

      • Calls dataConsistency() to check the consistency of the data.json file.
      • If inconsistent, the program terminates with the corresponding error.
      • If successful, the program continues.
  3. Further Initialization:

    • After successfully running run(), the program can proceed with additional initialization, such as loading and processing data.