Skip to content

Commit

Permalink
implemented issue BU-ISCIII#224. Crontab sets directly to error when …
Browse files Browse the repository at this point in the history
…runParameters is not found
  • Loading branch information
luissian committed Aug 29, 2023
1 parent c5db8a2 commit 6767dfc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
16 changes: 16 additions & 0 deletions wetlab/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ def check_valid_date_format(date):
return False


def get_samba_atribute_data(conn, shared_folder, remote_path, attribute=None):
"""_summary_
Args:
conn (_type_): _description_
shared_folder (_type_): _description_
remote_path (_type_): _description_
attribute (_type_, optional): _description_. Defaults to None.
"""
attributes = conn.getAttributes(shared_folder, remote_path)
if attribute is not None:
atr_field = "attributes." + attribute
return eval(atr_field)
return attributes


def get_samba_connection_data():
"""
Description:
Expand Down
3 changes: 1 addition & 2 deletions wetlab/utils/crontab_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,14 +1233,13 @@ def store_sample_sheet_if_not_defined_in_run(
return sample_sheet_on_database


def waiting_time_expired(run_process_obj, time_to_check, maximun_time, experiment_name):
def waiting_time_expired(time_to_check, maximun_time, experiment_name):
"""
Description:
The function get the time run was recorded to compare with the present time.
If the value is less that the allowed time to wait will return False.
True is returned if the time is bigger
Input:
run_process_obj # run process object
time_to_check # reference time to be checked
maximun_time # maximm number of days to wait
experiment_name # experiment name to be checked
Expand Down
43 changes: 35 additions & 8 deletions wetlab/utils/crontab_update_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,39 @@ def search_update_new_runs(request_reason):
wetlab.utils.common.logging_errors(error_message, True, False)
experiment_name = "Experiment name NOT FOUND"
wetlab.utils.common.logging_errors(error_message, True, False)
# we don't have experiment name when there is no run_parameters file.
# We used the run folder name instead.
run_process_obj = wetlab.utils.crontab_process.get_run_process_obj_or_create_if_not_exists(
new_run
# check the run folder creation date to allow more time before
# setting the run to error
f_created_date = wetlab.utils.common.get_samba_atribute_data(
conn,
wetlab.utils.crontab_process.get_samba_shared_folder(),
new_run,
"created_time",
)
time_to_check = datetime.datetime.utcfromtimestamp(
f_created_date
).date()
max_time_for_run_parameters = (
wetlab.models.ConfigSetting.objects.filter(
configuration_name__exact="MAXIMUM_TIME_WAIT_RUN_PARAMETERS"
)
.last()
.get_configuration_value()
)
wetlab.utils.crontab_process.handling_errors_in_run(new_run, "21")
if wetlab.utils.crontab_process.waiting_time_expired(
time_to_check, max_time_for_run_parameters, experiment_name
):
# Maximum time for waiting run parameter in folder has expired
# we don't have experiment name when there is no run_parameters file.
# We used the run folder name instead.
run_process_obj = wetlab.utils.crontab_process.get_run_process_obj_or_create_if_not_exists(
new_run
)
wetlab.utils.crontab_process.handling_errors_in_run(new_run, "21")
else:
logger.debug(
"%s : RunParameter not in folder run. Allowing more time",
experiment_name,
)
logger.debug("%s : Deleting RunParameter file", experiment_name)
logger.debug(
"%s : Aborting the process for this run. Continue with the next.",
Expand Down Expand Up @@ -500,7 +527,7 @@ def manage_run_in_recorded_state(conn, run_process_objs):
run_process_obj.get_run_generated_date_no_format().date()
)
if not wetlab.utils.crontab_process.waiting_time_expired(
run_process_obj, time_to_check, maximun_time, experiment_name
time_to_check, maximun_time, experiment_name
):
logger.debug(
"%s : End the process. Waiting more time to get Sample Sheet file",
Expand Down Expand Up @@ -660,7 +687,7 @@ def manage_run_in_sample_sent_processing_state(conn, run_process_objs):
)
time_to_check = run_process_obj.get_run_generated_date_no_format().date()
if not wetlab.utils.crontab_process.waiting_time_expired(
run_process_obj, time_to_check, maximun_time, experiment_name
time_to_check, maximun_time, experiment_name
):
logger.info(
"%s : Waiting more time to get Sequencer completion",
Expand Down Expand Up @@ -864,7 +891,7 @@ def manage_run_in_processing_bcl2fastq_state(conn, run_process_objs):
)
continue
if not wetlab.utils.crontab_process.waiting_time_expired(
run_process_obj, time_to_check, maximun_time, experiment_name
time_to_check, maximun_time, experiment_name
):
logger.debug(
"%s : End the process. Waiting more time to get bcf2fastq stats.",
Expand Down

0 comments on commit 6767dfc

Please sign in to comment.