script_maker2000.files

script_maker2000.files.add_dir_to_config(new_output_dir)

Add a new output directory to the batch config.

Args:

new_output_dir (str): The path to the new output directory.

Returns:

str: A message indicating whether the directory was successfully added to the config or not.

Raises:

FileNotFoundError: If the new output directory or any required subfolders/files are not found.

script_maker2000.files.add_premade_config(config_path, return_config_name=False, override_config=False)

Adds a premade configuration to the existing premade configurations.

Args:

config_path (str or dict): The path to the configuration file or a dictionary containing the configuration. return_config_name (bool, optional): Whether to return the name of the added configuration. Defaults to False. override_config (bool, optional): Whether to override an existing configuration with the same name. Defaults to False.

Returns:

str or tuple: If return_config_name is True, returns a tuple containing the output text and the name of the added configuration. Otherwise, returns the output text as a string.

Raises:

FileNotFoundError: If the specified configuration file does not exist. JSONDecodeError: If the configuration file is not a valid JSON file. KeyError: If the configuration file does not contain the required keys.

script_maker2000.files.automatic_ressource_allocation(main_config)

Automatically allocates resources for job execution based on the provided main configuration.

Args:

main_config (dict): The main configuration containing input file path, loop configuration, and resource limits.

Returns:

tuple: A tuple containing the updated main configuration and a dictionary of changes made.

Raises:

FileNotFoundError: If the input file path is not found.

script_maker2000.files.change_entry_in_batch_config(config_name, new_status, output_dir)

Change the status of an entry in the batch config.

Args:

config_name (str): Name of the config. new_status (str): New status of the entry. Must be either ‘running’, ‘finished’, or ‘deleted’. output_dir (str): Output directory of the entry.

Returns:

str: Message indicating that the entry has been changed in the batch config.

Raises:

KeyError: If the config name is not found in the batch config. ValueError: If the new status is not ‘running’, ‘finished’, or ‘deleted’.

script_maker2000.files.check_config(main_config, skip_file_check=False, override_continue_job=False)

This function checks the main configuration for the necessary keys and values.

Args:

main_config (dict or str): The main configuration dictionary or the path to the configuration file. skip_file_check (bool, optional): Whether to skip the file path and format checks. Defaults to False. override_continue_job (bool, optional): Whether to override the “continue_previous_run” option in the main config. Defaults to False.

Raises:

ValueError: If the main configuration is missing required keys or has invalid values. FileExistsError: If the output directory already has subfolders setup and “continue_previous_run” is False.

script_maker2000.files.check_dir_in_batch_config(output_dir)
script_maker2000.files.check_input_files(main_config)

Check if the input files specified in the main configuration exist and have the correct format.

Args:

main_config (dict): The main configuration dictionary.

Raises:

FileNotFoundError: If the input file path is not provided or the input files cannot be found. ValueError: If the input file is not in JSON format or if no XYZ files are found in the input directory.

script_maker2000.files.collect_input_files(config_path, preparation_dir, config_name=None, zip_name=None)

Collects all input files (xyz, config, csv) and puts them into a single zipball.

Args:

config_path (str): Path to the config file. preparation_dir (str): Path to the directory where the input files will be prepared. config_name (str, optional): Name of the config file. If not provided, the original name will be used. Defaults to None. zip_name (str, optional): Name of the zipball. If not provided, a default name will be used. Defaults to None.

Returns:

pathlib.Path: Path to the created zipball.

Raises:

ValueError: If config is given as a dict, but config_name is not provided. FileNotFoundError: If no input files are provided.

script_maker2000.files.collect_results_(output_dir, exclude_patterns=None)
script_maker2000.files.collect_xyz_files_to_dict(xyz_dir, filter_path=None)

Collects all xyz files in a directory and returns them as a dictionary.

Args:

xyz_dir (str): Path to the directory containing the xyz files.

Returns:

dict: Dictionary with the xyz files, where the keys are the file names without the extension and the values are dictionaries containing the file path, key, charge, and multiplicity.

Raises:

FileNotFoundError: If the specified directory does not exist. ValueError: If a file in the directory does not match the expected pattern.

script_maker2000.files.create_working_dir_structure(main_config: dict)

This function generates the data structure for further calculations. It creates a main folder with subfolders for crest, optimization, sp, and result. Each subfolder contains an input and an output folder. These folders store molecule files and slurm files.

Args:

main_config (dict): The main configuration dictionary containing the necessary information.

Returns:

output_dir (pathlib.Path): The path to the main output directory. new_input_path (pathlib.Path): The path to the new input folder. new_json_file (pathlib.Path): The path to the new JSON file.

script_maker2000.files.open_dir_in_explorer(path)
script_maker2000.files.read_batch_config_file(mode)

Read the global config file and check if any paths are pointing to non-existing files.

Args:

mode (str): path or dict

Returns:

str|dict: either the config path or the config dict

script_maker2000.files.read_config(config_file, perform_validation=True, override_continue_job=False, change_output_dir=True)

Read and provide the main configuration from a file or dictionary.

Args:

config_file (str or dict): Path to the configuration file or the configuration dictionary. perform_validation (bool, optional): Whether to perform validation on the configuration. Defaults to True. override_continue_job (bool, optional): Whether to override the “continue_previous_run” option in the main config. Defaults to False.

Returns:

dict: The main configuration dictionary.

Raises:

FileNotFoundError: If the configuration file cannot be found. ValueError: If the configuration file is not in JSON format.

script_maker2000.files.read_mol_input_json(input_json, skip_file_check=False)

Read the molecule input JSON file and perform consistency checks on the file paths and values.

Args:

input_json (str): The path to the molecule input JSON file. skip_file_check (bool, optional): Whether to skip the file path and format checks. Defaults to False.

Returns:

dict: The molecule input dictionary.

Raises:

FileNotFoundError: If a file specified in the JSON does not exist. ValueError: If the file format is not XYZ or if the file name does not match the specified key, charge, or multiplicity.

script_maker2000.files.read_premade_config(mode)

Reads a premade configuration file and returns the configuration data.

Args:

mode (str): The mode in which to read the configuration file. Must be one of “path”, “dict”, or “both”.

Returns:

path|dict|tuple: Return object can be: - If mode is “path”, returns the path to the configuration file. - If mode is “dict”, returns the configuration data as a dictionary. - If mode is “both”, returns a tuple containing the path to the configuration file and the configuration data.

Raises:

ValueError: If the mode is not one of “path”, “dict”, or “both”.

script_maker2000.files.remove_premade_config(config_name)

Removes a premade config from the list of premade configs.

Args:

config_name (str): The name of the config to be removed.

Returns:

str: A message indicating whether the config was successfully removed or not.

script_maker2000.files.replace_empty_with_empty_string(config_dict)
script_maker2000.files.return_user_config_dir()

Returns the user configuration directory path.

Returns:

str: Path to the user configuration directory.