From b6127336bec9054af460798cf5fda1337473f731 Mon Sep 17 00:00:00 2001 From: Peter Baker Date: Wed, 21 May 2025 12:45:54 +1000 Subject: [PATCH 1/2] Adding job tests and new payload options Signed-off-by: Peter Baker --- api-test/jobs.http | 81 +++++++++++++++++++++++++++++++++++----- src/api/services/jobs.ts | 38 ++++++++++++++----- 2 files changed, 100 insertions(+), 19 deletions(-) diff --git a/api-test/jobs.http b/api-test/jobs.http index a3a49f6..08cae75 100644 --- a/api-test/jobs.http +++ b/api-test/jobs.http @@ -50,11 +50,51 @@ Authorization: Bearer {{authToken}} { "type": "TEST", "inputPayload": { - "id" : 1 + "id" : 1111111 + } +} + +### Create a new regional assessment job (with full params) +# @name createRegionalAssessmentJob +POST {{baseUrl}}/jobs +Content-Type: {{contentType}} +Authorization: Bearer {{authToken}} + +{ + "type": "REGIONAL_ASSESSMENT", + "inputPayload": { + "region": "Mackay-Capricorn", + "reef_type": "slopes", + "depth_min": -10.1, + "depth_max": -2.1, + "slope_min": 0.1, + "slope_max": 30.0, + "rugosity_min": 0.0, + "rugosity_max": 6.0, + "waves_period_min": 1.94303, + "waves_period_max": 9.32689, + "waves_height_min": 0.237052, + "waves_height_max": 2.53194, + "threshold": 95 + } +} + +### Create a new regional assessment job (with minimal params) +# @name createRegionalAssessmentJob +POST {{baseUrl}}/jobs +Content-Type: {{contentType}} +Authorization: Bearer {{authToken}} + +{ + "type": "REGIONAL_ASSESSMENT", + "inputPayload": { + "region": "Mackay-Capricorn", + "reef_type": "slopes", + "depth_min" : -5.11111 } } -### Create a new suitability assessment job +### Create a new suitability assessment job (with full params) # @name createSuitabilityJob POST {{baseUrl}}/jobs Content-Type: {{contentType}} @@ -63,20 +103,41 @@ Authorization: Bearer {{authToken}} { "type": "SUITABILITY_ASSESSMENT", "inputPayload": { - "region": "Cairns-Cooktown", + "region": "Mackay-Capricorn", "reef_type": "slopes", - "depth_min": -7.0, - "depth_max": -3.9, - "slope_min": 0.2, - "slope_max": 40.0, + "depth_min": -10.1, + "depth_max": -2.1, + "slope_min": 0.1, + "slope_max": 30.0, "rugosity_min": 0.0, "rugosity_max": 6.0, - "x_dist" : 450, - "y_dist" : 20, + "waves_period_min": 1.94303, + "waves_period_max": 9.32689, + "waves_height_min": 0.237052, + "waves_height_max": 2.53194, + "x_dist": 451, + "y_dist": 27, "threshold": 95 } } +### Create a new suitability assessment job (with minimal params) +# @name createSuitabilityJob +POST {{baseUrl}}/jobs +Content-Type: {{contentType}} +Authorization: Bearer {{authToken}} + +{ + "type": "SUITABILITY_ASSESSMENT", + "inputPayload": { + "region": "Mackay-Capricorn", + "reef_type": "slopes", + "x_dist": 451, + "y_dist": 27 + } +} + + ### Store the job IDs for further operations @jobId = {{createJob.response.body.jobId}} @jobId = {{createSuitabilityJob.response.body.jobId}} @@ -241,4 +302,4 @@ Authorization: Bearer {{authToken}} ### Try download (should fail as job is not complete) GET {{baseUrl}}/jobs/{{jobId}}/download -Authorization: Bearer {{authToken}} \ No newline at end of file +Authorization: Bearer {{authToken}} diff --git a/src/api/services/jobs.ts b/src/api/services/jobs.ts index 642dd32..c30d911 100644 --- a/src/api/services/jobs.ts +++ b/src/api/services/jobs.ts @@ -35,17 +35,37 @@ type JobExpiryMap = { }; const sharedCriteriaSchema = z.object({ - // High level config + // High level config - common to all current scenarios region: z.string().describe('Region for assessment'), reef_type: z.string().describe('The type of reef, slopes or flats'), - // Criteria - depth_min: z.number().describe('The depth range (min)'), - depth_max: z.number().describe('The depth range (max)'), - slope_min: z.number().describe('The slope range (min)'), - slope_max: z.number().describe('The slope range (max)'), - rugosity_min: z.number().describe('The rugosity range (min)'), - rugosity_max: z.number().describe('The rugosity range (max)'), - threshold: z.number().describe('Suitability threshold integer (min)'), + + // Criteria - all optional to match the Union{Float64,Nothing} in worker + depth_min: z.number().optional().describe('The depth range (min)'), + depth_max: z.number().optional().describe('The depth range (max)'), + slope_min: z.number().optional().describe('The slope range (min)'), + slope_max: z.number().optional().describe('The slope range (max)'), + rugosity_min: z.number().optional().describe('The rugosity range (min)'), + rugosity_max: z.number().optional().describe('The rugosity range (max)'), + waves_period_min: z + .number() + .optional() + .describe('The wave period range (min)'), + waves_period_max: z + .number() + .optional() + .describe('The wave period range (max)'), + waves_height_min: z + .number() + .optional() + .describe('The wave height range (min)'), + waves_height_max: z + .number() + .optional() + .describe('The wave height range (max)'), + threshold: z + .number() + .optional() + .describe('Suitability threshold integer (min)'), }); /** From 6da77cea4b86c0a26fdec90a243b398d3535c441 Mon Sep 17 00:00:00 2001 From: Peter Baker Date: Wed, 21 May 2025 12:55:29 +1000 Subject: [PATCH 2/2] Reverting Signed-off-by: Peter Baker --- api-test/jobs.http | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api-test/jobs.http b/api-test/jobs.http index 08cae75..e1bb8a4 100644 --- a/api-test/jobs.http +++ b/api-test/jobs.http @@ -89,8 +89,7 @@ Authorization: Bearer {{authToken}} "type": "REGIONAL_ASSESSMENT", "inputPayload": { "region": "Mackay-Capricorn", - "reef_type": "slopes", - "depth_min" : -5.11111 + "reef_type": "slopes" } }