orient_express 2.4.1__tar.gz → 2.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orient_express-2.4.1 → orient_express-2.4.2}/PKG-INFO +1 -1
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/predictor.py +1 -1
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/utils/image_processor.py +33 -1
- {orient_express-2.4.1 → orient_express-2.4.2}/pyproject.toml +1 -1
- {orient_express-2.4.1 → orient_express-2.4.2}/README.md +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/__init__.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/deployment.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/model_wrapper.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/__init__.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/classification.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/feature_extraction.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/instance_segmentation.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/multi_label_classification.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/object_detection.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/semantic_segmentation.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/vector_index.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/sklearn_pipeline.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/utils/colors.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/utils/gs.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/utils/paths.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/utils/retry.py +0 -0
- {orient_express-2.4.1 → orient_express-2.4.2}/orient_express/vertex.py +0 -0
|
@@ -46,7 +46,7 @@ class ImagePredictor(Predictor):
|
|
|
46
46
|
self.model_path = model_path
|
|
47
47
|
|
|
48
48
|
def get_serving_container_image_uri(self):
|
|
49
|
-
return "us-west1-docker.pkg.dev/shiftsmart-api/orient-express/image-onnx:v2.4.
|
|
49
|
+
return "us-west1-docker.pkg.dev/shiftsmart-api/orient-express/image-onnx:v2.4.2"
|
|
50
50
|
|
|
51
51
|
def get_serving_container_health_route(self, model_name):
|
|
52
52
|
return f"/v1/models/{model_name}"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import ipaddress
|
|
2
3
|
import logging
|
|
4
|
+
import socket
|
|
3
5
|
from io import BytesIO
|
|
6
|
+
from urllib.parse import urlparse
|
|
4
7
|
|
|
5
8
|
import cv2
|
|
6
9
|
import numpy as np
|
|
@@ -9,6 +12,34 @@ import requests
|
|
|
9
12
|
|
|
10
13
|
from .gs import get_gcs_from_http_url, read_file_bytes
|
|
11
14
|
|
|
15
|
+
DOWNLOAD_TIMEOUT_SECONDS = 30
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class UnsafeUrlError(ValueError):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def validate_url(http_url):
|
|
23
|
+
# Reject URLs that could be used for SSRF: the request runs server-side
|
|
24
|
+
# with the service account's network access, so only allow http(s) URLs
|
|
25
|
+
# that resolve to public IPs (blocks the GCE metadata server, localhost,
|
|
26
|
+
# and private/internal ranges).
|
|
27
|
+
parsed = urlparse(http_url)
|
|
28
|
+
if parsed.scheme not in ("http", "https"):
|
|
29
|
+
raise UnsafeUrlError(f"unsupported URL scheme: {parsed.scheme}")
|
|
30
|
+
if not parsed.hostname:
|
|
31
|
+
raise UnsafeUrlError("URL has no hostname")
|
|
32
|
+
try:
|
|
33
|
+
addr_infos = socket.getaddrinfo(parsed.hostname, None)
|
|
34
|
+
except socket.gaierror as e:
|
|
35
|
+
raise UnsafeUrlError(f"could not resolve host: {parsed.hostname}") from e
|
|
36
|
+
for addr_info in addr_infos:
|
|
37
|
+
ip = ipaddress.ip_address(addr_info[4][0])
|
|
38
|
+
if not ip.is_global:
|
|
39
|
+
raise UnsafeUrlError(
|
|
40
|
+
f"URL host {parsed.hostname} resolves to non-public address {ip}"
|
|
41
|
+
)
|
|
42
|
+
|
|
12
43
|
|
|
13
44
|
def read_image_from_url(http_url, http_as_gcs=False) -> Image.Image:
|
|
14
45
|
# Extract GSC URI from http link and download the file directly.
|
|
@@ -19,7 +50,8 @@ def read_image_from_url(http_url, http_as_gcs=False) -> Image.Image:
|
|
|
19
50
|
if gs_uri:
|
|
20
51
|
return read_image_from_gs(gs_uri)
|
|
21
52
|
|
|
22
|
-
|
|
53
|
+
validate_url(http_url)
|
|
54
|
+
response = requests.get(http_url, timeout=DOWNLOAD_TIMEOUT_SECONDS)
|
|
23
55
|
response.raise_for_status()
|
|
24
56
|
image = Image.open(BytesIO(response.content))
|
|
25
57
|
return image
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "orient_express"
|
|
3
|
-
version = "2.4.
|
|
3
|
+
version = "2.4.2"
|
|
4
4
|
description = "A library to simplify model deployment to Vertex AI"
|
|
5
5
|
authors = ["Alexey Zankevich <alex.zankevich@shiftsmart.com>", "Ian Myers <ian.myers@shiftsmart.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/feature_extraction.py
RENAMED
|
File without changes
|
{orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/instance_segmentation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{orient_express-2.4.1 → orient_express-2.4.2}/orient_express/predictors/semantic_segmentation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|