Skip to content

Commit

Permalink
Merge branch 'FixCompletedJobsRunningTwice' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cjsostad committed Dec 13, 2024
2 parents d43499b + bd70598 commit 33aea56
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 1,146 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

Binary file removed autoast/2_jobs.xlsx
Binary file not shown.
Binary file removed autoast/4_jobs_tested.xlsx
Binary file not shown.
Binary file added autoast/5_jobs.xlsx
Binary file not shown.
Binary file added autoast/6_mixed_jobs.xlsx
Binary file not shown.
Binary file modified autoast/7_tested_jobs.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_4_jobs.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_5_jobs.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_5_jobs_Results.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_6_jobs.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_jobs_1_of_2.xlsx
Binary file not shown.
Binary file added autoast/Cariboo_replacement_jobs_2_of2.xlsx
Binary file not shown.
Binary file modified autoast/alan_jobs.xlsx
Binary file not shown.
1,103 changes: 0 additions & 1,103 deletions autoast/autoast_Indexing.py

This file was deleted.

2 changes: 1 addition & 1 deletion autoast/autoast_V1_Working Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


## *** INPUT YOUR EXCEL FILE NAME HERE ***
excel_file = '4_tested_jobs.xlsx'
excel_file = 'Cariboo_replacement_jobs.xlsx'

# Define the job timeout in seconds (6 hours) *** Timeout currently not working in this version *** No need to change the time
JOB_TIMEOUT = 6 * 60 * 60
Expand Down
87 changes: 51 additions & 36 deletions autoast/autoast_v2_Cuisinart_DEV.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import sys
import time

# Test Comment


## *** INPUT YOUR EXCEL FILE NAME HERE ***
excel_file = 'Cariboo_replacement_jobs.xlsx'
excel_file = 'Cariboo_replacement_6_jobs.xlsx'

# Set the job timeout further down. Use CNTL + F to search for JOB_TIMEOUT

Expand Down Expand Up @@ -453,12 +453,12 @@ def add_job_result(self, job_index, condition):
# Update the ast condition for the specific job to the new condition (failed, queued, complete)
ws.cell(row=excel_row_index, column=ast_condition_index, value=condition)

# # if the condition in AST_CONDITION_COLUMN is 'Requeued" then go to the dont overwrite output column and change false to true
# if condition == 'Requeued':
# # print(f"Add Job Result - Job {job_index} failed, updating condition to 'Requeued'. **CHANGED JOB INDEX +1 to JOB INDEX ***") #NOTE CHANGED JOB INDEX + 1 to JOB INDEX
# self.logger.info(f"Add Job Result - Job {job_index} (Row {excel_row_index}) updating condition to 'Requeued'.")
# ws.cell(row=excel_row_index, column=dont_overwrite_outputs_index, value="True")
# self.logger.info(f"Add Job Result - Job {job_index} (Row {excel_row_index}) updating dont_overwrite_outputs to 'True'.")
# if the condition in AST_CONDITION_COLUMN is 'Requeued" then go to the dont overwrite output column and change false to true
if condition == 'Requeued':
# print(f"Add Job Result - Job {job_index} failed, updating condition to 'Requeued'. **CHANGED JOB INDEX +1 to JOB INDEX ***") #NOTE CHANGED JOB INDEX + 1 to JOB INDEX
self.logger.info(f"Add Job Result - Job {job_index} (Row {excel_row_index}) updating condition to 'Requeued'.")
ws.cell(row=excel_row_index, column=dont_overwrite_outputs_index, value="True")
self.logger.info(f"Add Job Result - Job {job_index} (Row {excel_row_index}) updating dont_overwrite_outputs to 'True'.")

# Save the workbook with the updated condition
self.logger.info(f"Add Job Result - Updated Job {job_index} with condition '{condition}'.")
Expand Down Expand Up @@ -560,7 +560,7 @@ def batch_ast(self):
self.logger.error(f"Batch Ast: Job {job_index} exceeded timeout. Marking as Failed. Failed counter is {timeout_failed_counter}")

else:
# Get the result of the job from (return_dict).
# Get the result of the job from return_dict.
# If the result is 'Success', increment the success_counter and call the add_job_result method to mark the job as 'COMPLETE'

result = return_dict.get(job_index)
Expand Down Expand Up @@ -591,7 +591,7 @@ def batch_ast(self):



# This is the newer version of the re_load_failed_jobs function from the autoastv2Script unedited

# NOTE ** Reload failed jobs may be able to be incorporated into load failed jobs to tighten up the script
#RELOAD JOBS
def re_load_failed_jobs_V2(self):
Expand Down Expand Up @@ -675,12 +675,12 @@ def re_load_failed_jobs_V2(self):

# Skip if marked as "COMPLETE"
if ast_condition.upper() == 'COMPLETE':
print(f"Re Load Failed Jobs: Skipping job {job_index} as it is marked COMPLETE.")
print(f"Re Load Failed Jobs: Skipping job {job_index} as it is marked {ast_condition}.")
self.logger.info(f"Re Load Failed Jobs: Adding Complete to dictionary Skipping job {job_index} as it is marked COMPLETE.")
# continue
# ast_condition = 'COMPLETE'
ast_condition = 'COMPLETE'

# **Only requeue jobs that are marked as 'FAILED'**
# Change ast condition to requeued if the job is failed
elif ast_condition.upper() == 'FAILED':
self.logger.info(f"Re Load Failed Jobs: Requeuing {job_index} as it is marked Failed.")
ast_condition = 'Requeued'
Expand All @@ -701,37 +701,52 @@ def re_load_failed_jobs_V2(self):
try:
self.add_job_result(job_index, ast_condition)
self.logger.info(f"Re load Jobs - Added job condition '{ast_condition}' for job {job_index} to jobs list")
# Added Dec 12th
# Save the workbook with the updated condition
self.logger.info(f"Reload Failed Jobs - Saving Job Index ({job_index}) with new condition.")
wb.save(self.queuefile)
except Exception as e:
print(f"Error updating Excel sheet at row {job_index}: {e}")
self.logger.error(f"Re load Jobs - Error updating Excel sheet at row {job_index}: {e}")
self.logger.error(traceback.format_exc())
continue


# Check the condition of DONT_OVERWRITE_OUTPUTS
current_value = job.get(self.DONT_OVERWRITE_OUTPUTS, '')

# If DONT_OVERWRITE_OUTPUTS is anything but True, change it to 'True'
if current_value != 'True':
# Log the current state before changing
if current_value == 'False':
print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is False, changing to True")
self.logger.info(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is False, changing to True")
elif current_value == '':
print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is empty, changing to True")
self.logger.error(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is empty, changing to True")
else:
print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")
self.logger.warning(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")
# # Check the condition of DONT_OVERWRITE_OUTPUTS
# current_value = job.get(self.DONT_OVERWRITE_OUTPUTS, '')

# # If DONT_OVERWRITE_OUTPUTS is anything but True, change it to 'True'
# if current_value != 'True':
# print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")
# self.logger.warning(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")
# job[self.DONT_OVERWRITE_OUTPUTS] = "True"

# # Added Dec 12th
# # Save the workbook with the updated condition
# self.logger.info(f"Reload Failed Jobs - Saving Job Index ({job_index}) with new condition.")
# wb.save(self.queuefile)



# # # Log the current state before changing
# # if current_value == 'False':
# # print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is False, changing to True")
# # self.logger.info(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is False, changing to True")
# # elif current_value == '':
# # print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is empty, changing to True")
# # self.logger.error(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is empty, changing to True")
# # else:
# # print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")
# # self.logger.warning(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is '{current_value}', changing to True")

# Set the value to 'True'
job[self.DONT_OVERWRITE_OUTPUTS] = "True"
# # # Set the value to 'True'
# # job[self.DONT_OVERWRITE_OUTPUTS] = "True"

# If DONT_OVERWRITE_OUTPUTS is already 'True, don't change it.
else:
# If it's already 'True', log that no change is needed
print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is already True, no change needed")
self.logger.info(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is already True, no change needed")
# # If DONT_OVERWRITE_OUTPUTS is already 'True, don't change it.
# else:
# # If it's already 'True', log that no change is needed
# print(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is already True, no change needed")
# self.logger.info(f"Re Load Failed Jobs: Job {job_index} DONT_OVERWRITE_OUTPUTS is already True, no change needed")

# Add the job to the jobs list after all checks and processing
self.jobs.append(job)
Expand All @@ -747,7 +762,7 @@ def re_load_failed_jobs_V2(self):

print(f"Re Load Jobs - Job dictionary is {job}")
self.logger.info(f"Re load Jobs - Job {job_index} dictionary is {job}")

except FileNotFoundError as e:
print(f"Error: Queue file not found - {e}")
self.logger.error(f"Re Load Failed Jobs Error: Queue file not found - {e}")
Expand Down
4 changes: 2 additions & 2 deletions autoast/automated_status_sheet_call_routine_arcpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@

# import both the statusing tools which create tabs 1, 2, 3
# sys.path.append(r'\GISWHSE.ENV.GOV.BC.CA\whse_np\corp\script_whse\python\Utility_Misc\Ready\statusing_tools_arcpro\alpha')
# sys.path.append(r'\\GISWHSE.ENV.GOV.BC.CA\WHSE_NP\corp\script_whse\python\Utility_Misc\Ready\statusing_tools_arcpro\beta')
sys.path.append(r'\\spatialfiles.bcgov\work\srm\nel\Local\Geomatics\Workarea\csostad\GitHubAutoAST\statusing_tools_arcpro\beta')
#sys.path.append(r'\\GISWHSE.ENV.GOV.BC.CA\WHSE_NP\corp\script_whse\python\Utility_Misc\Ready\statusing_tools_arcpro\Scripts')
sys.path.append(r'\\spatialfiles.bcgov\work\srm\nel\Local\Geomatics\Workarea\csostad\GitHubAutoAST\statusing_tools_arcpro\Ready')
# sys.path.append(r'\\spatialfiles.bcgov\work\srm\nel\Local\Geomatics\Workarea\csostad\GitHubAutoAST\statusing_tools_arcpro\Ready')
import universal_overlap_tool_arcpro as revolt #@UnresolvedImport
import one_status_tabs_one_and_two_arcpro as one_status_part2
import create_bcgw_sde_connection as connect_bcgw
Expand Down
2 changes: 1 addition & 1 deletion map_automation_scripts_snippets/SiteAndOverviewToolbox.pyt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ site_map = aprx.listMaps('Layers')[0]
inset_map = aprx.listMaps('SiteInsetMap')[0]
overview_map = aprx.listMaps('OverviewLayers')[0]
overview_inset_map = aprx.listMaps('OverviewInsetMap')[0]
lands_file_path = '\\\\spatialfiles.bcgov\\work\\lwbc\\nsr\\Workarea\\fcbc_prg\\FCBC\\Lands_Files\\'
lands_file_path = '\\\\'
site_map_frame = 'Layers Map Frame'
site_map_inset_frame = 'Inset Data Frame Map Frame' # Could assign these strings to objects right here
overview_map_frame = 'Overview Layers Map Frame'
Expand Down

0 comments on commit 33aea56

Please sign in to comment.