Skip to content

feat: missing criteria and optional #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 70 additions & 10 deletions api-test/jobs.http
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,50 @@ Authorization: Bearer {{authToken}}
{
"type": "TEST",
"inputPayload": {
"id" : 1
"id" : 1111111
}
}

### Create a new suitability assessment job
### 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"
}
}

### Create a new suitability assessment job (with full params)
# @name createSuitabilityJob
POST {{baseUrl}}/jobs
Content-Type: {{contentType}}
Expand All @@ -63,20 +102,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}}
Expand Down Expand Up @@ -241,4 +301,4 @@ Authorization: Bearer {{authToken}}

### Try download (should fail as job is not complete)
GET {{baseUrl}}/jobs/{{jobId}}/download
Authorization: Bearer {{authToken}}
Authorization: Bearer {{authToken}}
38 changes: 29 additions & 9 deletions src/api/services/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)'),
});

/**
Expand Down