truss 0.11.15rc13__py3-none-any.whl → 0.11.17__py3-none-any.whl
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.
Potentially problematic release.
This version of truss might be problematic. Click here for more details.
- truss/contexts/image_builder/cache_warmer.py +14 -5
- truss/remote/baseten/utils/transfer.py +5 -2
- truss/tests/util/test_env_vars.py +8 -3
- truss/util/env_vars.py +19 -8
- truss/util/error_utils.py +3 -0
- {truss-0.11.15rc13.dist-info → truss-0.11.17.dist-info}/METADATA +1 -1
- {truss-0.11.15rc13.dist-info → truss-0.11.17.dist-info}/RECORD +10 -10
- {truss-0.11.15rc13.dist-info → truss-0.11.17.dist-info}/WHEEL +0 -0
- {truss-0.11.15rc13.dist-info → truss-0.11.17.dist-info}/entry_points.txt +0 -0
- {truss-0.11.15rc13.dist-info → truss-0.11.17.dist-info}/licenses/LICENSE +0 -0
|
@@ -11,11 +11,10 @@ from typing import Optional, Type
|
|
|
11
11
|
import boto3
|
|
12
12
|
from botocore import UNSIGNED
|
|
13
13
|
from botocore.client import Config
|
|
14
|
+
from botocore.exceptions import ClientError, NoCredentialsError
|
|
14
15
|
from google.cloud import storage
|
|
15
16
|
from huggingface_hub import hf_hub_download
|
|
16
17
|
|
|
17
|
-
from truss.util.error_utils import handle_client_error
|
|
18
|
-
|
|
19
18
|
B10CP_PATH_TRUSS_ENV_VAR_NAME = "B10CP_PATH_TRUSS"
|
|
20
19
|
|
|
21
20
|
GCS_CREDENTIALS = "/app/data/service_account.json"
|
|
@@ -189,14 +188,24 @@ class S3File(RepositoryFile):
|
|
|
189
188
|
if not dst_file.parent.exists():
|
|
190
189
|
dst_file.parent.mkdir(parents=True)
|
|
191
190
|
|
|
192
|
-
|
|
193
|
-
f"accessing S3 bucket {bucket_name} for file {file_name}"
|
|
194
|
-
):
|
|
191
|
+
try:
|
|
195
192
|
url = client.generate_presigned_url(
|
|
196
193
|
"get_object",
|
|
197
194
|
Params={"Bucket": bucket_name, "Key": file_name},
|
|
198
195
|
ExpiresIn=3600,
|
|
199
196
|
)
|
|
197
|
+
except NoCredentialsError as nce:
|
|
198
|
+
raise RuntimeError(
|
|
199
|
+
f"No AWS credentials found\nOriginal exception: {str(nce)}"
|
|
200
|
+
)
|
|
201
|
+
except ClientError as ce:
|
|
202
|
+
raise RuntimeError(
|
|
203
|
+
f"Client error when accessing the S3 bucket (check your credentials): {str(ce)}"
|
|
204
|
+
)
|
|
205
|
+
except Exception as exc:
|
|
206
|
+
raise RuntimeError(
|
|
207
|
+
f"File not found on S3 bucket: {file_name}\nOriginal exception: {str(exc)}"
|
|
208
|
+
)
|
|
200
209
|
|
|
201
210
|
download_file_using_b10cp(url, dst_file, self.file_name)
|
|
202
211
|
|
|
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Optional, Type
|
|
|
7
7
|
import boto3
|
|
8
8
|
from boto3.s3.transfer import TransferConfig
|
|
9
9
|
|
|
10
|
-
from truss.util.env_vars import
|
|
10
|
+
from truss.util.env_vars import modify_env_vars
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from rich import progress
|
|
@@ -26,7 +26,10 @@ def multipart_upload_boto3(
|
|
|
26
26
|
) -> None:
|
|
27
27
|
# In the CLI flow, ignore any local ~/.aws/config files,
|
|
28
28
|
# which can interfere with uploading the Truss to S3.
|
|
29
|
-
|
|
29
|
+
aws_env_vars = set(
|
|
30
|
+
env_var for env_var in os.environ.keys() if env_var.startswith("AWS_")
|
|
31
|
+
)
|
|
32
|
+
with modify_env_vars(deletions=aws_env_vars):
|
|
30
33
|
s3_resource = boto3.resource("s3", **credentials)
|
|
31
34
|
filesize = os.stat(file_path).st_size
|
|
32
35
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
-
from truss.util.env_vars import
|
|
3
|
+
from truss.util.env_vars import modify_env_vars
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def
|
|
6
|
+
def test_modify_env_vars():
|
|
7
7
|
os.environ["API_KEY"] = "original_key"
|
|
8
|
+
os.environ["AWS_CONFIG_FILE"] = "original_config_file"
|
|
8
9
|
|
|
9
|
-
with
|
|
10
|
+
with modify_env_vars(
|
|
11
|
+
overrides={"API_KEY": "new_key", "DEBUG": "true"}, deletions={"AWS_CONFIG_FILE"}
|
|
12
|
+
):
|
|
10
13
|
assert os.environ["API_KEY"] == "new_key"
|
|
11
14
|
assert os.environ["DEBUG"] == "true"
|
|
15
|
+
assert "AWS_CONFIG_FILE" not in os.environ
|
|
12
16
|
|
|
13
17
|
assert os.environ["API_KEY"] == "original_key"
|
|
14
18
|
assert "DEBUG" not in os.environ
|
|
19
|
+
assert os.environ["AWS_CONFIG_FILE"] == "original_config_file"
|
truss/util/env_vars.py
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Dict, Optional
|
|
2
|
+
from typing import Dict, Optional, Set
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class modify_env_vars:
|
|
6
6
|
"""A context manager for temporarily overwriting environment variables.
|
|
7
7
|
|
|
8
8
|
Usage:
|
|
9
|
-
with
|
|
9
|
+
with modify_env_vars(overrides={'API_KEY': 'test_key', 'DEBUG': 'true'}, deletions={'AWS_CONFIG_FILE'}):
|
|
10
10
|
# Environment variables are modified here
|
|
11
11
|
...
|
|
12
12
|
# Original environment is restored here
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
def __init__(
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
overrides: Optional[Dict[str, str]] = None,
|
|
18
|
+
deletions: Optional[Set[str]] = None,
|
|
19
|
+
):
|
|
16
20
|
"""
|
|
17
21
|
Args:
|
|
18
|
-
|
|
22
|
+
overrides: Dictionary of environment variables to set
|
|
23
|
+
deletions: Set of environment variables to delete
|
|
19
24
|
"""
|
|
20
|
-
self.
|
|
25
|
+
self.overrides: Dict[str, str] = overrides or dict()
|
|
26
|
+
self.deletions: Set[str] = deletions or set()
|
|
21
27
|
self.original_vars: Dict[str, Optional[str]] = {}
|
|
22
28
|
|
|
23
29
|
def __enter__(self):
|
|
24
|
-
|
|
30
|
+
all_keys = set(self.overrides.keys()) | self.deletions
|
|
31
|
+
for key in all_keys:
|
|
25
32
|
self.original_vars[key] = os.environ.get(key)
|
|
26
33
|
|
|
27
|
-
for key, value in self.
|
|
34
|
+
for key, value in self.overrides.items():
|
|
28
35
|
os.environ[key] = value
|
|
29
36
|
|
|
37
|
+
for key in self.deletions:
|
|
38
|
+
if key in os.environ:
|
|
39
|
+
del os.environ[key]
|
|
40
|
+
|
|
30
41
|
return self
|
|
31
42
|
|
|
32
43
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
truss/util/error_utils.py
CHANGED
|
@@ -34,7 +34,7 @@ truss/cli/utils/output.py,sha256=GNjU85ZAMp5BI6Yij5wYXcaAvpm_kmHV0nHNmdkMxb0,646
|
|
|
34
34
|
truss/cli/utils/self_upgrade.py,sha256=eTJZA4Wc8uUp4Qh6viRQp6bZm--wnQp7KWe5KRRpPtg,5427
|
|
35
35
|
truss/contexts/docker_build_setup.py,sha256=cF4ExZgtYvrWxvyCAaUZUvV_DB_7__MqVomUDpalvKo,3925
|
|
36
36
|
truss/contexts/truss_context.py,sha256=uS6L-ACHxNk0BsJwESOHh1lA0OGGw0pb33aFKGsASj4,436
|
|
37
|
-
truss/contexts/image_builder/cache_warmer.py,sha256=
|
|
37
|
+
truss/contexts/image_builder/cache_warmer.py,sha256=TGMV1Mh87n2e_dSowH0sf0rZhZraDOR-LVapZL3a5r8,7377
|
|
38
38
|
truss/contexts/image_builder/image_builder.py,sha256=IuRgDeeoHVLzIkJvKtX3807eeqEyaroCs_KWDcIHZUg,1461
|
|
39
39
|
truss/contexts/image_builder/serving_image_builder.py,sha256=1PfHtkTEdNPhSQAX8Ajk_0LN3KR2EfLKwOJsnECtKXQ,33958
|
|
40
40
|
truss/contexts/image_builder/util.py,sha256=y2-CjUKv0XV-0w2sr1fUCflysDJLsoU4oPp6tvvoFnk,1203
|
|
@@ -63,7 +63,7 @@ truss/remote/baseten/service.py,sha256=HMaKiYbr2Mzv4BfXF9QkJ8H3Wwrq3LOMpFt9js4t0
|
|
|
63
63
|
truss/remote/baseten/utils/status.py,sha256=jputc9N9AHXxUuW4KOk6mcZKzQ_gOBOe5BSx9K0DxPY,1266
|
|
64
64
|
truss/remote/baseten/utils/tar.py,sha256=pMUv--YkwXDngUx1WUOK-KmAIKMcOg2E-CD5x4heh3s,2514
|
|
65
65
|
truss/remote/baseten/utils/time.py,sha256=Ry9GMjYnbIGYVIGwtmv4V8ljWjvdcaCf5NOQzlNeGxI,397
|
|
66
|
-
truss/remote/baseten/utils/transfer.py,sha256=
|
|
66
|
+
truss/remote/baseten/utils/transfer.py,sha256=vMI-Dcd_HaRkqVjWI02y3eK9DjiqgG0ULayS0KxIIvA,1652
|
|
67
67
|
truss/templates/README.md.jinja,sha256=N7CJdyldZuJamj5jLh47le0hFBdu9irVsTBqoxhPNPQ,2476
|
|
68
68
|
truss/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
69
69
|
truss/templates/base.Dockerfile.jinja,sha256=tdMmK5TeiQuYbz4gqbACM3R-l-mazqL9tAZtJ4sxC4g,5331
|
|
@@ -318,7 +318,7 @@ truss/tests/test_data/test_truss_with_error/packages/helpers_2.py,sha256=q_UpVfX
|
|
|
318
318
|
truss/tests/trt_llm/test_trt_llm_config.py,sha256=lNQ4EEkOsiT17KvnvW1snCeEBd7K_cl9_Y0dko3qpn8,8505
|
|
319
319
|
truss/tests/trt_llm/test_validation.py,sha256=dmax2EHxRfqxJvWzV8uubkTef50833KBBHw-WkHufL8,2120
|
|
320
320
|
truss/tests/util/test_config_checks.py,sha256=aoZF_Q-eRd3qz5wjUqa8Cr_7qF2SxodXbBIY_DBuFWg,522
|
|
321
|
-
truss/tests/util/test_env_vars.py,sha256=
|
|
321
|
+
truss/tests/util/test_env_vars.py,sha256=kz5FlynWvXhNR9bhf-xC-0cXuyYyAOvtKLLxKLDUGf4,616
|
|
322
322
|
truss/tests/util/test_path.py,sha256=YfW3-IM_7iRsdR1Cb26KB1BkDsG_53_BUGBzoxY2Nog,7408
|
|
323
323
|
truss/trt_llm/config_checks.py,sha256=Efxb5l7vRNveDglse78untq9V-IgtLxejk3_8JKxN5I,4671
|
|
324
324
|
truss/trt_llm/validation.py,sha256=cse-EnmuHmRpwBuSc3IvmSnl-StSQCIFM1nssgnaRUQ,1848
|
|
@@ -341,8 +341,8 @@ truss/util/.truss_ignore,sha256=jpQA9ou-r_JEIcEHsUqGLHhir_m3d4IPGNyzKXtS-2g,3131
|
|
|
341
341
|
truss/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
342
342
|
truss/util/docker.py,sha256=6PD7kMBBrOjsdvgkuSv7JMgZbe3NoJIeGasljMm2SwA,3934
|
|
343
343
|
truss/util/download.py,sha256=1lfBwzyaNLEp7SAVrBd9BX5inZpkCVp8sBnS9RNoiJA,2521
|
|
344
|
-
truss/util/env_vars.py,sha256=
|
|
345
|
-
truss/util/error_utils.py,sha256=
|
|
344
|
+
truss/util/env_vars.py,sha256=PmKsXdN-PX2-_xk9XcdHTFuRRWiFaMw2iNUKxE8B1Ro,1671
|
|
345
|
+
truss/util/error_utils.py,sha256=pvBH_opyCVpfUbFvm8bgOtjOWit23x2smkBPPdkSZwc,1148
|
|
346
346
|
truss/util/gpu.py,sha256=YiEF_JZyzur0MDMJOebMuJBQxrHD9ApGI0aPpWdb5BU,553
|
|
347
347
|
truss/util/jinja.py,sha256=7KbuYNq55I3DGtImAiCvBwR0K9-z1Jo6gMhmsy4lNZE,333
|
|
348
348
|
truss/util/log_utils.py,sha256=LwSgRh2K7KFjKKqBxr-IirFxGIzHi1mUM7YEvujvHsE,1985
|
|
@@ -374,8 +374,8 @@ truss_train/deployment.py,sha256=lWWANSuzBWu2M4oK4qD7n-oVR1JKdmw2Pn5BJQHg-Ck,307
|
|
|
374
374
|
truss_train/loader.py,sha256=0o66EjBaHc2YY4syxxHVR4ordJWs13lNXnKjKq2wq0U,1630
|
|
375
375
|
truss_train/public_api.py,sha256=9N_NstiUlmBuLUwH_fNG_1x7OhGCytZLNvqKXBlStrM,1220
|
|
376
376
|
truss_train/restore_from_checkpoint.py,sha256=8hdPm-WSgkt74HDPjvCjZMBpvA9MwtoYsxVjOoa7BaM,1176
|
|
377
|
-
truss-0.11.
|
|
378
|
-
truss-0.11.
|
|
379
|
-
truss-0.11.
|
|
380
|
-
truss-0.11.
|
|
381
|
-
truss-0.11.
|
|
377
|
+
truss-0.11.17.dist-info/METADATA,sha256=z5W692XFnV2zh5UD0VlZTkRIagNShoxtaSB_mhYa0lA,6678
|
|
378
|
+
truss-0.11.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
379
|
+
truss-0.11.17.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
|
|
380
|
+
truss-0.11.17.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
|
|
381
|
+
truss-0.11.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|