From 2b81a54e85eb90dc4d92ad169e1e405701d068b7 Mon Sep 17 00:00:00 2001 From: IsaacMtz19 Date: Tue, 30 Sep 2025 08:39:06 -0600 Subject: [PATCH 1/2] bufgix: removed spaces in release.yml file --- .github/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/release.yml b/.github/release.yml index f069243..e6854b2 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -6,16 +6,20 @@ changelog: - title: Major Changes 🛠 labels: - major + - title: New Features 🎉 labels: - enhancement - style + - title: Bugfixes 🐛 labels: - bug + - title: Documentation 📖 labels: - documentation + - title: Maintenance 🔧 labels: -        - "*" + - "*" From f3a13694a23231f1b3aba1c738eebe29b9332d80 Mon Sep 17 00:00:00 2001 From: IsaacMtz19 Date: Wed, 1 Oct 2025 15:57:01 -0600 Subject: [PATCH 2/2] refactor: normalize structure reponse --- Murray/main.py | 15 ++++++++++----- api.py | 48 +++++++++++++++++++++++++++-------------------- tasks.py | 51 +++++++++++++++++++++++++++++++++++--------------- 3 files changed, 74 insertions(+), 40 deletions(-) diff --git a/Murray/main.py b/Murray/main.py index aacad7f..8186b0a 100644 --- a/Murray/main.py +++ b/Murray/main.py @@ -86,8 +86,10 @@ def select_treatments(similarity_matrix, treatment_size, excluded_locations): max_combinations = comb(n, r) n_combinations = max_combinations - if n_combinations > 5000: - n_combinations = 5000 + # if n_combinations > 5000: + # n_combinations = 5000 + if n_combinations > 2000: + n_combinations = 2000 logger.debug(f"Generating {n_combinations} combinations") @@ -515,7 +517,8 @@ def select_treatments_exclusive( # Smart candidate limit based on problem size available_ratio = n / len(similarity_matrix.columns) - base_candidates = min(5000, max_combinations) + # base_candidates = min(5000, max_combinations) + base_candidates = min(2000, max_combinations) if available_ratio < 0.3: # Many locations excluded, need more candidates max_candidates = min(base_candidates * 2, max_combinations) @@ -815,8 +818,10 @@ def BetterGroups( """ unique_locations = data["location"].unique() no_locations = len(unique_locations) - max_group_size = round(no_locations * 0.45) - min_elements_in_treatment = round(no_locations * 0.15) + max_group_size = round(no_locations * 0.35) + min_elements_in_treatment = round(no_locations * 0.20) + # max_group_size = round(no_locations * 0.45) + # min_elements_in_treatment = round(no_locations * 0.15) min_holdout = 100 - (maximum_treatment_percentage * 100) total_Y = data["Y"].sum() diff --git a/api.py b/api.py index 2c81368..2d781be 100644 --- a/api.py +++ b/api.py @@ -238,8 +238,10 @@ async def analyze_design( httpx.post(webhook_dict["url"], json={ "status": "pending", "task_id": task.id, - "message": "Task queued for processing", - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now().isoformat(), + "results": { + "message": "Task queued for processing" + } }) except Exception as ex: logger.error(f"[{task.id}] Error sending pending webhook: {str(ex)}") @@ -298,8 +300,10 @@ async def analyze_evaluation( httpx.post(webhook_dict["url"], json={ "status": "pending", "task_id": task.id, - "message": "Task queued for processing", - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now().isoformat(), + "results": { + "message": "Task queued for processing" + } }) except Exception as ex: logger.error(f"[{task.id}] Error sending pending webhook: {str(ex)}") @@ -317,8 +321,20 @@ async def get_task_status(task_id: str): Get the status and results of a task """ task_result = AsyncResult(task_id, app=celery_app) - - if task_result.ready(): + + # Check for revoked state first (revoked tasks might not be "ready") + if task_result.state == "REVOKED": + return TaskResponse( + task_id=task_id, + status="REVOKED", + results={ + "message": "Task was cancelled/revoked", + "details": "The task was cancelled by user request or system intervention", + "cancelled_at": datetime.now().isoformat(), + "final_status": "cancelled" + } + ) + elif task_result.ready(): if task_result.successful(): results = convert_ndarrays(task_result.result) # results = truncate_large_lists(results) @@ -333,17 +349,6 @@ async def get_task_status(task_id: str): status="FAILURE", results={"error": str(task_result.result)} ) - elif task_result.revoked(): - return TaskResponse( - task_id=task_id, - status="REVOKED", - results={ - "message": "Task was cancelled/revoked", - "details": "The task was cancelled by user request or system intervention", - "cancelled_at": datetime.now().isoformat(), - "final_status": "cancelled" - } - ) elif task_result.state == "RETRY": return TaskResponse( task_id=task_id, @@ -520,9 +525,12 @@ async def cancel_task(task_id: str): response = httpx.post(webhook_url, json={ "status": "cancelled", "task_id": task_id, - "message": "Task was cancelled by user request", - "progress": current_progress, - "progress_percentage": int(current_progress * 100), + "results": { + "message": "Task was cancelled/revoked", + "details": "The task was cancelled by user request or system intervention", + "cancelled_at": datetime.now().isoformat(), + "final_status": "cancelled" + }, "timestamp": datetime.now().isoformat() }) logger.info(f"[{task_id}] Cancellation webhook sent to {webhook_url}") diff --git a/tasks.py b/tasks.py index fc220c6..ac707f4 100644 --- a/tasks.py +++ b/tasks.py @@ -149,10 +149,13 @@ def analyze_design_task( httpx.post(webhook["url"], json={ "status": "started", "task_id": task_id, - "message": f"Design analysis task started ({analysis_mode} mode)", - "analysis_mode": analysis_mode, - "multicell_config": multicell_config, - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now().isoformat(), + "results": { + "message": f"Design analysis task started ({analysis_mode} mode)", + "analysis_mode": analysis_mode, + "multicell_config": multicell_config, + "task_type": "design" + } }) except Exception as e: logger.error(f"[{task_id}] Error sending start webhook: {str(e)}") @@ -304,7 +307,10 @@ def advance_to_sensitivity(): "status": "completed", "task_id": task_id, "timestamp": datetime.now().isoformat(), - "result": final_results + "results": { + "message": "Task completed successfully", + "analysis_data": final_results + } }) except Exception as e: logger.error(f"[{task_id}] Error sending traditional success webhook: {str(e)}") @@ -321,7 +327,10 @@ def advance_to_sensitivity(): "status": "failed", "task_id": task_id, "timestamp": datetime.now().isoformat(), - "error": str(e) + "results": { + "message": "Task failed with error", + "error": str(e) + } }) except Exception as webhook_error: logger.error(f"[{task_id}] Error sending traditional failure webhook: {str(webhook_error)}") @@ -366,8 +375,11 @@ def analyze_evaluation_task( httpx.post(webhook["url"], json={ "status": "started", "task_id": task_id, - "message": "Evaluation analysis task started", - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now().isoformat(), + "results": { + "message": "Evaluation analysis task started", + "task_type": "evaluation" + } }) except Exception as e: logger.error(f"[{task_id}] Error sending start webhook: {str(e)}") @@ -454,8 +466,11 @@ def analyze_evaluation_task( httpx.post(webhook["url"], json={ "status": "completed", "task_id": task_id, - "result": serializable_results, - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now().isoformat(), + "results": { + "message": "Task completed successfully", + "analysis_data": serializable_results + } }) except Exception as e: logger.error(f"[{task_id}] Error sending traditional success webhook: {str(e)}") @@ -472,7 +487,10 @@ def analyze_evaluation_task( "status": "failed", "task_id": task_id, "timestamp": datetime.now().isoformat(), - "error": str(e) + "results": { + "message": "Task failed with error", + "error": str(e) + } }) except Exception as webhook_error: logger.error(f"[{task_id}] Error sending traditional failure webhook: {str(webhook_error)}") @@ -1166,10 +1184,13 @@ def task_revoked_handler(sender=None, task_id=None, reason=None, **kwargs): response = httpx.post(webhook_url, json={ "status": "cancelled", "task_id": task_id, - "message": f"Task was revoked. Reason: {reason or 'Unknown'}", - "progress": current_progress, - "progress_percentage": int(current_progress * 100), - "reason": reason, + "results": { + "message": "Task was cancelled/revoked", + "details": f"The task was revoked. Reason: {reason or 'Unknown'}", + "cancelled_at": datetime.now().isoformat(), + "final_status": "cancelled", + "revocation_reason": reason + }, "timestamp": datetime.now().isoformat() }) logger.info(f"[{task_id}] Revocation webhook sent to {webhook_url}")