Skip to content

Commit

Permalink
Changes for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
danscales committed Jun 17, 2024
1 parent 1b30cf7 commit 28f46ae
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 98 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/terraform_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ jobs:
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Test with pytest
env:
ENV: test
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test # pragma: allowlist secret
AWS_DEFAULT_REGION: ${{ secrets.aws_region_dev }}
LOCALSTACK_API_KEY: ${{ secrets.localstack_api_key }}
DUMP_TO_STDOUT: true
run: |
./scripts/test
- name: Deploy production
if: success() && contains(github.ref, 'master')
env:
Expand Down
4 changes: 2 additions & 2 deletions src/datapump/commands/version_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class RasterVersionUpdateCommand(StrictBaseModel):
command: str
parameters: RasterVersionUpdateParameters


class CogAssetParameters(StrictBaseModel):
implementation: str
source_pixel_meaning: str
resampling: str = "mode"
blocksize: int

resampling: str = "mode"
1 change: 0 additions & 1 deletion src/datapump/jobs/version_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def _create_cog_asset(self, cog_asset_parameters: CogAssetParameters) -> str:
for asset in assets:
if asset["asset_type"] == "Raster tile set" and f"/{co.source_pixel_meaning}/" in asset["asset_uri"]:
if asset_id != "":

self.errors.append(f"Multiple assets with pixel meaning '{co.source_pixel_meaning}'")
return ""
asset_id = asset["asset_id"]
Expand Down
143 changes: 72 additions & 71 deletions src/datapump/sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,85 +203,86 @@ def build_jobs(self, config: DatapumpConfig) -> List[Job]:
for dataset, version in latest_versions.items()
]

if not self._should_update(latest_versions):
return []
# For testing, always force an integrated_alerts update
# if not self._should_update(latest_versions):
# return []

jobs = []

if config.dataset == "gadm":
jobs.append(
RasterVersionUpdateJob(
id=str(uuid1()),
status=JobStatus.starting,
dataset=self.DATASET_NAME,
version=self.sync_version,
tile_set_parameters=RasterTileSetParameters(
source_uri=source_uris,
calc=self.INPUT_CALC,
grid="10/100000",
data_type="uint16",
no_data=0,
pixel_meaning="date_conf",
band_count=1,
union_bands=True,
compute_stats=False,
timeout_sec=21600,
),
tile_cache_parameters=RasterTileCacheParameters(
max_zoom=14,
resampling="med",
symbology={"type": "date_conf_intensity_multi_8"},
),
aux_tile_set_parameters=RasterTileSetParameters(
[
RasterTileSetParameters(
pixel_meaning="intensity",
data_type="uint8",
calc="(A > 0) * 255",
grid="10/100000"
)
]
),
cog_asset_parameters=CogAssetParameters(
[
# Created from the "date_conf" asset
CogAssetParameters(
source_pixel_meaning="date_conf",
resampling="mode",
implementation="default",
blocksize=1024
),
# Created from the "intensity" asset
CogAssetParameters(
source_pixel_meaning="intensity",
resampling="bilinear",
implementation="intensity",
blocksize=1024
),
]
),
content_date_range=ContentDateRange(
start_date="2014-12-31", end_date=str(date.today())
),
)
)
jobs.append(
GeotrellisJob(
job = RasterVersionUpdateJob(
id=str(uuid1()),
status=JobStatus.starting,
analysis_version=config.analysis_version,
sync_version=self.sync_version,
sync_type=config.sync_type,
table=AnalysisInputTable(
dataset=config.dataset,
version=config.dataset_version,
analysis=config.analysis,
dataset=self.DATASET_NAME,
version=self.sync_version,
tile_set_parameters=RasterTileSetParameters(
source_uri=source_uris,
calc=self.INPUT_CALC,
grid="10/100000",
data_type="uint16",
no_data=0,
pixel_meaning="date_conf",
band_count=1,
union_bands=True,
compute_stats=False,
timeout_sec=21600,
),
tile_cache_parameters=RasterTileCacheParameters(
max_zoom=14,
resampling="med",
symbology={"type": "date_conf_intensity_multi_8"},
),
content_date_range=ContentDateRange(
start_date="2014-12-31", end_date=str(date.today())
),
features_1x1=config.metadata["features_1x1"],
geotrellis_version=config.metadata["geotrellis_version"],
timeout_sec=6 * 3600,
)
)
job.aux_tile_set_parameters = [
RasterTileSetParameters(
source_uri=None,
pixel_meaning="intensity",
data_type="uint8",
calc="(A > 0) * 255",
grid="10/100000",
no_data=0,
)
]
job.cog_asset_parameters = [
# Created from the "date_conf" asset
CogAssetParameters(
source_pixel_meaning="date_conf",
resampling="mode",
implementation="default",
blocksize=1024,
),
# Created from the "intensity" asset
CogAssetParameters(
source_pixel_meaning="intensity",
resampling="bilinear",
implementation="intensity",
blocksize=1024,
),
]

jobs.append(job)

# Disable for testing
# jobs.append(
# GeotrellisJob(
# id=str(uuid1()),
# status=JobStatus.starting,
# analysis_version=config.analysis_version,
# sync_version=self.sync_version,
# sync_type=config.sync_type,
# table=AnalysisInputTable(
# dataset=config.dataset,
# version=config.dataset_version,
# analysis=config.analysis,
# ),
# features_1x1=config.metadata["features_1x1"],
# geotrellis_version=config.metadata["geotrellis_version"],
# timeout_sec=6 * 3600,
# )
# )

return jobs

Expand Down
14 changes: 12 additions & 2 deletions src/lambdas/dispatcher/src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,30 @@ def _raster_version_update(command: RasterVersionUpdateCommand):
return [job.dict()]


from datapump.clients.datapump_store import DatapumpConfig


def _sync(command: SyncCommand):
jobs = []
syncer = Syncer(command.parameters.types, command.parameters.sync_version)
config_client = DatapumpStore()
# config_client = DatapumpStore()

for sync_type in command.parameters.types:
sync_config = config_client.get(sync=True, sync_type=sync_type)
# sync_config = config_client.get(sync=True, sync_type=sync_type)
sync_config = [DatapumpConfig(analysis_version="1.0", dataset="gadm",
dataset_version="3.6",
analysis="forest_change_diagnostic",
sync=True,
sync_type="integrated_alerts")]
if not sync_config:
slack_webhook(
"WARNING",
f"No DyanamoDB rows found for sync type {sync_type}!"
)
LOGGER.warning(f"No DyanamoDB rows found for sync type {sync_type}!")
for row in sync_config:
syncer_jobs = syncer.build_jobs(row)
LOGGER.info(f"Processing row {row}, got jobs {syncer_jobs}!")
if syncer_jobs:
jobs += [job.dict() for job in syncer_jobs]

Expand Down
24 changes: 12 additions & 12 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -e

if ! [ -f "/app/tests/files/mock_geotrellis/target/geotrellis-mock-0.1.0-shaded.jar" ]; then
cd /app/tests/files/mock_geotrellis
mvn package
if [[ "$?" -ne 0 ]] ; then
echo 'Error building mock geotrellis jar, exiting'; exit 1
fi
fi
# if ! [ -f "/app/tests/files/mock_geotrellis/target/geotrellis-mock-0.1.0-shaded.jar" ]; then
# cd /app/tests/files/mock_geotrellis
# mvn package
# if [[ "$?" -ne 0 ]] ; then
# echo 'Error building mock geotrellis jar, exiting'; exit 1
# fi
# fi

mkdir -p /app/tests/logs
# mkdir -p /app/tests/logs

cd /app/tests/terraform
terraform init && terraform plan -var-file="/app/tests/terraform/terraform-test.tfvars" && terraform apply -auto-approve -var-file="/app/tests/terraform/terraform-test.tfvars"
cd /app/tests
# cd /app/tests/terraform
# terraform init && terraform plan -var-file="/app/tests/terraform/terraform-test.tfvars" && terraform apply -auto-approve -var-file="/app/tests/terraform/terraform-test.tfvars"

pytest tests
# cd /app/tests
# pytest tests

0 comments on commit 28f46ae

Please sign in to comment.