Skip to content
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

EDSC-3797: Added an option for concatenation for custom downloads via Harmony #1693

Merged
merged 30 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cb78e2d
EDSC-3797: made initial implementation of the code
bnp26 Oct 31, 2023
1fdf6bd
EDSC-3797: added tests.
bnp26 Nov 2, 2023
3363af9
EDSC-3797: supportsConcat test
bnp26 Nov 2, 2023
a799b02
Merge branch 'main' of https://github.com/nasa/earthdata-search into …
bnp26 Nov 6, 2023
c29d3a8
EDSC-3797: fixed up the issues for default stuff and added the necess…
bnp26 Nov 6, 2023
3a51e5f
small fix
bnp26 Nov 6, 2023
0162953
fix
bnp26 Nov 6, 2023
07d2eb8
EDSC-3797: changed the newly added gray-text class to use text-muted
bnp26 Nov 9, 2023
178f38f
removed console.logs
bnp26 Nov 9, 2023
1eb914b
EDSC-3797: pushing up changes so that enableConcatenateDownload is no…
bnp26 Nov 13, 2023
8e1da76
removed console.log
bnp26 Nov 13, 2023
1acb09f
EDSC-3797: added tests to make sure behavior is consistent when aggre…
bnp26 Nov 13, 2023
a082ccb
Fixed buildAccessMethods test
bnp26 Nov 13, 2023
edf986a
EDSC-3797: re-added deleted test
bnp26 Nov 13, 2023
288cd63
removed console.log
bnp26 Nov 13, 2023
7d445b9
Merge branch 'main' of https://github.com/nasa/earthdata-search into …
bnp26 Nov 13, 2023
ffa4f83
EDSC-3797: addresses Matthew's comments
bnp26 Nov 13, 2023
414c59e
EDSC-3797: changed the wording on the description of the concatenatio…
bnp26 Nov 13, 2023
9fe558d
EDSC-3797: slight change to one of the test descriptions
bnp26 Nov 13, 2023
421e7a0
EDSC-3797: added encoder and decoder for concatenateDownload.
bnp26 Nov 13, 2023
7a10a59
EDSC-3797: added tests to check concatenate Download variable in the …
bnp26 Nov 13, 2023
85712f0
EDSC-3797: set enabledConcatenateDownload to be equal to the defaultC…
bnp26 Nov 13, 2023
f97c309
Update static/src/js/util/accessMethods/__tests__/defaultConcatenatio…
bnp26 Nov 14, 2023
37fa7dc
Merge branch 'EDSC-3797' of https://github.com/nasa/earthdata-search …
bnp26 Nov 14, 2023
344b7b3
EDSC-3797: reverted certain variables
bnp26 Nov 14, 2023
b56e01b
Merge branch 'main' into EDSC-3797
bnp26 Nov 15, 2023
457a5cb
EDSC-3797: updated the wording and moved around tests to match best p…
bnp26 Nov 15, 2023
e5a5886
Merge branch 'main' of https://github.com/nasa/earthdata-search into …
bnp26 Nov 15, 2023
977c0ca
Merge branch 'EDSC-3797' of https://github.com/nasa/earthdata-search …
bnp26 Nov 15, 2023
951248d
spelling mistake fix
bnp26 Nov 16, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,115 @@ describe('constructOrderPayload', () => {
})
})
})

describe('when only concatenation is supported', () => {
test('constructs a payload containing supportsConcatenation = true and enableConcatenateDownload = true', async () => {
bnp26 marked this conversation as resolved.
Show resolved Hide resolved
nock(/cmr/)
.matchHeader('Authorization', 'Bearer access-token')
.get('/search/granules.json?point%5B%5D=-77%2C%2034')
.reply(200, {
feed: {
entry: [{
id: 'G10000001-EDSC'
}, {
id: 'G10000005-EDSC'
}]
}
})

const granuleParams = {
point: ['-77, 34']
}

const accessMethod = {
supportsConcatenation: true,
enableConcatenateDownload: true
}

const accessToken = 'access-token'

const response = await constructOrderPayload({
accessMethod,
granuleParams,
accessToken
})

expect(response.getAll('concatenate')).toEqual([
'true'
])
})

test('constructs a payload containing supportsConcatenation = true and enableConcatenateDownload = false', async () => {
nock(/cmr/)
.matchHeader('Authorization', 'Bearer access-token')
.get('/search/granules.json?point%5B%5D=-77%2C%2034')
.reply(200, {
feed: {
entry: [{
id: 'G10000001-EDSC'
}, {
id: 'G10000005-EDSC'
}]
}
})

const granuleParams = {
point: ['-77, 34']
}

const accessMethod = {
supportsConcatenation: true,
enableConcatenateDownload: false
}

const accessToken = 'access-token'

const response = await constructOrderPayload({
accessMethod,
granuleParams,
accessToken
})

expect(response.getAll('concatenate')).not.toEqual([
'true'
])
})
})

describe('when concatenation is not supported', () => {
test('constructs a payload containing supportsConcatenation = false', async () => {
nock(/cmr/)
.matchHeader('Authorization', 'Bearer access-token')
.get('/search/granules.json?point%5B%5D=-77%2C%2034')
.reply(200, {
feed: {
entry: [{
id: 'G10000001-EDSC'
}, {
id: 'G10000005-EDSC'
}]
}
})

const granuleParams = {
point: ['-77, 34']
}

const accessMethod = {
supportsConcatenation: false
}

const accessToken = 'access-token'

const response = await constructOrderPayload({
accessMethod,
granuleParams,
accessToken
})

expect(response.getAll('concatenate')).not.toEqual([
'true'
])
})
})
})
9 changes: 8 additions & 1 deletion serverless/src/submitHarmonyOrder/constructOrderPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export const constructOrderPayload = async ({
const {
enableTemporalSubsetting,
enableSpatialSubsetting,
enableConcatenateDownload,
mbr,
selectedOutputFormat,
selectedOutputProjection,
supportsBoundingBoxSubsetting,
supportsShapefileSubsetting
supportsShapefileSubsetting,
supportsConcatenation
} = accessMethod

// OGC uses duplicate parameter names for subsetting and the
Expand Down Expand Up @@ -215,6 +217,11 @@ export const constructOrderPayload = async ({
orderPayload.append('outputCrs', selectedOutputProjection)
}

// Adds supportsConcatenation to the payload and it's value
if (supportsConcatenation && enableConcatenateDownload) {
bnp26 marked this conversation as resolved.
Show resolved Hide resolved
orderPayload.append('concatenate', true)
}

// EDSC-3440: Add skipPreview=true to all Harmony orders
orderPayload.append('skipPreview', true)

Expand Down
75 changes: 68 additions & 7 deletions static/src/js/components/AccessMethod/AccessMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export class AccessMethod extends Component {
enableTemporalSubsetting = !isRecurring
} = selectedMethod || {}

const {
enableConcatenateDownload
} = selectedMethod || false

const {
enableSpatialSubsetting = !(
boundingBox === undefined
Expand All @@ -73,14 +77,16 @@ export class AccessMethod extends Component {

this.state = {
enableTemporalSubsetting,
enableSpatialSubsetting
enableSpatialSubsetting,
enableConcatenateDownload
}

this.handleAccessMethodSelection = this.handleAccessMethodSelection.bind(this)
this.handleOutputFormatSelection = this.handleOutputFormatSelection.bind(this)
this.handleOutputProjectionSelection = this.handleOutputProjectionSelection.bind(this)
this.handleToggleTemporalSubsetting = this.handleToggleTemporalSubsetting.bind(this)
this.handleToggleSpatialSubsetting = this.handleToggleSpatialSubsetting.bind(this)
this.handleConcatenationSelection = this.handleConcatenationSelection.bind(this)
}

UNSAFE_componentWillReceiveProps() {
Expand Down Expand Up @@ -141,6 +147,25 @@ export class AccessMethod extends Component {
})
}

handleConcatenationSelection(event) {
const { metadata, onUpdateAccessMethod, selectedAccessMethod } = this.props
const { conceptId: collectionId } = metadata

const { target } = event
const { checked } = target

this.setState({ enableConcatenateDownload: checked })

onUpdateAccessMethod({
collectionId,
method: {
[selectedAccessMethod]: {
enableConcatenateDownload: checked
}
}
})
}

handleToggleTemporalSubsetting(event) {
const { metadata, onUpdateAccessMethod, selectedAccessMethod } = this.props
const { conceptId: collectionId } = metadata
Expand Down Expand Up @@ -207,11 +232,6 @@ export class AccessMethod extends Component {
}

render() {
const {
enableTemporalSubsetting,
enableSpatialSubsetting
} = this.state

const {
accessMethods,
index,
Expand Down Expand Up @@ -337,9 +357,17 @@ export class AccessMethod extends Component {
supportsTemporalSubsetting = false,
supportsShapefileSubsetting = false,
supportsBoundingBoxSubsetting = false,
supportsVariableSubsetting = false
supportsVariableSubsetting = false,
supportsConcatenation = false,
defaultConcatenation = false
} = selectedMethod || {}

const {
enableTemporalSubsetting,
enableSpatialSubsetting,
enableConcatenateDownload = defaultConcatenation
} = this.state

const isOpendap = (selectedAccessMethod && selectedAccessMethod === 'opendap')

// Harmony access methods are postfixed with an index given that there can be more than one
Expand Down Expand Up @@ -392,6 +420,7 @@ export class AccessMethod extends Component {
|| supportsBoundingBoxSubsetting
|| supportedOutputFormatOptions.length > 0
|| supportedOutputProjectionOptions.length > 0
|| supportsConcatenation
|| (form && isActive)

const {
Expand Down Expand Up @@ -496,6 +525,38 @@ export class AccessMethod extends Component {
</ProjectPanelSection>
)
}
{
supportsConcatenation && (
<ProjectPanelSection
customHeadingTag="h4"
heading="Combine Data"
intro="Select from available operations to combine the data."
nested
>
<Form.Group controlId="input__concatinate-subsetting" className="mb-0">
<Form.Check
id="input__concatinate-subsetting"
type="checkbox"
label={
(
<div>
<span className="mb-1 d-block">
Enable Concatenation
</span>
<span className="mb-1 d-block text-muted">
Data will be concatenated along a newly created dimension
</span>
</div>
)
}
checked={enableConcatenateDownload}
disabled={isRecurring}
onChange={this.handleConcatenationSelection}
/>
</Form.Group>
</ProjectPanelSection>
)
}
{
supportsTemporalSubsetting && (
<ProjectPanelSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ describe('AccessMethod component', () => {

const checkbox = screen.getByRole('checkbox')
await user.click(checkbox)
expect(screen.getByRole('checkbox').checked).toEqual(true)
expect(checkbox.checked).toEqual(true)
})

test('calls onUpdateAccessMethod', async () => {
Expand Down Expand Up @@ -1140,6 +1140,89 @@ describe('AccessMethod component', () => {
expect(screen.getByText(/using the harmony-service-name/)).toBeInTheDocument()
})
})

describe('when the service type is `Harmony` and concatenation is available', () => {
test('the `Combine Data` option is avaialable when concatenation service is true', () => {
const collectionId = 'collectionId'
const serviceName = 'harmony-service-name'
setup({
accessMethods: {
harmony0: {
isValid: true,
type: 'Harmony',
name: serviceName,
supportsConcatenation: true,
defaultConcatenation: true
}
},
metadata: {
conceptId: collectionId
},
selectedAccessMethod: 'harmony0'
})

expect(screen.getByText(/The requested data will be processed/)).toBeInTheDocument()
expect(screen.getByText(/Combine Data/)).toBeInTheDocument()
expect(screen.getByRole('checkbox').checked).toEqual(true)
})

test('when the `Combine Data` option is clicked, the enableConcatenateDownload changes', async () => {
const user = userEvent.setup()
const collectionId = 'collectionId'
const serviceName = 'harmony-service-name'
const { onUpdateAccessMethod } = setup({
accessMethods: {
harmony0: {
isValid: true,
type: 'Harmony',
name: serviceName,
supportsConcatenation: true,
defaultConcatenation: false
}
},
metadata: {
conceptId: collectionId
},
selectedAccessMethod: 'harmony0'
})

expect(screen.getByText(/The requested data will be processed/)).toBeInTheDocument()
expect(screen.getByText(/Combine Data/)).toBeInTheDocument()
await user.click(screen.getByRole('checkbox'))

expect(onUpdateAccessMethod).toHaveBeenCalledTimes(1)
expect(onUpdateAccessMethod).toHaveBeenCalledWith({
collectionId: 'collectionId',
method: { harmony0: { enableConcatenateDownload: true } }
})

expect(screen.getByRole('checkbox').checked).toEqual(true)
})
})

describe('when the service type is `Harmony` and concatenation is unavailable', () => {
test('when the `Combine Data` option is clicked, the enableConcatenateDownload changes', async () => {
const collectionId = 'collectionId'
const serviceName = 'harmony-service-name'
setup({
accessMethods: {
harmony0: {
isValid: true,
type: 'Harmony',
name: serviceName,
supportsConcatenation: false,
enableConcatenateDownload: false
}
},
metadata: {
conceptId: collectionId
},
selectedAccessMethod: 'harmony0'
})

expect(screen.queryAllByText(/Combine Data/)).toHaveLength(0)
})
})
})
})
})
Loading