Skip to content
Snippets Groups Projects
Commit addf5331 authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

Added duration of execution

parent 306eacae
No related branches found
No related tags found
No related merge requests found
......@@ -48,20 +48,20 @@ function run_file(workflowFilePath::String)
results_container = startResultsContainer(encoded_auth)
# Start the data containers
startDataContainers(unique_services, encoded_auth)
#startDataContainers(unique_services, encoded_auth)
# Execute the workflow
need_to_update_results = manage_workflow(tasks, globals["platform"], results_container, overwrite)
# Stop the results container
if need_to_update_results
#=if need_to_update_results
saveResultsContainer(encoded_auth)
else
stopResultsContainer(encoded_auth)
end
# Stop the data containers
stopDataContainers(unique_services, encoded_auth)
stopDataContainers(unique_services, encoded_auth)=#
end
......
......@@ -32,7 +32,8 @@ This function will process the task parameters, execute the task, update the con
"""
function run_task(task_name::String, task_info::Dict, dependencies_info::Dict, results_container::Dict, update_condition::Atomic{Bool}, overwrite::Bool)
println("Starting task $task_name at $(Dates.format(now(), "HH:MM:SS"))")
start_time = now() # Capture the start time
println("Starting task $task_name at $(Dates.format(start_time, "HH:MM:SS"))")
condition_met = false
......@@ -50,7 +51,12 @@ function run_task(task_name::String, task_info::Dict, dependencies_info::Dict,
atomic_cas!(update_condition, false, true) # CAS: Compare-And-Swap
end
println("Completed task $task_name at $(Dates.format(now(), "HH:MM:SS"))")
end_time = now() # Capture the end time
println("Completed task $task_name at $(Dates.format(end_time, "HH:MM:SS"))")
# Calculate and print the duration
duration = print_duration_in_hms(end_time - start_time) # Duration as a Period type
println("Duration of task $task_name: $duration")
end
......@@ -232,4 +238,14 @@ function get_task_df(task_name::String, dependencies_info::Dict, results_contain
close_connection(results_connection)
return df
end
function print_duration_in_hms(duration::Period)
total_seconds = Dates.value(duration) # Get total seconds from the duration
hours = total_seconds ÷ 3600 # Integer division to get hours
minutes = (total_seconds ÷ 60) % 60 # Remaining minutes
seconds = total_seconds % 60 # Remaining seconds
# Format the string with leading zeros for minutes and seconds
return "$(hours)h:$(lpad(minutes, 2, "0"))m:$(lpad(seconds, 2, "0"))s"
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment