Skip to content

Commit

Permalink
Merge branch 'release/2024.1.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcfarland committed Mar 28, 2024
2 parents c9656c3 + e3e5cf5 commit 93ca129
Show file tree
Hide file tree
Showing 22 changed files with 308 additions and 189 deletions.
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ REACT_APP_ONEDS_TENANT_KEY=
REACT_APP_API_ROOT=https://planetarycomputer-staging.microsoft.com

# Root URL for image function app endpoints
REACT_APP_IMAGE_API_ROOT=
REACT_APP_IMAGE_API_ROOT=https://planetarycomputer-staging.microsoft.com/api/f

# Subscription key for Azure Maps
REACT_APP_AZMAPS_KEY=
# Client Id for Azure Maps
REACT_APP_AZMAPS_CLIENT_ID=8f49b6d6-5845-4e20-9015-9630df1ca8d2

# URL for JHub cloned repo launch (including 'git-pull')
REACT_APP_HUB_URL=
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

jobs:
build_and_deploy_job:
permissions:
pull-requests: write
environment: staging
if:
github.event_name == 'push' || (github.event_name == 'pull_request' &&
Expand All @@ -20,10 +22,9 @@ jobs:
env:
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
REACT_APP_AUTH_URL: ${{ secrets.AUTH_URL }}
steps:
- uses: actions/checkout@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

jobs:
build_and_deploy_job:
permissions:
pull-requests: write
environment: production
if:
github.event_name == 'push' || (github.event_name == 'pull_request' &&
Expand All @@ -20,9 +22,8 @@ jobs:
env:
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
REACT_APP_JSLL_APP_ID: ${{ secrets.JSLL_APP_ID }}
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
steps:
- uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

jobs:
build_and_deploy_job:
permissions:
pull-requests: write
environment: test
if:
github.event_name == 'push' || (github.event_name == 'pull_request' &&
Expand All @@ -20,10 +22,9 @@ jobs:
env:
REACT_APP_API_ROOT: ${{ secrets.API_ROOT }}
REACT_APP_IMAGE_API_ROOT: ${{ secrets.IMAGE_API_ROOT }}
REACT_APP_AZMAPS_CLIENT_ID: ${{ secrets.AZMAPS_CLIENT_ID }}
REACT_APP_ONEDS_TENANT_KEY: ${{ secrets.ONEDS_TENANT_KEY }}
REACT_APP_AZMAPS_KEY: ${{ secrets.AZMAPS_KEY }}
REACT_APP_HUB_URL: ${{ secrets.HUB_URL }}
REACT_APP_AUTH_URL: ${{ secrets.AUTH_URL }}
steps:
- uses: actions/checkout@v3
with:
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,29 @@ First, copy `.env.sample` file to `.env`, and ensure the configuration values ar
|`REACT_APP_API_ROOT`| <https://planetarycomputer-staging.microsoft.com> | The root URL for the STAC API, either prod, staging or a local instance. If the URL ends in 'stac', this is a special case that is handled by replacing 'stac' with the target service, e.g. 'data' or 'sas'
|`REACT_APP_TILER_ROOT`| Optional | The root URL for the data tiler API, if not hosted from the domain of the STAC API.
|`REACT_APP_IMAGE_API_ROOT`| PC APIs pcfunc endpoint | The root URL for the image data API for animations.
|`REACT_APP_AZMAPS_KEY`| Retrieve from Azure Portal | The key used to authenticate the Azure Maps inset map on a dataset detail page.
|`REACT_APP_AZMAPS_CLIENT_ID`| Retrieve from Azure Portal | The Client ID used to authenticate against Azure Maps.
|`REACT_APP_HUB_URL`| Optional. URL to root Hub instance | Used to enable a request to launch the Hub with a specific git hosted file.
|`REACT_APP_ONEDS_TENANT_KEY`| Lookup at <https://1dswhitelisting.azurewebsites.net/> | Telemetry key (not needed for dev)
|`REACT_APP_AUTH_URL`| Optional. URL to root pc-session-api instance | Used to enable login work.

Run `./scripts/server` to launch a development server.
Run `./scripts/server --api` to launch a development server with a local Azure Functions host running.

#### Azure Maps

In the local development setups, the Azure Maps token is generated using the local developer identity. Be sure to
`az login` and `az account set --subscription "Planetary Computer"` to ensure the correct token is generated. Your identity
will also need the "Azure Maps Search and Render Data Reader" permission, which can be set with:

```sh
USER_NAME=$(az account show --query user.name -o tsv)
az role assignment create \
--assignee "$USER_NAME" \
--role "Azure Maps Search and Render Data Reader" \
--scope "/subscriptions/9da7523a-cb61-4c3e-b1d4-afa5fc6d2da9/resourceGroups/pc-datacatalog-rg/providers/Microsoft.Maps/accounts/pc-datacatalog-azmaps" \
--subscription "Planetary Computer"
```

Note, you may need to assign this role via an identity that has JIT admin privileges enabled against the Planetary Computer subscription.

#### Developing against local STAC assets

Expand Down
15 changes: 12 additions & 3 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
FROM mcr.microsoft.com/azure-functions/python:4-python3.9
FROM mcr.microsoft.com/azure-cli:cbl-mariner2.0

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

RUN tdnf install libicu unzip wget -y
RUN wget https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.5530/Azure.Functions.Cli.linux-x64.4.0.5530.zip
RUN mkdir -p /usr/local/lib/Azure.Functions.Cli
RUN unzip Azure.Functions.Cli.linux-x64.4.0.5530.zip -d /usr/local/lib/Azure.Functions.Cli
RUN chmod +x /usr/local/lib/Azure.Functions.Cli/func

ENV PATH="/usr/local/lib/Azure.Functions.Cli:${PATH}"

RUN python3 -m ensurepip --upgrade
COPY requirements.txt /
RUN pip install -r /requirements.txt
RUN pip3 install -r /requirements.txt

COPY requirements-dev.txt /
RUN pip install -r /requirements-dev.txt
RUN pip3 install -r /requirements-dev.txt
12 changes: 6 additions & 6 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ To set appropriate configuration values for the Function app, copy the `local.se

The `local.settings.json` file has the following keys in the Values section:

|Key|KeyVault Key|Purpose|
|---|---|---|
|`NotificationHook`| | URL to send Teams notification on new Account Request
|`AuthAdminUrl`| | URL to the PC ID admin page which contains the signup table. Used in the Teams notification message.
|`SignupUrl`| | URL to POST new user content to on submission
|`SignupToken` | `pc-id--request-auth-token` | Bearer token required to make the above POST request
| Key | KeyVault Key | Purpose |
|--------------------|-----------------------------|------------------------------------------------------------------------------------------------------|
| `NotificationHook` | | URL to send Teams notification on new Account Request |
| `AuthAdminUrl` | | URL to the PC ID admin page which contains the signup table. Used in the Teams notification message. |
| `SignupUrl` | | URL to POST new user content to on submission |
| `SignupToken` | `pc-id--request-auth-token` | Bearer token required to make the above POST request |

### Production

Expand Down
38 changes: 38 additions & 0 deletions api/map-token/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import json
import logging
from typing import TypedDict

import azure.functions as func

from azure.identity import DefaultAzureCredential
from azure.core.exceptions import ClientAuthenticationError

logger = logging.getLogger("api.maps-token")
# For performance, exclude checking options we know won't be used
credential = DefaultAzureCredential(
exclude_environment_credential=True,
exclude_developer_cli_credential=True,
exclude_powershell_credential=True,
exclude_visual_studio_code_credential=True,
)


class TokenResponse(TypedDict):
token: str
expires_on: int


def main(req: func.HttpRequest) -> func.HttpResponse:

logger.debug("Python HTTP trigger function processed a request.")
try:
logger.debug("Getting azure maps token")
token = credential.get_token("https://atlas.microsoft.com/.default")
logger.debug("Token acquired")

resp: TokenResponse = {"token": token.token, "expires_on": token.expires_on}

return func.HttpResponse(status_code=200, body=json.dumps(resp))
except ClientAuthenticationError:
logger.exception(f"Error getting azure maps token")
return func.HttpResponse("Error getting token", status_code=500)
19 changes: 19 additions & 0 deletions api/map-token/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
1 change: 1 addition & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# Manually managing azure-functions-worker may cause unexpected issues

azure-functions==1.11.2
azure-identity==1.15.0
requests==2.31.0
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
# environment variables set via GH Actions to test and build.
- REACT_APP_API_ROOT
- REACT_APP_IMAGE_API_ROOT
- REACT_APP_AZMAPS_KEY
- REACT_APP_AZMAPS_CLIENT_ID
- REACT_APP_ONEDS_TENANT_KEY
- REACT_APP_HUB_URL
volumes:
Expand All @@ -34,6 +34,7 @@ services:
- "8000:8000"
volumes:
- ./api:/usr/src
- ~/.azure:/root/.azure
networks:
pcdc-network:
command: func host start --script-root ./ --cors "*" --port 7071
Expand Down
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Explorer <overview/explorer>
The Hub <overview/environment>
Use VS Code <overview/ui-vscode>
Use GitHub Codespaces <overview/ui-codespaces>
Batch Jobs <overview/batch.md>
Using QGIS <overview/qgis-plugin>
Changelog <overview/changelog>
```
Expand Down
58 changes: 0 additions & 58 deletions docs/overview/batch.md

This file was deleted.

5 changes: 3 additions & 2 deletions docs/overview/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Select *Stop My Server* to stop your server and release all of the resources you

![JupyterHub menu to stop the server](images/hub-home.png)

Note that we will automatically stop notebook servers that appear idle or are older that 24 hours. If you expect a job to take longer
than 24 hours, then see [running batch jobs](./batch) for a way to submit long-running jobs.
Note that we will automatically stop notebook servers that appear idle or are older that 24 hours.
The Planetary Computer Hub is primarily intended for interactive computation on datasets
from our catalog.

## Using JupyterLab

Expand Down
Loading

0 comments on commit 93ca129

Please sign in to comment.