diff --git a/.github/actions/deploy_infrastructure/action.yml b/.github/actions/deploy_infrastructure/action.yml index bfc958c7..9984d9b9 100644 --- a/.github/actions/deploy_infrastructure/action.yml +++ b/.github/actions/deploy_infrastructure/action.yml @@ -76,14 +76,18 @@ runs: command: up stack-name: ${{ inputs.environment }} - # Copy shared database_client.py files - - name: Copy Shared File + - name: Copy common db files shell: bash run: | - mkdir -p cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/ - cp cerulean_cloud/database_client.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/database_client.py - cp cerulean_cloud/database_schema.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/database_schema.py - cp cerulean_cloud/__init__.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/__init__.py + mkdir -p cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/common + cp \ + cerulean_cloud/__init__.py \ + cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/ + cp \ + cerulean_cloud/common/__init__.py \ + cerulean_cloud/common/database_client.py \ + cerulean_cloud/common/database_schema.py \ + cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/common/ - name: Deploy Infrastructure uses: pulumi/actions@v5 diff --git a/Dockerfiles/Dockerfile.cloud_run_offset b/Dockerfiles/Dockerfile.cloud_run_offset index a6bb982b..54099f77 100644 --- a/Dockerfiles/Dockerfile.cloud_run_offset +++ b/Dockerfiles/Dockerfile.cloud_run_offset @@ -18,14 +18,16 @@ RUN pip install \ -r requirements.txt RUN pip install \ - --isolated \ - --no-cache-dir \ - --disable-pip-version-check \ - 'cyclonedx-bom<4.0.0' \ - && pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force \ - && rm requirements.txt - -COPY cerulean_cloud/ /app/cerulean_cloud/ + --isolated \ + --no-cache-dir \ + --disable-pip-version-check \ + 'cyclonedx-bom<4.0.0' +RUN pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force +RUN rm requirements.txt + +COPY cerulean_cloud/__init__.py /app/cerulean_cloud/ +COPY cerulean_cloud/common /app/cerulean_cloud/common +COPY cerulean_cloud/cloud_run_offset_tiles /app/cerulean_cloud/cloud_run_offset_tiles FROM gcr.io/distroless/python3-debian11:debug-nonroot AS final diff --git a/Dockerfiles/Dockerfile.cloud_run_orchestrator b/Dockerfiles/Dockerfile.cloud_run_orchestrator index 26beb3d1..cf1dee66 100644 --- a/Dockerfiles/Dockerfile.cloud_run_orchestrator +++ b/Dockerfiles/Dockerfile.cloud_run_orchestrator @@ -1,7 +1,6 @@ FROM python:3.9-slim AS build-env WORKDIR /app -COPY cerulean_cloud/ /app/cerulean_cloud/ SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -14,16 +13,20 @@ RUN pip install \ --no-warn-script-location \ --isolated \ --target ./site-packages \ - -r ./requirements.txt \ - && pip install \ - --isolated \ - --no-cache-dir \ - --disable-pip-version-check \ - 'cyclonedx-bom<4.0.0' \ - && pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force \ - && rm requirements.txt - -COPY cerulean_cloud/ /app/cerulean_cloud/ + -r ./requirements.txt +RUN pip install \ + --isolated \ + --no-cache-dir \ + --disable-pip-version-check \ + 'cyclonedx-bom<4.0.0' +RUN pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force +RUN rm requirements.txt + +COPY cerulean_cloud/__init__.py /app/cerulean_cloud/ +COPY cerulean_cloud/common /app/cerulean_cloud/common +COPY cerulean_cloud/cloud_run_orchestrator /app/cerulean_cloud/cloud_run_orchestrator +COPY cerulean_cloud/cloud_run_offset_tiles /app/cerulean_cloud/cloud_run_offset_tiles +COPY cerulean_cloud/cloud_function_ais_analysis /app/cerulean_cloud/cloud_function_ais_analysis FROM gcr.io/distroless/python3-debian11:debug-nonroot AS final diff --git a/Dockerfiles/Dockerfile.cloud_run_tipg b/Dockerfiles/Dockerfile.cloud_run_tipg index 890c7123..c7989293 100644 --- a/Dockerfiles/Dockerfile.cloud_run_tipg +++ b/Dockerfiles/Dockerfile.cloud_run_tipg @@ -16,16 +16,19 @@ RUN pip install \ --no-cache-dir \ --upgrade \ --target ./site-packages \ - -r ./requirements.txt \ - && pip install \ - --isolated \ - --no-cache-dir \ - --disable-pip-version-check \ - 'cyclonedx-bom<4.0.0' \ - && pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force \ - && rm requirements.txt + -r ./requirements.txt -COPY cerulean_cloud/ /app/cerulean_cloud/ +RUN pip install \ + --isolated \ + --no-cache-dir \ + --disable-pip-version-check \ + 'cyclonedx-bom<4.0.0' +RUN pip freeze --path ./site-packages | cyclonedx-py -r -i - --purl-bom-ref --format xml -o sbom.xml --force +RUN rm requirements.txt + +COPY cerulean_cloud/__init__.py /app/cerulean_cloud/ +COPY cerulean_cloud/common /app/cerulean_cloud/common +COPY cerulean_cloud/cloud_run_tipg /app/cerulean_cloud/cloud_run_tipg FROM gcr.io/distroless/python3-debian11:debug-nonroot AS final diff --git a/Dockerfiles/Dockerfile.titiler b/Dockerfiles/Dockerfile.titiler index ef01aeb2..300739d4 100644 --- a/Dockerfiles/Dockerfile.titiler +++ b/Dockerfiles/Dockerfile.titiler @@ -5,8 +5,8 @@ WORKDIR /var/task COPY cerulean_cloud/titiler_sentinel/requirements.txt ./requirements.txt COPY cerulean_cloud/titiler_sentinel/handler.py handler.py -COPY cerulean_cloud/auth.py auth.py COPY cerulean_cloud/titiler_sentinel/templates/ ./templates +COPY cerulean_cloud/common/auth.py auth.py # Use after upgrade of Pulumi Docker to >= 4 # COPY --chown=root:root --chmod=400 Dockerfiles/scripts/titiler-entrypoint.sh /entrypoint.sh diff --git a/alembic/versions/5e03ce584f3c_add_eez.py b/alembic/versions/5e03ce584f3c_add_eez.py index 38fc367d..95ec9a7f 100644 --- a/alembic/versions/5e03ce584f3c_add_eez.py +++ b/alembic/versions/5e03ce584f3c_add_eez.py @@ -12,7 +12,7 @@ from shapely.geometry import MultiPolygon, shape from sqlalchemy import orm -import cerulean_cloud.database_schema as database_schema +import cerulean_cloud.common.database_schema as database_schema from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/c0bd1215a3ca_add_iho.py b/alembic/versions/c0bd1215a3ca_add_iho.py index 4c220ac4..af5364ad 100644 --- a/alembic/versions/c0bd1215a3ca_add_iho.py +++ b/alembic/versions/c0bd1215a3ca_add_iho.py @@ -12,7 +12,7 @@ from shapely.geometry import MultiPolygon, shape from sqlalchemy import orm -import cerulean_cloud.database_schema as database_schema +import cerulean_cloud.common.database_schema as database_schema from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/c941681a050d_add_initial_records.py b/alembic/versions/c941681a050d_add_initial_records.py index 173c2ff9..0440866a 100644 --- a/alembic/versions/c941681a050d_add_initial_records.py +++ b/alembic/versions/c941681a050d_add_initial_records.py @@ -10,7 +10,7 @@ from sqlalchemy import orm -import cerulean_cloud.database_schema as database_schema +import cerulean_cloud.common.database_schema as database_schema from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/f9b7166c86b7_add_mpa.py b/alembic/versions/f9b7166c86b7_add_mpa.py index 0972126e..98194860 100644 --- a/alembic/versions/f9b7166c86b7_add_mpa.py +++ b/alembic/versions/f9b7166c86b7_add_mpa.py @@ -12,7 +12,7 @@ from shapely.geometry import MultiPolygon, shape from sqlalchemy import orm -import cerulean_cloud.database_schema as database_schema +import cerulean_cloud.common.database_schema as database_schema from alembic import op # revision identifiers, used by Alembic. diff --git a/cerulean_cloud/cloud_function_ais_analysis/main.py b/cerulean_cloud/cloud_function_ais_analysis/main.py index e584d060..41e1c154 100644 --- a/cerulean_cloud/cloud_function_ais_analysis/main.py +++ b/cerulean_cloud/cloud_function_ais_analysis/main.py @@ -11,7 +11,7 @@ from shapely import wkb from utils.analyzer import ASA_MAPPING -from cerulean_cloud.database_client import DatabaseClient, get_engine +from cerulean_cloud.common.database_client import DatabaseClient, get_engine def verify_api_key(request): diff --git a/cerulean_cloud/cloud_run_offset_tiles/handler.py b/cerulean_cloud/cloud_run_offset_tiles/handler.py index 6dc4c095..a43b41e3 100644 --- a/cerulean_cloud/cloud_run_offset_tiles/handler.py +++ b/cerulean_cloud/cloud_run_offset_tiles/handler.py @@ -9,12 +9,12 @@ from fastapi_utils.timing import add_timing_middleware, record_timing from starlette.requests import Request -from cerulean_cloud.auth import api_key_auth from cerulean_cloud.cloud_run_offset_tiles.schema import ( InferenceResultStack, PredictPayload, ) -from cerulean_cloud.models import get_model +from cerulean_cloud.common.auth import api_key_auth +from cerulean_cloud.common.models import get_model # mypy: ignore-errors diff --git a/cerulean_cloud/cloud_run_offset_tiles/requirements.txt b/cerulean_cloud/cloud_run_offset_tiles/requirements.txt index 41d66c0c..037c1578 100644 --- a/cerulean_cloud/cloud_run_offset_tiles/requirements.txt +++ b/cerulean_cloud/cloud_run_offset_tiles/requirements.txt @@ -3,8 +3,9 @@ starlette-cramjam==0.1.0 uvicorn[standard] rasterio==1.3.0 setuptools==59.5.0 -torch==1.11.0 -torchvision==0.12.0 +-f https://download.pytorch.org/whl/cpu/torch_stable.html +torch==1.11.0+cpu +torchvision==0.12.0+cpu numpy<2.0.0 typing-inspect fastapi-utils diff --git a/cerulean_cloud/cloud_run_orchestrator/handler.py b/cerulean_cloud/cloud_run_orchestrator/handler.py index 61e2ddb4..8037abdb 100644 --- a/cerulean_cloud/cloud_run_orchestrator/handler.py +++ b/cerulean_cloud/cloud_run_orchestrator/handler.py @@ -23,18 +23,18 @@ from global_land_mask import globe from shapely.geometry import shape -from cerulean_cloud.auth import api_key_auth from cerulean_cloud.cloud_function_ais_analysis.queuer import add_to_asa_queue from cerulean_cloud.cloud_run_orchestrator.clients import CloudRunInferenceClient from cerulean_cloud.cloud_run_orchestrator.schema import ( OrchestratorInput, OrchestratorResult, ) -from cerulean_cloud.database_client import DatabaseClient, get_engine -from cerulean_cloud.models import get_model -from cerulean_cloud.roda_sentinelhub_client import RodaSentinelHubClient -from cerulean_cloud.tiling import TMS, offset_bounds_from_base_tiles -from cerulean_cloud.titiler_client import TitilerClient +from cerulean_cloud.common.auth import api_key_auth +from cerulean_cloud.common.database_client import DatabaseClient, get_engine +from cerulean_cloud.common.models import get_model +from cerulean_cloud.common.roda_sentinelhub_client import RodaSentinelHubClient +from cerulean_cloud.common.tiling import TMS, offset_bounds_from_base_tiles +from cerulean_cloud.common.titiler_client import TitilerClient app = FastAPI(title="Cloud Run orchestrator", dependencies=[Depends(api_key_auth)]) # Allow CORS for local debugging diff --git a/cerulean_cloud/cloud_run_orchestrator/requirements.txt b/cerulean_cloud/cloud_run_orchestrator/requirements.txt index 4a220b2e..6fd260d7 100644 --- a/cerulean_cloud/cloud_run_orchestrator/requirements.txt +++ b/cerulean_cloud/cloud_run_orchestrator/requirements.txt @@ -24,8 +24,9 @@ pygeos networkx google-cloud-tasks protobuf -torch==1.11.0 -torchvision==0.12.0 +-f https://download.pytorch.org/whl/cpu/torch_stable.html +torch==1.11.0+cpu +torchvision==0.12.0+cpu scipy scikit-image pydantic<2.0 \ No newline at end of file diff --git a/cerulean_cloud/common/__init__.py b/cerulean_cloud/common/__init__.py new file mode 100644 index 00000000..98994805 --- /dev/null +++ b/cerulean_cloud/common/__init__.py @@ -0,0 +1 @@ +"""Common modules for Cerulean Cloud.""" diff --git a/cerulean_cloud/auth.py b/cerulean_cloud/common/auth.py similarity index 100% rename from cerulean_cloud/auth.py rename to cerulean_cloud/common/auth.py diff --git a/cerulean_cloud/database_client.py b/cerulean_cloud/common/database_client.py similarity index 99% rename from cerulean_cloud/database_client.py rename to cerulean_cloud/common/database_client.py index 51fe651a..86190cc2 100644 --- a/cerulean_cloud/database_client.py +++ b/cerulean_cloud/common/database_client.py @@ -10,7 +10,7 @@ from sqlalchemy import and_, or_, select, update from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine -import cerulean_cloud.database_schema as db +import cerulean_cloud.common.database_schema as db class InstanceNotFoundError(Exception): diff --git a/cerulean_cloud/database_schema.py b/cerulean_cloud/common/database_schema.py similarity index 100% rename from cerulean_cloud/database_schema.py rename to cerulean_cloud/common/database_schema.py diff --git a/cerulean_cloud/models.py b/cerulean_cloud/common/models.py similarity index 100% rename from cerulean_cloud/models.py rename to cerulean_cloud/common/models.py diff --git a/cerulean_cloud/roda_sentinelhub_client.py b/cerulean_cloud/common/roda_sentinelhub_client.py similarity index 99% rename from cerulean_cloud/roda_sentinelhub_client.py rename to cerulean_cloud/common/roda_sentinelhub_client.py index a613d4dc..29d16f6a 100644 --- a/cerulean_cloud/roda_sentinelhub_client.py +++ b/cerulean_cloud/common/roda_sentinelhub_client.py @@ -1,4 +1,5 @@ """client code to interact with roda http proxy to s3 s1 bucket""" + import posixpath import urllib.parse as urlib from typing import Dict diff --git a/cerulean_cloud/tiling.py b/cerulean_cloud/common/tiling.py similarity index 100% rename from cerulean_cloud/tiling.py rename to cerulean_cloud/common/tiling.py diff --git a/cerulean_cloud/titiler_client.py b/cerulean_cloud/common/titiler_client.py similarity index 99% rename from cerulean_cloud/titiler_client.py rename to cerulean_cloud/common/titiler_client.py index 4f60b520..4e3ba987 100644 --- a/cerulean_cloud/titiler_client.py +++ b/cerulean_cloud/common/titiler_client.py @@ -10,7 +10,7 @@ from rasterio.io import MemoryFile from rasterio.plot import reshape_as_image -from cerulean_cloud.tiling import TMS +from cerulean_cloud.common.tiling import TMS TMS_TITLE = TMS.identifier diff --git a/cerulean_cloud/titiler_sentinel/handler.py b/cerulean_cloud/titiler_sentinel/handler.py index 7697b3db..cc799c46 100644 --- a/cerulean_cloud/titiler_sentinel/handler.py +++ b/cerulean_cloud/titiler_sentinel/handler.py @@ -28,7 +28,6 @@ import os from typing import Dict -from auth import api_key_auth from fastapi import Depends, FastAPI, Query from mangum import Mangum from rio_tiler_pds.errors import InvalidSentinelSceneId @@ -42,6 +41,8 @@ from titiler.core.errors import DEFAULT_STATUS_CODES, add_exception_handlers from titiler.core.factory import MultiBandTilerFactory +from cerulean_cloud.common.auth import api_key_auth + app = FastAPI(title="Sentinel-1 API") add_exception_handlers(app, DEFAULT_STATUS_CODES) add_exception_handlers( diff --git a/images/cloud_run_images.py b/images/cloud_run_images.py index fddd2437..90fd9ad9 100644 --- a/images/cloud_run_images.py +++ b/images/cloud_run_images.py @@ -65,6 +65,9 @@ def construct_name(resource_name: str) -> str: build=docker.DockerBuildArgs( context="../", dockerfile="../Dockerfiles/Dockerfile.cloud_run_offset", + cache_from=docker.CacheFromArgs( + images=[cloud_run_offset_tile_image_url.apply(lambda url: f"{url}:latest")] + ), target="final", ), image_name=cloud_run_offset_tile_image_url, @@ -75,6 +78,9 @@ def construct_name(resource_name: str) -> str: build=docker.DockerBuildArgs( context="../", dockerfile="../Dockerfiles/Dockerfile.cloud_run_orchestrator", + cache_from=docker.CacheFromArgs( + images=[cloud_run_orchestrator_image_url.apply(lambda url: f"{url}:latest")] + ), target="final", ), image_name=cloud_run_orchestrator_image_url, @@ -85,6 +91,9 @@ def construct_name(resource_name: str) -> str: build=docker.DockerBuildArgs( context="../", dockerfile="../Dockerfiles/Dockerfile.cloud_run_tipg", + cache_from=docker.CacheFromArgs( + images=[cloud_run_tipg_image_url.apply(lambda url: f"{url}:latest")] + ), target="final", ), image_name=cloud_run_tipg_image_url, diff --git a/stack/cloud_function_ais_analysis.py b/stack/cloud_function_ais_analysis.py index fc55050f..2ed78a8c 100644 --- a/stack/cloud_function_ais_analysis.py +++ b/stack/cloud_function_ais_analysis.py @@ -1,7 +1,5 @@ """cloud function to find slick culprits from AIS tracks""" -import time - import database import git import pulumi @@ -58,7 +56,7 @@ # source code. ("main.py" and "requirements.txt".) source_archive_object = storage.BucketObject( construct_name("source-cf-ais"), - name=f"handler.py-{time.time():f}", + name="handler.py", bucket=bucket.name, source=archive, ) diff --git a/stack/cloud_function_historical_run.py b/stack/cloud_function_historical_run.py index 8c7d1436..a8b0d871 100644 --- a/stack/cloud_function_historical_run.py +++ b/stack/cloud_function_historical_run.py @@ -1,7 +1,5 @@ """cloud function to select appropriate scenes (over water and IW) from SNS notification""" -import time - import cloud_function_scene_relevancy import cloud_run_orchestrator import database @@ -37,7 +35,7 @@ # source code. ("main.py" and "requirements.txt".) source_archive_object = storage.BucketObject( construct_name("source-cf-historical-run"), - name=f"handler.py-{time.time():f}", + name="handler.py", bucket=cloud_function_scene_relevancy.bucket.name, source=archive, ) diff --git a/stack/cloud_function_scene_relevancy.py b/stack/cloud_function_scene_relevancy.py index b8a1aa69..d5425f5f 100644 --- a/stack/cloud_function_scene_relevancy.py +++ b/stack/cloud_function_scene_relevancy.py @@ -1,7 +1,5 @@ """cloud function to select appropriate scenes (over water and IW) from SNS notification""" -import time - import cloud_run_orchestrator import database import pulumi @@ -60,7 +58,7 @@ # source code. ("main.py" and "requirements.txt".) source_archive_object = storage.BucketObject( construct_name("source-cf-sr"), - name=f"handler.py-{time.time():f}", + name="handler.py", bucket=bucket.name, source=archive, ) diff --git a/stack/utils.py b/stack/utils.py index 8c516bbf..34294738 100644 --- a/stack/utils.py +++ b/stack/utils.py @@ -126,9 +126,7 @@ def create_zip( :param compression: The compression type to use for the zip file (default is ZIP_DEFLATED) """ if not zip_filepath: - _, zip_filepath = mkstemp( - suffix=".zip", - ) + _, zip_filepath = mkstemp(suffix=".zip") else: zip_filepath = os.path.abspath(zip_filepath) @@ -142,7 +140,21 @@ def create_zip( ): # Store the file relative to the directory specified archive_name = os.path.relpath(full_path, dir_to_zip) - zipf.write(full_path, archive_name) + + # Create ZipInfo object to set the date_time manually + zinfo = zipfile.ZipInfo.from_file(full_path, archive_name) + # Set date_time to January 1, 1980 + zinfo.date_time = (1980, 1, 1, 0, 0, 0) + + # Write file data to zip in chunks to be memory efficient + with open(full_path, "rb") as f: + with zipf.open(zinfo, "w") as zf: + while True: + chunk = f.read(1024 * 1024) # Read 1MB at a time + if not chunk: + break + zf.write(chunk) + return zip_filepath diff --git a/test/test_cerulean_cloud/test_cloud_run_offset_tiles.py b/test/test_cerulean_cloud/test_cloud_run_offset_tiles.py index e1e23c8f..53ce43ae 100644 --- a/test/test_cerulean_cloud/test_cloud_run_offset_tiles.py +++ b/test/test_cerulean_cloud/test_cloud_run_offset_tiles.py @@ -7,10 +7,10 @@ import torchvision # noqa necessary for torch.jit.load of icevision mrcnn model from rasterio.plot import reshape_as_raster -import cerulean_cloud.models as models +import cerulean_cloud.common.models as models from cerulean_cloud.cloud_run_offset_tiles.schema import InferenceInput, PredictPayload -from cerulean_cloud.tiling import TMS -from cerulean_cloud.titiler_client import TitilerClient +from cerulean_cloud.common.tiling import TMS +from cerulean_cloud.common.titiler_client import TitilerClient @pytest.mark.skip diff --git a/test/test_cerulean_cloud/test_cloud_run_orchestrator.py b/test/test_cerulean_cloud/test_cloud_run_orchestrator.py index a7a4007e..92c94781 100644 --- a/test/test_cerulean_cloud/test_cloud_run_orchestrator.py +++ b/test/test_cerulean_cloud/test_cloud_run_orchestrator.py @@ -28,10 +28,10 @@ offset_group_shape_from_base_tiles, ) from cerulean_cloud.cloud_run_orchestrator.schema import OrchestratorInput -from cerulean_cloud.models import BaseModel, b64_image_to_array -from cerulean_cloud.roda_sentinelhub_client import RodaSentinelHubClient -from cerulean_cloud.tiling import TMS, offset_bounds_from_base_tiles -from cerulean_cloud.titiler_client import TitilerClient +from cerulean_cloud.common.models import BaseModel, b64_image_to_array +from cerulean_cloud.common.roda_sentinelhub_client import RodaSentinelHubClient +from cerulean_cloud.common.tiling import TMS, offset_bounds_from_base_tiles +from cerulean_cloud.common.titiler_client import TitilerClient S1_ID = "S1A_IW_GRDH_1SDV_20200729T034859_20200729T034924_033664_03E6D3_93EF" @@ -45,9 +45,7 @@ def get_base_tile_3band(*args, **kwargs): @pytest.mark.skip -@patch.object( - cerulean_cloud.titiler_client.TitilerClient, "get_base_tile", get_base_tile_3band -) +@patch.object(TitilerClient, "get_base_tile", get_base_tile_3band) def test_create_fixture_inference( url="https://0xshe4bmk8.execute-api.eu-central-1.amazonaws.com/", inference_url="https://cerulean-cloud-staging-cr-offset-tiles-49b-5qkjkyomta-ew.a.run.app", @@ -143,14 +141,10 @@ async def mock_get_product_info(*args, **kwargs): @pytest.mark.skip +@patch.object(TitilerClient, "get_statistics", mock_get_statistics) +@patch.object(TitilerClient, "get_bounds", mock_get_bounds) @patch.object( - cerulean_cloud.titiler_client.TitilerClient, "get_statistics", mock_get_statistics -) -@patch.object( - cerulean_cloud.titiler_client.TitilerClient, "get_bounds", mock_get_bounds -) -@patch.object( - cerulean_cloud.roda_sentinelhub_client.RodaSentinelHubClient, + RodaSentinelHubClient, "get_product_info", mock_get_product_info, ) diff --git a/test/test_cerulean_cloud/test_database_client.py b/test/test_cerulean_cloud/test_database_client.py index 777bb134..dab39b9d 100644 --- a/test/test_cerulean_cloud/test_database_client.py +++ b/test/test_cerulean_cloud/test_database_client.py @@ -11,9 +11,9 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import Session, sessionmaker -import cerulean_cloud.database_schema as database_schema -from cerulean_cloud.database_client import DatabaseClient, get_engine -from cerulean_cloud.titiler_client import TitilerClient +from cerulean_cloud.common import database_schema +from cerulean_cloud.common.database_client import DatabaseClient, get_engine +from cerulean_cloud.common.titiler_client import TitilerClient def test_get_engine(postgresql): diff --git a/test/test_cerulean_cloud/test_inference_client.py b/test/test_cerulean_cloud/test_inference_client.py index 2be45527..193bbed6 100644 --- a/test/test_cerulean_cloud/test_inference_client.py +++ b/test/test_cerulean_cloud/test_inference_client.py @@ -7,7 +7,6 @@ import rasterio from rasterio.plot import reshape_as_image -import cerulean_cloud.titiler_client from cerulean_cloud.cloud_run_offset_tiles.schema import ( InferenceResult, InferenceResultStack, @@ -19,8 +18,8 @@ get_ship_density, handle_aux_datasets, ) -from cerulean_cloud.tiling import TMS -from cerulean_cloud.titiler_client import TitilerClient +from cerulean_cloud.common.tiling import TMS +from cerulean_cloud.common.titiler_client import TitilerClient def get_mock_layer(short_name, source_url=""): @@ -77,9 +76,7 @@ def fixture_cloud_inference_tile(httpx_mock): ) -@patch.object( - cerulean_cloud.titiler_client.TitilerClient, "get_base_tile", mock_get_base_tile -) +@patch.object(TitilerClient, "get_base_tile", mock_get_base_tile) @pytest.mark.skip @pytest.mark.asyncio async def test_get_tile_inference(fixture_cloud_inference_tile, httpx_mock): diff --git a/test/test_cerulean_cloud/test_roda_sentinelhub_client.py b/test/test_cerulean_cloud/test_roda_sentinelhub_client.py index b855b844..da0807a8 100644 --- a/test/test_cerulean_cloud/test_roda_sentinelhub_client.py +++ b/test/test_cerulean_cloud/test_roda_sentinelhub_client.py @@ -2,7 +2,7 @@ import pytest -from cerulean_cloud.roda_sentinelhub_client import RodaSentinelHubClient +from cerulean_cloud.common.roda_sentinelhub_client import RodaSentinelHubClient S1_IDS = [ "S1A_IW_GRDH_1SDV_20200729T034859_20200729T034924_033664_03E6D3_93EF", diff --git a/test/test_cerulean_cloud/test_tiling.py b/test/test_cerulean_cloud/test_tiling.py index 5b6d97fe..ba2d879d 100644 --- a/test/test_cerulean_cloud/test_tiling.py +++ b/test/test_cerulean_cloud/test_tiling.py @@ -4,7 +4,7 @@ import shapely.geometry import supermercado -from cerulean_cloud.tiling import TMS, offset_bounds_from_base_tiles +from cerulean_cloud.common.tiling import TMS, offset_bounds_from_base_tiles @pytest.fixture diff --git a/test/test_cerulean_cloud/test_titiler_client.py b/test/test_cerulean_cloud/test_titiler_client.py index ee058a38..f3ce4d82 100644 --- a/test/test_cerulean_cloud/test_titiler_client.py +++ b/test/test_cerulean_cloud/test_titiler_client.py @@ -1,8 +1,8 @@ import mercantile import pytest -from cerulean_cloud.tiling import adjacent_tile, pixel_to_location -from cerulean_cloud.titiler_client import TMS_TITLE, TitilerClient +from cerulean_cloud.common.tiling import adjacent_tile, pixel_to_location +from cerulean_cloud.common.titiler_client import TMS_TITLE, TitilerClient @pytest.fixture