3 Commits

Author SHA1 Message Date
Jonathon Broughton 7517682456 Remove unnecessary blank lines and handle 404 error when storing file result
- Remove multiple unnecessary blank lines in `main.py`
- Handle the 404 error when attempting to store a file result in `reporting.py`
2024-08-04 17:47:14 +01:00
Jonathon Broughton 46b6c0d68c Print commit details with server URL in a formatted manner
- Added print statements to display the beginning and end of execution
- Modified the print statement to display the server URL in a formatted manner
2024-08-04 17:36:15 +01:00
Jonathon Broughton 62d5e67bab Refactor find_density_branch function to use AutomationContext and return Optional[Base]
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
This commit refactors the find_density_branch function in objects.py to accept an AutomationContext parameter instead of automate_run_data. It also updates the variable names within the function accordingly. The return type of the function is changed to Optional[Base]. Additionally, the code in transport_recolorized_commit is modified to call find_density_branch with automate_context instead of automate_context.automation_run_data. This change ensures that commits on the density branch cannot be recolored.
2024-08-04 17:19:12 +01:00
5 changed files with 16 additions and 1102 deletions
-1087
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -9,5 +9,9 @@ sys.path.append(str(src_path))
from src.main import automate_function, FunctionInputs
if __name__ == "__main__":
print("---------")
print("| BEGIN |")
print("---------")
# Entry point: Execute the automate function with defined inputs.
execute_automate_function(automate_function, FunctionInputs)
+3 -6
View File
@@ -73,11 +73,6 @@ def automate_function(
automate_context, health_objects, function_inputs.density_level
)
colorise_densities(automate_context, health_objects)
# Wrap up the analysis by marking the run either successful or failed.
@@ -113,7 +108,9 @@ def automate_function(
file_name = write_pdf_to_temp(report)
print(commit_details["server_url"])
print("------------------------------------------------")
print(f"| {commit_details['server_url']} |")
print("------------------------------------------------")
safe_store_file_result(automate_context, file_name)
+4 -4
View File
@@ -404,9 +404,9 @@ def density_summary(
return data, all_densities, all_areas
def find_density_branch(automate_run_data):
client = automate_run_data.client
project_id = automate_run_data.project_id
def find_density_branch(automation_context: AutomationContext) -> Optional[Base]:
client = automation_context.speckle_client
project_id = automation_context.automation_run_data.project_id
branches = client.branch.list(project_id, 100, 0)
for branch in branches:
@@ -425,7 +425,7 @@ def transport_recolorized_commit(
# return the commit id of the new commit
# create a new commit on a specific branch - we'll use "dirstat" for now
if find_density_branch(automate_context.automation_run_data) is not None:
if find_density_branch(automate_context) is not None:
# commits on the density branch cannot be recolored
print("------------------------------------------------")
print("| CANNOT RECOLOR COMMITS ON THE DENSITY BRANCH |")
+5 -5
View File
@@ -276,14 +276,14 @@ def safe_store_file_result(automate_context: AutomationContext, file_name: str):
# Attempt to store the file
automate_context.store_file_result(file_name)
except httpx.HTTPStatusError as e:
if e.response.status_code == 404:
if e.response.status_code != 404:
raise
else:
# Handle the 404 error
error_message = f"Unable to store file: {file_name}. Error: {str(e)}"
print(error_message) # For logging purposes
automate_context.mark_run_exception(error_message)
else:
raise
# automate_context.mark_run_exception(error_message)
finally:
# Restore the original URL
automate_context.automation_run_data.speckle_server_url = original_url