truss 0.11.3__py3-none-any.whl → 0.11.4rc1__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/remote/baseten/api.py +8 -0
- truss/remote/baseten/custom_types.py +7 -0
- truss/templates/control/requirements.txt +2 -1
- truss/templates/server/requirements.txt +2 -1
- {truss-0.11.3.dist-info → truss-0.11.4rc1.dist-info}/METADATA +1 -1
- {truss-0.11.3.dist-info → truss-0.11.4rc1.dist-info}/RECORD +12 -12
- truss_chains/deployment/code_gen.py +3 -3
- truss_chains/deployment/deployment_client.py +11 -4
- truss_chains/public_types.py +9 -4
- {truss-0.11.3.dist-info → truss-0.11.4rc1.dist-info}/WHEEL +0 -0
- {truss-0.11.3.dist-info → truss-0.11.4rc1.dist-info}/entry_points.txt +0 -0
- {truss-0.11.3.dist-info → truss-0.11.4rc1.dist-info}/licenses/LICENSE +0 -0
truss/remote/baseten/api.py
CHANGED
|
@@ -6,6 +6,7 @@ import requests
|
|
|
6
6
|
|
|
7
7
|
from truss.remote.baseten import custom_types as b10_types
|
|
8
8
|
from truss.remote.baseten.auth import ApiKey, AuthService
|
|
9
|
+
from truss.remote.baseten.custom_types import APIKeyCategory
|
|
9
10
|
from truss.remote.baseten.error import ApiError
|
|
10
11
|
from truss.remote.baseten.rest_client import RestAPIClient
|
|
11
12
|
from truss.remote.baseten.utils.transfer import base64_encoded_json_str
|
|
@@ -560,6 +561,13 @@ class BasetenApi:
|
|
|
560
561
|
def get_all_secrets(self) -> Any:
|
|
561
562
|
return self._rest_api_client.get("v1/secrets")
|
|
562
563
|
|
|
564
|
+
# NOTE(Tyron): `name` is required because all official
|
|
565
|
+
# Baseten API keys should have a descriptive name.
|
|
566
|
+
def create_api_key(self, api_key_type: APIKeyCategory, name: str) -> Any:
|
|
567
|
+
return self._rest_api_client.post(
|
|
568
|
+
"v1/api_keys", body={"type": api_key_type.value, "name": name}
|
|
569
|
+
)
|
|
570
|
+
|
|
563
571
|
def upsert_training_project(self, training_project):
|
|
564
572
|
resp_json = self._rest_api_client.post(
|
|
565
573
|
"v1/training_projects",
|
|
@@ -155,3 +155,10 @@ class GetCacheSummaryResponseV1(pydantic.BaseModel):
|
|
|
155
155
|
file_summaries: list[FileSummary] = pydantic.Field(
|
|
156
156
|
description="List of files in the cache"
|
|
157
157
|
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class APIKeyCategory(Enum):
|
|
161
|
+
PERSONAL = "PERSONAL"
|
|
162
|
+
WORKSPACE_MANAGE_ALL = "WORKSPACE_MANAGE_ALL"
|
|
163
|
+
WORKSPACE_EXPORT_METRICS = "WORKSPACE_EXPORT_METRICS"
|
|
164
|
+
WORKSPACE_INVOKE = "WORKSPACE_INVOKE"
|
|
@@ -7,6 +7,7 @@ python-json-logger>=2.0.2
|
|
|
7
7
|
tenacity>=8.1.0
|
|
8
8
|
# To avoid divergence, this should follow the latest release.
|
|
9
9
|
truss==0.11.1
|
|
10
|
-
|
|
10
|
+
# NB(nikhil): Uvicorn 0.36.0 has breaking changes for the event loop, so we pin to a lower version.
|
|
11
|
+
uvicorn>=0.24.0,<0.36.0
|
|
11
12
|
uvloop>=0.19.0
|
|
12
13
|
websockets>=10.0
|
|
@@ -19,6 +19,7 @@ python-json-logger>=2.0.2
|
|
|
19
19
|
pyyaml>=6.0.0
|
|
20
20
|
requests>=2.31.0
|
|
21
21
|
truss-transfer==0.0.30
|
|
22
|
-
|
|
22
|
+
# NB(nikhil): Uvicorn 0.36.0 has breaking changes for the event loop, so we pin to a lower version.
|
|
23
|
+
uvicorn>=0.24.0,<0.36.0
|
|
23
24
|
uvloop>=0.19.0
|
|
24
25
|
websockets>=10.0
|
|
@@ -52,10 +52,10 @@ truss/patch/truss_dir_patch_applier.py,sha256=ALnaVnu96g0kF2UmGuBFTua3lrXpwAy4sG
|
|
|
52
52
|
truss/remote/remote_factory.py,sha256=-0gLh_yIyNDgD48Q6sR8Yo5dOMQg84lrHRvn_XR0n4s,3585
|
|
53
53
|
truss/remote/truss_remote.py,sha256=TEe6h6by5-JLy7PMFsDN2QxIY5FmdIYN3bKvHHl02xM,8440
|
|
54
54
|
truss/remote/baseten/__init__.py,sha256=XNqJW1zyp143XQc6-7XVwsUA_Q_ZJv_ausn1_Ohtw9Y,176
|
|
55
|
-
truss/remote/baseten/api.py,sha256=
|
|
55
|
+
truss/remote/baseten/api.py,sha256=5XsB0mSfFD2YGybco4aPGMQalSvhsqv-QgzW4A66r7k,25081
|
|
56
56
|
truss/remote/baseten/auth.py,sha256=tI7s6cI2EZgzpMIzrdbILHyGwiHDnmoKf_JBhJXT55E,776
|
|
57
57
|
truss/remote/baseten/core.py,sha256=uxtmBI9RAVHu1glIEJb5Q4ccJYLeZM1Cp5Svb9W68Yw,21965
|
|
58
|
-
truss/remote/baseten/custom_types.py,sha256=
|
|
58
|
+
truss/remote/baseten/custom_types.py,sha256=bYrfTzGgYr6FDoya0omyadCLSTcTc-83U2scQORyUj0,4715
|
|
59
59
|
truss/remote/baseten/error.py,sha256=3TNTwwPqZnr4NRd9Sl6SfLUQR2fz9l6akDPpOntTpzA,578
|
|
60
60
|
truss/remote/baseten/remote.py,sha256=Se8AES5mk8jxa8S9fN2DSG7wnsaV7ftRjJ4Uwc_w_S0,22544
|
|
61
61
|
truss/remote/baseten/rest_client.py,sha256=_t3CWsWARt2u0C0fDsF4rtvkkHe-lH7KXoPxWXAkKd4,1185
|
|
@@ -72,7 +72,7 @@ truss/templates/cache_requirements.txt,sha256=xoPoJ-OVnf1z6oq_RVM3vCr3ionByyqMLj
|
|
|
72
72
|
truss/templates/copy_cache_files.Dockerfile.jinja,sha256=Os5zFdYLZ_AfCRGq4RcpVTObOTwL7zvmwYcvOzd_Zqo,126
|
|
73
73
|
truss/templates/docker_server_requirements.txt,sha256=PyhOPKAmKW1N2vLvTfLMwsEtuGpoRrbWuNo7tT6v2Mc,18
|
|
74
74
|
truss/templates/server.Dockerfile.jinja,sha256=CUYnF_hgxPGq2re7__0UPWlwzOHMoFkxp6NVKi3U16s,7071
|
|
75
|
-
truss/templates/control/requirements.txt,sha256=
|
|
75
|
+
truss/templates/control/requirements.txt,sha256=nqqNmlTwFeV8sV4fqwItwzzd_egADBP_e-cEopXBJ4k,358
|
|
76
76
|
truss/templates/control/control/application.py,sha256=jYeta6hWe1SkfLL3W4IDmdYjg3ZuKqI_UagWYs5RB_E,3793
|
|
77
77
|
truss/templates/control/control/endpoints.py,sha256=VQ1lvZjFvR091yRkiFdvXw1Q7PiNGXT9rJwY7_sX6yg,11828
|
|
78
78
|
truss/templates/control/control/server.py,sha256=R4Y219i1dcz0kkksN8obLoX-YXWGo9iW1igindyG50c,3128
|
|
@@ -96,7 +96,7 @@ truss/templates/docker_server/supervisord.conf.jinja,sha256=dd37fwZE--cutrvOUCqE
|
|
|
96
96
|
truss/templates/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
97
97
|
truss/templates/server/main.py,sha256=kWXrdD8z8IpamyWxc8qcvd5ck9gM1Kz2QH5qHJCnmOQ,222
|
|
98
98
|
truss/templates/server/model_wrapper.py,sha256=k75VVISwwlsx5EGb82UZsu8kCM_i6Yi3-Hd0-Kpm1yo,42055
|
|
99
|
-
truss/templates/server/requirements.txt,sha256=
|
|
99
|
+
truss/templates/server/requirements.txt,sha256=fMLT-6FuY-j3dyJdOosR5fKqcBOkCZOob7Pl_Y0feg8,780
|
|
100
100
|
truss/templates/server/truss_server.py,sha256=noXfGJMsKIhgF4oI_8LC1UHkcx8Vg8nGSITZJ_bkRFQ,19598
|
|
101
101
|
truss/templates/server/common/__init__.py,sha256=qHIqr68L5Tn4mV6S-PbORpcuJ4jmtBR8aCuRTIWDvNo,85
|
|
102
102
|
truss/templates/server/common/errors.py,sha256=My0P6-Y7imVTICIhazHT0vlSu3XJDH7As06OyVzu4Do,8589
|
|
@@ -348,14 +348,14 @@ truss_chains/__init__.py,sha256=QDw1YwdqMaQpz5Oltu2Eq2vzEX9fDrMoqnhtbeh60i4,1278
|
|
|
348
348
|
truss_chains/framework.py,sha256=CS7tSegPe2Q8UUT6CDkrtSrB3utr_1QN1jTEPjrj5Ug,67519
|
|
349
349
|
truss_chains/private_types.py,sha256=6CaQEPawFLXjEbJ-01lqfexJtUIekF_q61LNENWegFo,8917
|
|
350
350
|
truss_chains/public_api.py,sha256=0AXV6UdZIFAMycUNG_klgo4aLFmBZeKGfrulZEWzR0M,9532
|
|
351
|
-
truss_chains/public_types.py,sha256=
|
|
351
|
+
truss_chains/public_types.py,sha256=RPr8jgKO_F_26F7H3CpwbidL-6euoKPdFHVpEIpYqrQ,29415
|
|
352
352
|
truss_chains/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
353
353
|
truss_chains/pydantic_numpy.py,sha256=MG8Ji_Inwo_JSfM2n7TPj8B-nbrBlDYsY3SOeBwD8fE,4289
|
|
354
354
|
truss_chains/streaming.py,sha256=DGl2LEAN67YwP7Nn9MK488KmYc4KopWmcHuE6WjyO1Q,12521
|
|
355
355
|
truss_chains/utils.py,sha256=LvpCG2lnN6dqPqyX3PwLH9tyjUzqQN3N4WeEFROMHak,6291
|
|
356
356
|
truss_chains/deployment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
357
|
-
truss_chains/deployment/code_gen.py,sha256=
|
|
358
|
-
truss_chains/deployment/deployment_client.py,sha256=
|
|
357
|
+
truss_chains/deployment/code_gen.py,sha256=397FiSNZuW59J3Ma7N9GKGfvG_87BNFAXCIV8BW41t0,32669
|
|
358
|
+
truss_chains/deployment/deployment_client.py,sha256=OoqkO3daktYzR2YsIcDvsuGfjR05X2K7QlA7wvFduzc,34208
|
|
359
359
|
truss_chains/reference_code/reference_chainlet.py,sha256=5feSeqGtrHDbldkfZCfX2R5YbbW0Uhc35mhaP2pXrHw,1340
|
|
360
360
|
truss_chains/reference_code/reference_model.py,sha256=emH3hb23E_nbP98I37PGp1Xk1hz3g3lQ00tiLo55cSM,322
|
|
361
361
|
truss_chains/remote_chainlet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -368,8 +368,8 @@ truss_train/deployment.py,sha256=lWWANSuzBWu2M4oK4qD7n-oVR1JKdmw2Pn5BJQHg-Ck,307
|
|
|
368
368
|
truss_train/loader.py,sha256=0o66EjBaHc2YY4syxxHVR4ordJWs13lNXnKjKq2wq0U,1630
|
|
369
369
|
truss_train/public_api.py,sha256=9N_NstiUlmBuLUwH_fNG_1x7OhGCytZLNvqKXBlStrM,1220
|
|
370
370
|
truss_train/restore_from_checkpoint.py,sha256=KmJuTUVpvtvlkEClcmllxAF2TKgbp-FuzfblfGh06XA,1239
|
|
371
|
-
truss-0.11.
|
|
372
|
-
truss-0.11.
|
|
373
|
-
truss-0.11.
|
|
374
|
-
truss-0.11.
|
|
375
|
-
truss-0.11.
|
|
371
|
+
truss-0.11.4rc1.dist-info/METADATA,sha256=yy9ab3NYRQruWFmhfzJmsBssRYRYmFTW1ylVuA2COCE,6672
|
|
372
|
+
truss-0.11.4rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
373
|
+
truss-0.11.4rc1.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
|
|
374
|
+
truss-0.11.4rc1.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
|
|
375
|
+
truss-0.11.4rc1.dist-info/RECORD,,
|
|
@@ -764,13 +764,13 @@ def _gen_truss_config(
|
|
|
764
764
|
config.external_package_dirs.append(ext_dir.abs_path)
|
|
765
765
|
config.use_local_src = use_local_src
|
|
766
766
|
|
|
767
|
-
if public_types.
|
|
768
|
-
config.secrets[public_types.
|
|
767
|
+
if public_types.CHAIN_API_KEY_SECRET_NAME not in config.secrets:
|
|
768
|
+
config.secrets[public_types.CHAIN_API_KEY_SECRET_NAME] = (
|
|
769
769
|
public_types.SECRET_DUMMY
|
|
770
770
|
)
|
|
771
771
|
else:
|
|
772
772
|
logging.info(
|
|
773
|
-
f"Chains automatically add {public_types.
|
|
773
|
+
f"Chains automatically add {public_types.CHAIN_API_KEY_SECRET_NAME} "
|
|
774
774
|
"to secrets - no need to manually add it."
|
|
775
775
|
)
|
|
776
776
|
config.model_cache = truss_config.ModelCache(assets.cached)
|
|
@@ -303,7 +303,7 @@ def _push_service_docker(
|
|
|
303
303
|
options: private_types.PushOptionsLocalDocker,
|
|
304
304
|
) -> str:
|
|
305
305
|
th = truss_handle.TrussHandle(truss_dir)
|
|
306
|
-
th.add_secret(public_types.
|
|
306
|
+
th.add_secret(public_types.CHAIN_API_KEY_SECRET_NAME, options.baseten_chain_api_key)
|
|
307
307
|
container = th.docker_run(
|
|
308
308
|
local_port=None,
|
|
309
309
|
detach=True,
|
|
@@ -536,14 +536,21 @@ def _create_baseten_chain(
|
|
|
536
536
|
def _create_chains_secret_if_missing(remote_provider: b10_remote.BasetenRemote) -> None:
|
|
537
537
|
secrets_info = remote_provider.api.get_all_secrets()
|
|
538
538
|
secret_names = {sec["name"] for sec in secrets_info["secrets"]}
|
|
539
|
-
|
|
539
|
+
|
|
540
|
+
if public_types.CHAIN_API_KEY_SECRET_NAME not in secret_names:
|
|
540
541
|
logging.info(
|
|
541
542
|
"It seems you are using chains for the first time, since there "
|
|
542
|
-
f"is no `{public_types.
|
|
543
|
+
f"is no `{public_types.CHAIN_API_KEY_SECRET_NAME}` secret on baseten. "
|
|
543
544
|
"Creating secret automatically."
|
|
544
545
|
)
|
|
546
|
+
|
|
547
|
+
workspace_api_key = remote_provider.api.create_api_key(
|
|
548
|
+
api_key_type=b10_types.APIKeyCategory.WORKSPACE_INVOKE,
|
|
549
|
+
name=public_types.CHAIN_API_KEY_NAME,
|
|
550
|
+
)["api_key"]
|
|
551
|
+
|
|
545
552
|
remote_provider.api.upsert_secret(
|
|
546
|
-
public_types.
|
|
553
|
+
public_types.CHAIN_API_KEY_SECRET_NAME, workspace_api_key
|
|
547
554
|
)
|
|
548
555
|
|
|
549
556
|
|
truss_chains/public_types.py
CHANGED
|
@@ -28,7 +28,12 @@ DEFAULT_CONCURRENCY_LIMIT = 300
|
|
|
28
28
|
CpuCountT = Literal["cpu_count"]
|
|
29
29
|
CPU_COUNT: CpuCountT = "cpu_count"
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
# NOTE(Tyron): This is a secret that points to an API key value.
|
|
33
|
+
CHAIN_API_KEY_SECRET_NAME = "baseten_chain_api_key"
|
|
34
|
+
|
|
35
|
+
# NOTE(Tyron): This is the actual API key pointed to by the above secret.
|
|
36
|
+
CHAIN_API_KEY_NAME = "baseten-chain-api-key"
|
|
32
37
|
|
|
33
38
|
_K = TypeVar("_K", contravariant=True)
|
|
34
39
|
_V = TypeVar("_V", covariant=True)
|
|
@@ -738,14 +743,14 @@ class DeploymentContext(custom_types.SafeModelNonSerializable):
|
|
|
738
743
|
)
|
|
739
744
|
error_msg = (
|
|
740
745
|
"For using chains, it is required to setup a an API key with name "
|
|
741
|
-
f"`{
|
|
746
|
+
f"`{CHAIN_API_KEY_SECRET_NAME}` on Baseten to allow chain Chainlet to "
|
|
742
747
|
"call other Chainlets. For local execution, secrets can be provided "
|
|
743
748
|
"to `run_local`."
|
|
744
749
|
)
|
|
745
|
-
if
|
|
750
|
+
if CHAIN_API_KEY_SECRET_NAME not in self.secrets:
|
|
746
751
|
raise MissingDependencyError(error_msg)
|
|
747
752
|
|
|
748
|
-
api_key = self.secrets[
|
|
753
|
+
api_key = self.secrets[CHAIN_API_KEY_SECRET_NAME]
|
|
749
754
|
if api_key == SECRET_DUMMY:
|
|
750
755
|
raise MissingDependencyError(
|
|
751
756
|
f"{error_msg}. Retrieved dummy value of `{api_key}`."
|
|
File without changes
|
|
File without changes
|
|
File without changes
|