truss 0.11.2rc504__py3-none-any.whl → 0.11.3__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/api/__init__.py CHANGED
@@ -64,6 +64,7 @@ def push(
64
64
  environment: Optional[str] = None,
65
65
  progress_bar: Optional[Type["progress.Progress"]] = None,
66
66
  include_git_info: bool = False,
67
+ preserve_env_instance_type: bool = True,
67
68
  ) -> definitions.ModelDeployment:
68
69
  """
69
70
  Pushes a Truss to Baseten.
@@ -88,6 +89,9 @@ def push(
88
89
  include_git_info: Whether to attach git versioning info (sha, branch, tag) to
89
90
  deployments made from within a git repo. If set to True in `.trussrc`, it
90
91
  will always be attached.
92
+ preserve_env_instance_type: When pushing a truss to an environment, whether to use the resources
93
+ specified in the truss config to resolve the instance type or preserve the instance type
94
+ configured in the specified environment.
91
95
 
92
96
  Returns:
93
97
  The newly created ModelDeployment.
@@ -130,6 +134,7 @@ def push(
130
134
  environment=environment,
131
135
  progress_bar=progress_bar,
132
136
  include_git_info=include_git_info,
137
+ preserve_env_instance_type=preserve_env_instance_type,
133
138
  ) # type: ignore
134
139
 
135
140
  return definitions.ModelDeployment(cast(BasetenService, service))
@@ -54,7 +54,9 @@ class ModelContainerPatchApplier:
54
54
  py_req_patch: PythonRequirementPatch = patch.body
55
55
  self._apply_python_requirement_patch(py_req_patch)
56
56
  elif isinstance(patch.body, SystemPackagePatch):
57
- raise UnsupportedPatch("System package patches are not supported for model container, please push truss again instead")
57
+ raise UnsupportedPatch(
58
+ "System package patches are not supported for model container, please run truss push again"
59
+ )
58
60
  elif isinstance(patch.body, ConfigPatch):
59
61
  config_patch: ConfigPatch = patch.body
60
62
  self._apply_config_patch(config_patch)
@@ -113,7 +115,6 @@ class ModelContainerPatchApplier:
113
115
  else:
114
116
  raise ValueError(f"Unknown python requirement patch action {action}")
115
117
 
116
-
117
118
  def _apply_config_patch(self, config_patch: ConfigPatch):
118
119
  self._app_logger.debug(f"Applying config patch {config_patch.to_dict()}")
119
120
  TrussConfig.from_dict(config_patch.config).write_to_yaml_file(
@@ -16,7 +16,6 @@ from truss.templates.control.control.helpers.custom_types import (
16
16
  Patch,
17
17
  PatchType,
18
18
  PythonRequirementPatch,
19
- SystemPackagePatch,
20
19
  )
21
20
  from truss.truss_handle.patch.calc_patch import (
22
21
  _calc_python_requirements_patches,
@@ -736,49 +735,33 @@ def test_calc_config_patches_add_remove_env_var(custom_model_truss_dir: Path):
736
735
  ]
737
736
 
738
737
 
739
- def test_calc_config_patches_add_system_package(custom_model_truss_dir: Path):
740
- patches = _apply_config_change_and_calc_patches(
741
- custom_model_truss_dir, lambda config: config.system_packages.append("curl")
742
- )
743
- assert len(patches) == 2
744
- assert patches == [
745
- Patch(
746
- type=PatchType.CONFIG,
747
- body=ConfigPatch(
748
- action=Action.UPDATE,
749
- config=yaml.safe_load((custom_model_truss_dir / "config.yaml").open()),
750
- ),
751
- ),
752
- Patch(
753
- type=PatchType.SYSTEM_PACKAGE,
754
- body=SystemPackagePatch(action=Action.ADD, package="curl"),
755
- ),
756
- ]
738
+ def test_system_package_changes_make_truss_unpatchable_add(
739
+ custom_model_truss_dir: Path,
740
+ ):
741
+ # System package changes should raise a ValueError indicating full rebuild required
742
+ with pytest.raises(
743
+ ValueError, match="System package changes detected - full rebuild required"
744
+ ):
745
+ _apply_config_change_and_calc_patches(
746
+ custom_model_truss_dir, lambda config: config.system_packages.append("curl")
747
+ )
757
748
 
758
749
 
759
- def test_calc_config_patches_remove_system_package(custom_model_truss_dir: Path):
760
- patches = _apply_config_change_and_calc_patches(
761
- custom_model_truss_dir,
762
- config_pre_op=lambda config: config.system_packages.append("curl"),
763
- config_op=lambda config: config.system_packages.clear(),
764
- )
765
- assert len(patches) == 2
766
- assert patches == [
767
- Patch(
768
- type=PatchType.CONFIG,
769
- body=ConfigPatch(
770
- action=Action.UPDATE,
771
- config=yaml.safe_load((custom_model_truss_dir / "config.yaml").open()),
772
- ),
773
- ),
774
- Patch(
775
- type=PatchType.SYSTEM_PACKAGE,
776
- body=SystemPackagePatch(action=Action.REMOVE, package="curl"),
777
- ),
778
- ]
750
+ def test_system_package_changes_make_truss_unpatchable_remove(
751
+ custom_model_truss_dir: Path,
752
+ ):
753
+ # System package changes should raise a ValueError indicating full rebuild required
754
+ with pytest.raises(
755
+ ValueError, match="System package changes detected - full rebuild required"
756
+ ):
757
+ _apply_config_change_and_calc_patches(
758
+ custom_model_truss_dir,
759
+ config_pre_op=lambda config: config.system_packages.append("curl"),
760
+ config_op=lambda config: config.system_packages.clear(),
761
+ )
779
762
 
780
763
 
781
- def test_calc_config_patches_add_and_remove_system_package(
764
+ def test_system_package_changes_make_truss_unpatchable_modify(
782
765
  custom_model_truss_dir: Path,
783
766
  ):
784
767
  def config_pre_op(config: TrussConfig):
@@ -787,29 +770,13 @@ def test_calc_config_patches_add_and_remove_system_package(
787
770
  def config_op(config: TrussConfig):
788
771
  config.system_packages = ["curl", "libsnd"]
789
772
 
790
- patches = _apply_config_change_and_calc_patches(
791
- custom_model_truss_dir, config_pre_op=config_pre_op, config_op=config_op
792
- )
793
- assert len(patches) == 3
794
- assert patches[0] == Patch(
795
- type=PatchType.CONFIG,
796
- body=ConfigPatch(
797
- action=Action.UPDATE,
798
- config=yaml.safe_load((custom_model_truss_dir / "config.yaml").open()),
799
- ),
800
- )
801
- patches = patches[1:]
802
- patches.sort(key=lambda patch: patch.body.package)
803
- assert patches == [
804
- Patch(
805
- type=PatchType.SYSTEM_PACKAGE,
806
- body=SystemPackagePatch(action=Action.REMOVE, package="jq"),
807
- ),
808
- Patch(
809
- type=PatchType.SYSTEM_PACKAGE,
810
- body=SystemPackagePatch(action=Action.ADD, package="libsnd"),
811
- ),
812
- ]
773
+ # System package changes should raise a ValueError indicating full rebuild required
774
+ with pytest.raises(
775
+ ValueError, match="System package changes detected - full rebuild required"
776
+ ):
777
+ _apply_config_change_and_calc_patches(
778
+ custom_model_truss_dir, config_pre_op=config_pre_op, config_op=config_op
779
+ )
813
780
 
814
781
 
815
782
  def test_calc_config_patches_toggle_apply_library_patches(custom_model_truss_dir: Path):
@@ -9,8 +9,6 @@ from truss.tests.test_testing_utilities_for_other_tests import ensure_kill_all
9
9
  from truss.tests.test_truss_handle import (
10
10
  verify_python_requirement_installed_on_container,
11
11
  verify_python_requirement_not_installed_on_container,
12
- verify_system_package_installed_on_container,
13
- verify_system_requirement_not_installed_on_container,
14
12
  )
15
13
  from truss.truss_handle.truss_gatherer import calc_shadow_truss_dirname
16
14
  from truss.truss_handle.truss_handle import TrussHandle
@@ -147,14 +145,6 @@ def test_control_truss_python_sys_req_patch(
147
145
  th.remove_python_requirement(req)
148
146
  return th.docker_predict([1], tag=tag, binary=binary, local_port=None)
149
147
 
150
- def predict_with_system_requirement_added(pkg):
151
- th.add_system_package(pkg)
152
- return th.docker_predict([1], tag=tag, binary=binary, local_port=None)
153
-
154
- def predict_with_system_requirement_removed(pkg):
155
- th.remove_system_package(pkg)
156
- return th.docker_predict([1], tag=tag, binary=binary, local_port=None)
157
-
158
148
  with ensure_kill_all():
159
149
  th.docker_predict([1], tag=tag, binary=binary, local_port=None)
160
150
  orig_num_truss_images = len(th.get_all_docker_images())
@@ -170,15 +160,6 @@ def test_control_truss_python_sys_req_patch(
170
160
  assert current_num_docker_images(th) == orig_num_truss_images
171
161
  verify_python_requirement_not_installed_on_container(container, python_req)
172
162
 
173
- system_pkg = "jq"
174
- predict_with_system_requirement_added(system_pkg)
175
- assert current_num_docker_images(th) == orig_num_truss_images
176
- verify_system_package_installed_on_container(container, system_pkg)
177
-
178
- predict_with_system_requirement_removed(system_pkg)
179
- assert current_num_docker_images(th) == orig_num_truss_images
180
- verify_system_requirement_not_installed_on_container(container, system_pkg)
181
-
182
163
 
183
164
  @pytest.mark.integration
184
165
  @pytest.mark.parametrize(
@@ -18,7 +18,6 @@ from truss.templates.control.control.helpers.custom_types import (
18
18
  Patch,
19
19
  PatchType,
20
20
  PythonRequirementPatch,
21
- SystemPackagePatch,
22
21
  )
23
22
  from truss.templates.control.control.helpers.truss_patch.requirement_name_identifier import (
24
23
  RequirementMeta,
@@ -423,22 +422,18 @@ def _calc_python_requirements_patches(
423
422
  def _calc_system_packages_patches(
424
423
  prev_config: TrussConfig, new_config: TrussConfig
425
424
  ) -> List[Patch]:
426
- """Calculate patch based on changes to system packates.
425
+ """Calculate patch based on changes to system packages.
427
426
 
428
- Empty list means no relevant differences found.
427
+ System package patches are no longer supported, so this function
428
+ raises an exception if any system package changes are detected.
429
429
  """
430
- patches = []
431
430
  prev_pkgs = system_packages_set(prev_config.system_packages)
432
431
  new_pkgs = system_packages_set(new_config.system_packages)
433
- removed_pkgs = prev_pkgs.difference(new_pkgs)
434
- for removed_pkg in removed_pkgs:
435
- patches.append(_mk_system_package_patch(Action.REMOVE, removed_pkg))
436
432
 
437
- added_pkgs = new_pkgs.difference(prev_pkgs)
438
- for added_pkg in added_pkgs:
439
- patches.append(_mk_system_package_patch(Action.ADD, added_pkg))
433
+ if prev_pkgs != new_pkgs:
434
+ raise ValueError("System package changes detected - full rebuild required")
440
435
 
441
- return patches
436
+ return []
442
437
 
443
438
 
444
439
  def _mk_config_patch(action: Action, config: dict) -> Patch:
@@ -471,13 +466,6 @@ def _mk_python_requirement_patch(action: Action, requirement: str) -> Patch:
471
466
  )
472
467
 
473
468
 
474
- def _mk_system_package_patch(action: Action, package: str) -> Patch:
475
- return Patch(
476
- type=PatchType.SYSTEM_PACKAGE,
477
- body=SystemPackagePatch(action=action, package=package),
478
- )
479
-
480
-
481
469
  def _relative_to(path: str, relative_to_path: str):
482
470
  return str(Path(path).relative_to(relative_to_path))
483
471
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: truss
3
- Version: 0.11.2rc504
3
+ Version: 0.11.3
4
4
  Summary: A seamless bridge from model development to model delivery
5
5
  Project-URL: Repository, https://github.com/basetenlabs/truss
6
6
  Project-URL: Homepage, https://truss.baseten.co
@@ -1,5 +1,5 @@
1
1
  truss/__init__.py,sha256=CoUcP6vx_pocyemRmpbCPlndkHhdMkABAlr0ZXVuPCk,1163
2
- truss/api/__init__.py,sha256=spBAa_m1pItiid97iDLKPmumgAkSirPkv-E8RWMZyOk,5090
2
+ truss/api/__init__.py,sha256=5GTE2rlupet-beaawUr0FPyDPEJ9UyBTUpJmCE3RGfc,5453
3
3
  truss/api/definitions.py,sha256=QAaIBqL59Q-R7HtLcXcoeCIWBN2HqOzApdFX0PpCq2s,1604
4
4
  truss/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  truss/base/constants.py,sha256=sExArdnuGg83z83XMgaQ4b8SS3V_j_bJEpOATDGJzpE,3600
@@ -84,7 +84,7 @@ truss/templates/control/control/helpers/inference_server_process_controller.py,s
84
84
  truss/templates/control/control/helpers/inference_server_starter.py,sha256=Fz2Puijro6Cc5cvTsAqOveNJbBQR_ARYJXl4lvETJ8Y,2633
85
85
  truss/templates/control/control/helpers/truss_patch/__init__.py,sha256=CXZdUV_ylqLTJrKuFpvSnUT6PUFrZrMF2y6jiHbdaKU,998
86
86
  truss/templates/control/control/helpers/truss_patch/model_code_patch_applier.py,sha256=LTIIADLz0wRn7V49j64dU1U7Hbta9YLde3pb5YZWvzQ,2001
87
- truss/templates/control/control/helpers/truss_patch/model_container_patch_applier.py,sha256=rxJzXwNmrr_2FOM9gZSE3TDbV-Bpwz67fv1dcMsQ9EE,6420
87
+ truss/templates/control/control/helpers/truss_patch/model_container_patch_applier.py,sha256=uiZvKhLa_rpr_N67NpApgA-XVrBFLXraZlikSOFDDOw,6445
88
88
  truss/templates/control/control/helpers/truss_patch/requirement_name_identifier.py,sha256=CL3KEAj4B3ApMQShd7TI5umXVbazLZY5StrNlwHwWtc,1995
89
89
  truss/templates/control/control/helpers/truss_patch/system_packages.py,sha256=IYh1CVU_kooAvtSGXKQDDWnNdOhlv7ENWagsL1wvhgw,208
90
90
  truss/templates/custom/examples.yaml,sha256=2UcCtEdavImWmiCtj31ckBlAKVOwNMC5AwMIIznKDag,48
@@ -131,7 +131,7 @@ truss/tests/helpers.py,sha256=DKnUGzmt-k4IN_wSnlAXbVYCiEt58xFzFmmuCDSQ0dg,555
131
131
  truss/tests/test_build.py,sha256=Wq4sM9tmZFVTCN3YljvOcn04Kkj-L-41Tlw0DKQ8Z7c,709
132
132
  truss/tests/test_config.py,sha256=AVpVCL_XHYXKSGHzwecrh7BAJlB_Wr5AUlnnwMqWM98,30559
133
133
  truss/tests/test_context_builder_image.py,sha256=fVZNJSzZNiWa7Dr1X_VhhMJtyJ5HzsLaPglOr6NV2CA,1105
134
- truss/tests/test_control_truss_patching.py,sha256=lbMuAjLbkeDRLxUxXHWr41BZyhZKHQYoMnbJSj3dqrc,15390
134
+ truss/tests/test_control_truss_patching.py,sha256=qQOUfyF1MorZ_obOvPJK9utI4HUAzgT6YBS-fo90TEw,14497
135
135
  truss/tests/test_custom_server.py,sha256=GP2qMgnqxJMPRtfEciqbhBcG0_JUK7gNL7nrXPGrSLg,1305
136
136
  truss/tests/test_docker.py,sha256=3RI6jEC9CVQsKj83s_gOBl3EkdOaov-KEX4IihfMJW4,523
137
137
  truss/tests/test_model_inference.py,sha256=9QfPMa1kjxvKCWg5XKocjwcpfDkKB7pWd8bn4hIkshk,76213
@@ -150,7 +150,7 @@ truss/tests/contexts/image_builder/test_serving_image_builder.py,sha256=16niCXZn
150
150
  truss/tests/contexts/local_loader/test_load_local.py,sha256=D1qMH2IpYA2j5009v50QMgUnKdeOsX15ndkwXe10a4E,801
151
151
  truss/tests/contexts/local_loader/test_truss_module_finder.py,sha256=oN1K2lg3ATHY5yOVUTfQIaSqusTF9I2wFaYaTSo5-O4,5342
152
152
  truss/tests/local/test_local_config_handler.py,sha256=aLvcOyfppskA2MziVLy_kMcagjxMpO4mjar9zxUN6g0,2245
153
- truss/tests/patch/test_calc_patch.py,sha256=GBPvIwIQ12fgYwqiHn7BUzAO5693-AX5R4upwGqfdB8,31960
153
+ truss/tests/patch/test_calc_patch.py,sha256=ClvrkNvxc5-bclXZUnqCis0bS1he2vbxn3DIcrR1WuU,31082
154
154
  truss/tests/patch/test_dir_signature.py,sha256=HnG9Cyqt86YagYkY-jurSf36yYP2oM7PQvfb_d5T2mY,1033
155
155
  truss/tests/patch/test_hash.py,sha256=VsGAllNP653rmyrvPYBRY1gEc0gTpLl38tAhjXFUGGM,5997
156
156
  truss/tests/patch/test_signature.py,sha256=vdAy5dbIqTEWLZVpO6szTGdNTRZgE8PtABGuhPP0Y6s,728
@@ -325,7 +325,7 @@ truss/truss_handle/readme_generator.py,sha256=B4XbGwUjzMNOr71DWNAL8kCu5_ZHq7YOM8
325
325
  truss/truss_handle/truss_gatherer.py,sha256=Xysl_UnCVhehPfZeHa8p7WFp94ENqh-VVpbuqnCui3A,2870
326
326
  truss/truss_handle/truss_handle.py,sha256=WF2MQSly9DQ1SoAvqfi87Ulu4llTadpXoncsDjpL79E,40886
327
327
  truss/truss_handle/patch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
328
- truss/truss_handle/patch/calc_patch.py,sha256=Qyk1QmacK4jy9Ia8-93L8VtAWJhw15z22DdZUkBKlys,18334
328
+ truss/truss_handle/patch/calc_patch.py,sha256=_-cBKRiRgleqn7vtqG53Ta18zTE0BWTAQEgFeKCUtK4,17971
329
329
  truss/truss_handle/patch/constants.py,sha256=pCEi5Pwi8Rnqthrr3VEsWL9EP1P1VV1T8DEYuitHLmc,139
330
330
  truss/truss_handle/patch/custom_types.py,sha256=QklzhgLD_PpvNvNYQCvujAd16eYEaDGfLA1scxk6zsA,3481
331
331
  truss/truss_handle/patch/dir_signature.py,sha256=UCdZCzXkI-l-ae0I0pdmB2bavB9qzhhOKYXyLnDFQZY,921
@@ -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.2rc504.dist-info/METADATA,sha256=kmeypQ9CmBsHrPE-nB0Xw7DYTGCirhsQIW6wbP9yiSU,6674
372
- truss-0.11.2rc504.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
- truss-0.11.2rc504.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
374
- truss-0.11.2rc504.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
375
- truss-0.11.2rc504.dist-info/RECORD,,
371
+ truss-0.11.3.dist-info/METADATA,sha256=tzcaX0tJ3oM9TfBC0FGlbh3No2PfcyBO4Yfg3IPMkKE,6669
372
+ truss-0.11.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
+ truss-0.11.3.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
374
+ truss-0.11.3.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
375
+ truss-0.11.3.dist-info/RECORD,,