Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-integration-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emileten committed Feb 19, 2024
2 parents 9e886a2 + 1e39ddb commit b973fbc
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 32 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# [6.1.0](https://github.com/developmentseed/eoapi-cdk/compare/v6.0.2...v6.1.0) (2023-11-12)


### Features

* **stac-browser:** configurable config file in stac browser deployment ([#84](https://github.com/developmentseed/eoapi-cdk/issues/84)) ([b86ad1a](https://github.com/developmentseed/eoapi-cdk/commit/b86ad1a8cb1fb92628f6450c1c8b05258d78280b))

## [6.0.2](https://github.com/developmentseed/eoapi-cdk/compare/v6.0.1...v6.0.2) (2023-11-02)


### Bug Fixes

* **bootstrapper:** fix httpx response ([#81](https://github.com/developmentseed/eoapi-cdk/issues/81)) ([b879076](https://github.com/developmentseed/eoapi-cdk/commit/b8790766818b0048e2192849a34f462997a08c0e))

## [6.0.1](https://github.com/developmentseed/eoapi-cdk/compare/v6.0.0...v6.0.1) (2023-11-01)


### Bug Fixes

* **ingestor-api-handler:** fix docs endpoint ([#82](https://github.com/developmentseed/eoapi-cdk/issues/82)) ([d134c77](https://github.com/developmentseed/eoapi-cdk/commit/d134c77f84363b3e4560176ccd810b55b6855f07))

# [6.0.0](https://github.com/developmentseed/eoapi-cdk/compare/v5.4.1...v6.0.0) (2023-10-31)


### Features

* custom runtimes, optional VPC, python 3.11 ([#74](https://github.com/developmentseed/eoapi-cdk/issues/74)) ([ba6bf09](https://github.com/developmentseed/eoapi-cdk/commit/ba6bf09651caae8537df7ee737dbf6d0bf975f41))


### BREAKING CHANGES

* the `bootstrapper` construct was deleted and is no longer available. In addition, we switched from `PythonFunction` to `Function` for all lambdas.

## [5.4.1](https://github.com/developmentseed/eoapi-cdk/compare/v5.4.0...v5.4.1) (2023-10-05)


### Bug Fixes

* synchronize pgstac versions -> 0.7.9 across constructs ([c6bb921](https://github.com/developmentseed/eoapi-cdk/commit/c6bb9213f745f1161d193b120083fac1e7943eb5))

# [5.4.0](https://github.com/developmentseed/eoapi-cdk/compare/v5.3.0...v5.4.0) (2023-09-05)


Expand Down
4 changes: 2 additions & 2 deletions lib/database/bootstrapper_runtime/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import json

import boto3
import psycopg
import httpx
import psycopg
from psycopg import sql
from psycopg.conninfo import make_conninfo
from pypgstac.db import PgstacDB
Expand Down Expand Up @@ -59,7 +59,7 @@ def send(

try:
response = httpx.put(responseUrl, data=json_responseBody, headers=headers)
print("Status code: " + response.reason)
print("Status code: " + response.status_code)
except Exception as e:
print("send(..) failed executing httpx.put(..): " + str(e))

Expand Down
2 changes: 1 addition & 1 deletion lib/ingestor-api/runtime/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
httpx
moto[dynamodb, ssm]>=4.0.9
moto[dynamodb, ssm]>=4.0.9
2 changes: 1 addition & 1 deletion lib/ingestor-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

from .main import app

handler = Mangum(app, lifespan="off")
handler = Mangum(app, lifespan="off", api_gateway_base_path=app.root_path)
2 changes: 1 addition & 1 deletion lib/ingestor-api/runtime/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import boto3
import pydantic
from fastapi.encoders import jsonable_encoder
from pypgstac.db import PgstacDB
from pypgstac.load import Methods
from fastapi.encoders import jsonable_encoder

from .loader import Loader
from .schemas import Ingestion
Expand Down
5 changes: 3 additions & 2 deletions lib/ingestor-api/runtime/tests/test_collection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
from unittest.mock import Mock, patch

import pytest
import src.collection as collection
from pypgstac.load import Methods
from src.utils import DbCreds
import src.collection as collection
import os


@pytest.fixture()
Expand Down
3 changes: 1 addition & 2 deletions lib/ingestor-api/runtime/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from typing import TYPE_CHECKING, List
from unittest.mock import call, patch

from fastapi.encoders import jsonable_encoder
import pytest

from fastapi.encoders import jsonable_encoder

if TYPE_CHECKING:
from fastapi.testclient import TestClient
Expand Down
2 changes: 1 addition & 1 deletion lib/ingestor-api/runtime/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from unittest.mock import Mock, patch

import pytest
from pypgstac.load import Methods
from fastapi.encoders import jsonable_encoder
from pypgstac.load import Methods
from src.utils import DbCreds


Expand Down
1 change: 1 addition & 0 deletions lib/stac-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import asyncio
import os

from mangum import Mangum

from .app import app
Expand Down
34 changes: 25 additions & 9 deletions lib/stac-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class StacBrowser extends Construct {
constructor(scope: Construct, id: string, props: StacBrowserProps) {
super(scope, id);

const buildPath = this.buildApp(props.stacCatalogUrl, props.githubRepoTag, props.cloneDirectory || DEFAULT_CLONE_DIRECTORY);
const buildPath = this.buildApp(props, props.cloneDirectory || DEFAULT_CLONE_DIRECTORY);

// import a bucket from props.bucketArn if defined, otherwise create a new bucket
if (props.bucketArn) {
Expand Down Expand Up @@ -58,16 +58,16 @@ export class StacBrowser extends Construct {

}

private buildApp(stacCatalogUrl: string, githubRepoTag: string, cloneDirectory: string): string {
private buildApp(props: StacBrowserProps, cloneDirectory: string): string {

// Define where to clone and build
const githubRepoUrl = 'https://github.com/radiantearth/stac-browser.git';


// Maybe the repo already exists in cloneDirectory. Try checking out the desired version and if it fails, delete and reclone.
try {
console.log(`Checking if a valid cloned repo exists with version ${githubRepoTag}...`)
execSync(`git checkout tags/${githubRepoTag}`, { cwd: cloneDirectory });
console.log(`Checking if a valid cloned repo exists with version ${props.githubRepoTag}...`)
execSync(`git checkout tags/${props.githubRepoTag}`, { cwd: cloneDirectory });
}
catch (error) {

Expand All @@ -83,18 +83,28 @@ export class StacBrowser extends Construct {
execSync(`git clone ${githubRepoUrl} ${cloneDirectory}`);

// Check out the desired version
console.log(`Checking out version ${githubRepoTag}...`)
execSync(`git checkout tags/${githubRepoTag}`, { cwd: cloneDirectory });
console.log(`Checking out version ${props.githubRepoTag}...`)
execSync(`git checkout tags/${props.githubRepoTag}`, { cwd: cloneDirectory });

}

// Install the dependencies and build the application
console.log(`Installing dependencies`)
execSync('npm install', { cwd: cloneDirectory });

// If a config file is provided, copy it to the stac-browser directory at "config.js", replaces the default config.js.
if (props.configFilePath) {
// check that the file exists at this location. if not, raise an error and print current working directory.
if (!fs.existsSync(props.configFilePath)) {
throw new Error(`Config file ${props.configFilePath} does not exist. Current working directory is ${process.cwd()}`);
}
console.log(`Copying config file ${props.configFilePath} to ${cloneDirectory}/config.js`)
fs.copyFileSync(props.configFilePath, `${cloneDirectory}/config.js`);
}

// Build the app with catalogUrl
console.log(`Building app with catalogUrl=${stacCatalogUrl} into ${cloneDirectory}`)
execSync(`npm run build -- --catalogUrl=${stacCatalogUrl}`, { cwd: cloneDirectory });
console.log(`Building app with catalogUrl=${props.stacCatalogUrl} into ${cloneDirectory}`)
execSync(`npm run build -- --catalogUrl=${props.stacCatalogUrl}`, { cwd: cloneDirectory });

return './stac-browser/dist'

Expand All @@ -115,10 +125,16 @@ export interface StacBrowserProps {
readonly bucketArn?: string;

/**
* STAC catalog URL
* STAC catalog URL. Overrides the catalog URL in the stac-browser configuration.
*/
readonly stacCatalogUrl: string;

/**
* Path to config file for the STAC browser. If not provided, default configuration in the STAC browser
* repository is used.
*/
readonly configFilePath?: string;

/**
* Tag of the radiant earth stac-browser repo to use to build the app.
*/
Expand Down
13 changes: 6 additions & 7 deletions lib/tipg-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@

import asyncio
import os

from mangum import Mangum
from utils import load_pgstac_secret

load_pgstac_secret(os.environ["PGSTAC_SECRET_ARN"]) # required for the below imports

# skipping linting rule that wants all imports at the top
from tipg.main import app # noqa: E402
from tipg.collections import register_collection_catalog # noqa: E402
from tipg.database import connect_to_db # noqa: E402
from tipg.settings import ( # noqa: E402
CustomSQLSettings, # noqa: E402
DatabaseSettings, # noqa: E402
PostgresSettings, # noqa: E402
) # noqa: E402

# skipping linting rule that wants all imports at the top
from tipg.main import app # noqa: E402
from tipg.settings import CustomSQLSettings # noqa: E402
from tipg.settings import DatabaseSettings # noqa: E402
from tipg.settings import PostgresSettings # noqa: E402; noqa: E402

postgres_settings = PostgresSettings()
db_settings = DatabaseSettings()
Expand Down
3 changes: 2 additions & 1 deletion lib/tipg-api/runtime/src/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import base64
import json
import boto3
import os

import boto3


def load_pgstac_secret(secret_name: str):
"""Retrieve secrets from AWS Secrets Manager
Expand Down
3 changes: 2 additions & 1 deletion lib/titiler-pgstac-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import asyncio
import os

from mangum import Mangum
from utils import get_secret_dict

Expand All @@ -20,8 +21,8 @@
}
)

from titiler.pgstac.main import app # noqa: E402
from titiler.pgstac.db import connect_to_db # noqa: E402
from titiler.pgstac.main import app # noqa: E402


@app.on_event("startup")
Expand Down
1 change: 1 addition & 0 deletions lib/titiler-pgstac-api/runtime/src/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
import json

import boto3


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eoapi-cdk",
"version": "5.4.0",
"version": "6.1.0",
"description": "A set of constructs deploying pgSTAC with CDK",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -58,7 +58,7 @@
},
"bundledDependencies": [
"module"
],
],
"peerDependencies": {
"aws-cdk-lib": "^2.99.1",
"constructs": "^10.1.113"
Expand Down

0 comments on commit b973fbc

Please sign in to comment.