ResSimpy.Nexus.logfile_operations.Logging
- class ResSimpy.Nexus.logfile_operations.Logging(model: NexusSimulator)[source]
Bases:
objectMethods:
__init__(model)Class for controlling all logging and logfile (*.log) related functionality.
get_simulation_time(line)Searches for the simulation time in a line.
convert_server_date(original_date)Convert a datetime string from the server for when the simulation was started to a strptime object.
get_errors_warnings_string(log_file_line_list)Retrieves the number of warnings and errors from the simulation log output, and formats them as a string.
Get the start time of an executed simulation run, if no simulation start time returns '-'.
Get the end time of an executed simulation run if it has completed, if no simulation end time returns '-'.
Get the job Id of a simulation run.
get_simulation_status([from_startup])Gets the run status of the latest simulation run.
Get the time taken for the base case to run.
Returns the simulation progress from log files.
- __init__(model: NexusSimulator) None[source]
Class for controlling all logging and logfile (*.log) related functionality.
- Parameters:
model – NexusSimulator instance
__job_id (int) – Run job ID for executed runs
__simulation_start_time (Optional[str]) – Execution start time of the simulation when submitted to calculation engine
__simulation_end_time (Optional[str]) – Execution end time of the last time the simulation was run
__previous_run_time (Optional[str]) – Difference between simulation execution start time and end time.
- static get_simulation_time(line: str) str[source]
Searches for the simulation time in a line.
- Parameters:
line (str) – line to search for the simulation time
- Raises:
ValueError – Throws error if get_next_value doesn’t find any subsequent value in the line
- Returns:
str – value found after TIME card in a line
- static convert_server_date(original_date: str) datetime[source]
Convert a datetime string from the server for when the simulation was started to a strptime object.
- Parameters:
original_date (str) – string of a date with format: “Mon Jan 01 00:00:00 CST 2020”
- Returns:
datetime – datetime object derived from the input string
- static get_errors_warnings_string(log_file_line_list: list[str]) str | None[source]
Retrieves the number of warnings and errors from the simulation log output, and formats them as a string.
- Parameters:
log_file_line_list (list[str]) – log file formatted as a list of strings with a new list entry per line
- Returns:
Optional[str] – string containing the errors and warnings from the simulation log. None if error/warning set is too short
- get_simulation_start_time() str[source]
Get the start time of an executed simulation run, if no simulation start time returns ‘-‘.
- get_simulation_end_time() str[source]
Get the end time of an executed simulation run if it has completed, if no simulation end time returns ‘-‘.
- get_simulation_status(from_startup: bool = False) str | None[source]
Gets the run status of the latest simulation run.
- Parameters:
from_startup (bool, optional) – Searches the same directory as the original_fcs_file_path if True. Otherwise searches the destination folder path, failing this then searches the original_fcs_file_path if False. Defaults to False.
- Raises:
NotImplementedError – If log file is not found - only supporting simulation status from log files
- Returns:
Optional[str] – the error/warning string if the simulation has finished, otherwise returns the running job ID. Empty string if a logfile is not found and from_start up is True
- get_base_case_run_time() str[source]
Get the time taken for the base case to run. Returns ‘-’ if no run time found.
- get_simulation_progress() float[source]
Returns the simulation progress from log files.
- Raises:
NotImplementedError – Only retrieving status from a log file is supported at the moment
ValueError – if no times from the runcontrol file are read in
- Returns:
Optional[float] – how long through a simulation run as a proportion of the number of days simulated as stated in the runcontrol