Skip to content

Commit

Permalink
Merge branch 'feature/lambda-docker' into feature/github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zcernigoj committed Oct 20, 2023
2 parents 8f167a1 + 8bb78d1 commit 536d91a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ deploy-production-generate-zappa-settings:
- $CI_COMMIT_TAG =~ /^v[0-9]+[.][0-9]+[.][0-9]+$/
image: python:3.9.13
variables:
DEPLOYMENT_NAME: "testing-docker"
DEPLOYMENT_NAME: "production-docker"
before_script:
# configure aws access credentials:
- mkdir -p ~/.aws
Expand Down Expand Up @@ -341,7 +341,7 @@ deploy-production-create-docker-image:
# configure aws access credentials:
- mkdir -p ~/.aws
- echo -e "[default]\nregion=eu-central-1" > ~/.aws/config
- echo -e "[default]\naws_access_key_id=$TESTINGZAPPA_AWS_ACCESS_KEY_ID\naws_secret_access_key=$TESTINGZAPPA_AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
- echo -e "[default]\naws_access_key_id=$PRODZAPPA_AWS_ACCESS_KEY_ID\naws_secret_access_key=$PRODZAPPA_AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
script:
- cd rest/
# build docker image with correct tags
Expand Down Expand Up @@ -374,7 +374,7 @@ deploy-production-rest-lambda-docker:
# configure aws access credentials:
- mkdir -p ~/.aws
- echo -e "[default]\nregion=eu-central-1" > ~/.aws/config
- echo -e "[default]\naws_access_key_id=$TESTINGZAPPA_AWS_ACCESS_KEY_ID\naws_secret_access_key=$TESTINGZAPPA_AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
- echo -e "[default]\naws_access_key_id=$PRODZAPPA_AWS_ACCESS_KEY_ID\naws_secret_access_key=$PRODZAPPA_AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
- pip install pipenv==2021.5.29
script:
- chmod +x download-process-definitions.sh
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ Then the REST API server can be run:
<pipenv> $ python app.py
```

To locally run the REST API server on HTTPS, so you can use it in the [openEO editor](https://editor.openeo.org/), start it with:
To locally run the REST API server on HTTPS, start it with:
```
<pipenv> $ python app.py https
```

To use it in the [openEO editor](https://editor.openeo.org/), you must first access the endpoint directly via a Browser and "Accept the Risk and Continue" (there is no valid security certificate behind this secure connection).

### Troubleshooting

If validator complains about process graphs that are clearly correct (and which are valid on production deployment), there are two things than can be done:
Expand Down
6 changes: 5 additions & 1 deletion rest/processing/processing_api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def make_request(self):
return requests.post(self.url, data=json.dumps(self.data), headers=self.get_headers())

def has_rate_limiting_with_backoff(self):
if self.url.startswith(SentinelhubDeployments.USWEST):
if (
self.url.startswith(SentinelhubDeployments.MAIN)
or self.url.startswith(SentinelhubDeployments.USWEST)
or self.url.startswith(SentinelhubDeployments.CREODIAS)
):
return True
return False
71 changes: 68 additions & 3 deletions tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,40 @@ def test_get_roles(filename, expected_roles):
"endpoint,access_token,api_responses,min_exec_time,should_raise_error,expected_error",
[
("https://services.sentinel-hub.com", None, [{"status": 200}], 0, False, None),
("https://services.sentinel-hub.com", None, [{"status": 429}], 0, True, "Too Many Requests"),
("https://services.sentinel-hub.com", "some-token", [{"status": 200}], 0, False, None),
("https://services.sentinel-hub.com", "some-token", [{"status": 429}], 0, True, "Too Many Requests"),
(
"https://services.sentinel-hub.com",
None,
[
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "7"}},
{"status": 200},
],
9,
False,
None,
),
(
"https://services.sentinel-hub.com",
None,
[
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
],
0,
True,
"Out of retries.",
),
(
"https://services.sentinel-hub.com",
None,
[{"status": 429, "headers": {"retry-after": "2"}}, {"status": 500}],
0,
True,
"Internal Server Error",
),
("https://services-uswest2.sentinel-hub.com", None, [{"status": 200}], 0, False, None),
(
"https://services-uswest2.sentinel-hub.com",
None,
Expand Down Expand Up @@ -1022,6 +1053,40 @@ def test_get_roles(filename, expected_roles):
True,
"Internal Server Error",
),
("https://creodias.sentinel-hub.com", None, [{"status": 200}], 0, False, None),
(
"https://creodias.sentinel-hub.com",
None,
[
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "7"}},
{"status": 200},
],
9,
False,
None,
),
(
"https://creodias.sentinel-hub.com",
None,
[
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
{"status": 429, "headers": {"retry-after": "2"}},
],
0,
True,
"Out of retries.",
),
(
"https://creodias.sentinel-hub.com",
None,
[{"status": 429, "headers": {"retry-after": "2"}}, {"status": 500}],
0,
True,
"Internal Server Error",
),
],
)
def test_processing_api_request(
Expand Down

0 comments on commit 536d91a

Please sign in to comment.