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

Issue#16: Change apply opera treatment choice and lambda to be specific to HLS #24

Merged
merged 3 commits into from
May 30, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- [issues/15](https://github.com/podaac/bignbit/issues/15): Change 'convertToPNG' choice to a generic send to harmony choice
- [issues/16](https://github.com/podaac/bignbit/issues/16): Change apply opera treatment choice and lambda to be specific to HLS

## [0.1.1]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from bignbit import utils

CUMULUS_LOGGER = CumulusLogger('apply_opera_treatment')
CUMULUS_LOGGER = CumulusLogger('apply_opera_hls_treatment')


def load_mgrs_gibs_intersection():
Expand Down Expand Up @@ -61,7 +61,7 @@ def process(self) -> List[Dict]:

def transform_images(cma_file_list: List[Dict], temp_dir: pathlib.Path, mgrs_grid_code: str) -> List[Dict]:
"""
Applies special OPERA processing to each input image. Each input image will result in multiple output transformed
Applies special OPERA HLS processing to each input image. Each input image will result in multiple output transformed
images.

Parameters
Expand Down Expand Up @@ -91,8 +91,8 @@ def transform_images(cma_file_list: List[Dict], temp_dir: pathlib.Path, mgrs_gri
# Reproject and resample image to sub-tiles
transformed_images_dirpath = temp_dir.joinpath(source_image_local_filepath.stem)
transformed_images_dirpath.mkdir(parents=True)
transformed_images_filepaths = the_opera_treatment(source_image_local_filepath, transformed_images_dirpath,
mgrs_grid_code)
transformed_images_filepaths = the_opera_hls_treatment(source_image_local_filepath, transformed_images_dirpath,
mgrs_grid_code)
CUMULUS_LOGGER.info(f'Created new images: {[str(t) for t in transformed_images_filepaths]}')

# Create new file metadata for each new image
Expand Down Expand Up @@ -138,8 +138,8 @@ def get_file(bucket: str, key: str, local_filepath: pathlib.Path) -> pathlib.Pat
return local_filepath


def the_opera_treatment(source_image_filepath: pathlib.Path, working_dirpath: pathlib.Path,
mgrs_grid_code: str) -> List[pathlib.Path]:
def the_opera_hls_treatment(source_image_filepath: pathlib.Path, working_dirpath: pathlib.Path,
mgrs_grid_code: str) -> List[pathlib.Path]:
"""
What is the OPERA treatment? Well, it is special.

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ COPY --chown=dockeruser docker/docker-entrypoint.sh /home/dockeruser/.local/bin/
RUN chmod 755 /home/dockeruser/.local/bin/aws-lambda-rie /home/dockeruser/.local/bin/docker-entrypoint.sh && \
touch bignbit/__init__.py
ENTRYPOINT [ "/home/dockeruser/.local/bin/docker-entrypoint.sh" ]
CMD [ "bignbit.apply_opera_treatment.lambda_handler" ]
CMD [ "bignbit.apply_opera_hls_treatment.lambda_handler" ]
6 changes: 3 additions & 3 deletions terraform/lambda_functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,17 @@ resource "aws_lambda_function" "copy_harmony_output_to_s3" {
tags = var.default_tags
}

resource "aws_lambda_function" "apply_opera_treatment" {
resource "aws_lambda_function" "apply_opera_hls_treatment" {
depends_on = [
null_resource.upload_ecr_image
]

package_type = "Image"
image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}"
image_config {
command = ["bignbit.apply_opera_treatment.lambda_handler"]
command = ["bignbit.apply_opera_hls_treatment.lambda_handler"]
}
function_name = "${local.lambda_resources_name}-apply_opera_treatment-lambda"
function_name = "${local.lambda_resources_name}-apply_opera_hls_treatment-lambda"
role = var.lambda_role.arn
timeout = 30
memory_size = 512
Expand Down
2 changes: 1 addition & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data "template_file" "workflow_definition" {
ConfigDir = var.config_dir,
GetGranuleUmmJsonLambda = aws_lambda_function.get_granule_umm_json.arn,
IdentifyImageFileLambda = aws_lambda_function.identify_image_file.arn,
ApplyOperaTreatmentLambda = aws_lambda_function.apply_opera_treatment.arn,
ApplyOperaHLSTreatmentLambda = aws_lambda_function.apply_opera_hls_treatment.arn,
GetCollectionConceptIdLambda = aws_lambda_function.get_collection_concept_id.arn,
SubmitHarmonyJobLambda = aws_lambda_function.submit_harmony_job.arn,
GetHarmonyJobStatusLambda = aws_lambda_function.get_harmony_job_status.arn,
Expand Down
4 changes: 2 additions & 2 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ output "copy_harmony_output_to_s3_arn"{
value = aws_lambda_function.copy_harmony_output_to_s3.arn
}

output "apply_opera_treatment_arn"{
value = aws_lambda_function.apply_opera_treatment.arn
output "apply_opera_hls_treatment_arn"{
value = aws_lambda_function.apply_opera_hls_treatment.arn
}

output "pobit_build_image_sets_arn" {
Expand Down
16 changes: 8 additions & 8 deletions terraform/state_machine_definition.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,31 @@
"BackoffRate":2
}
],
"Next":"Apply OPERA Treatment?"
"Next":"Apply OPERA HLS Treatment?"
},
"Apply OPERA Treatment?":{
"Apply OPERA HLS Treatment?":{
"Type":"Choice",
"Choices":[
{
"And":[
{
"Variable":"$.payload.datasetConfigurationForBIG.config.operaTreatment",
"Variable":"$.payload.datasetConfigurationForBIG.config.operaHLSTreatment",
"IsPresent":true
},
{
"Variable":"$.payload.datasetConfigurationForBIG.config.operaTreatment",
"Variable":"$.payload.datasetConfigurationForBIG.config.operaHLSTreatment",
"BooleanEquals":true
}
],
"Comment":"If operaTreatment is true",
"Next":"Apply OPERA Treatment"
"Comment":"If operaHLSTreatment is true",
"Next":"Apply OPERA HLS Treatment"
}
],
"Default":"Generate Image Metadata"
},
"Apply OPERA Treatment":{
"Apply OPERA HLS Treatment":{
"Type":"Task",
"Resource":"${ApplyOperaTreatmentLambda}",
"Resource":"${ApplyOperaHLSTreatmentLambda}",
"Parameters":{
"cma":{
"event.$":"$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from bignbit.apply_opera_treatment import the_opera_treatment
from bignbit.apply_opera_hls_treatment import the_opera_hls_treatment


@pytest.fixture()
Expand All @@ -15,10 +15,10 @@ def cnm_v151_schema():
return cnm_schema


def test_the_opera_treatment(tmp_path):
def test_the_opera_hls_treatment(tmp_path):
test_data_input = pathlib.Path(dirname(realpath(__file__))).joinpath('data').joinpath(
'OPERA_L3_DSWx-HLS_T48SUE_20190302T034350Z_20230131T222341Z_L8_30_v0.0_BROWSE.tiff')

result = the_opera_treatment(test_data_input, tmp_path, 'T48SUE')
result = the_opera_hls_treatment(test_data_input, tmp_path, 'T48SUE')

assert result
Loading