truss 0.11.6rc1__py3-none-any.whl → 0.11.6rc101__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/cli/train/core.py CHANGED
@@ -458,6 +458,7 @@ def _get_all_train_init_example_options(
458
458
  def _get_train_init_example_info(
459
459
  repo_id: str = "ml-cookbook",
460
460
  examples_subdir: str = "examples",
461
+ training_subdir: str = "training",
461
462
  example_name: Optional[str] = None,
462
463
  token: Optional[str] = None,
463
464
  ) -> list[Dict[str, str]]:
@@ -471,6 +472,7 @@ def _get_train_init_example_info(
471
472
 
472
473
  url = f"https://api.github.com/repos/basetenlabs/{repo_id}/contents/{examples_subdir}/{example_name}"
473
474
 
475
+ console.print(f"Attempting to retrieve example info from: {url}")
474
476
  try:
475
477
  response = requests.get(url, headers=headers)
476
478
  response.raise_for_status()
@@ -478,6 +480,8 @@ def _get_train_init_example_info(
478
480
  items = response.json()
479
481
  if not isinstance(items, list):
480
482
  items = [items]
483
+ # return only training subdirectory info for example
484
+ items = [item for item in items if item["name"] == training_subdir]
481
485
  return items
482
486
 
483
487
  except requests.exceptions.HTTPError as e:
@@ -785,9 +785,6 @@ class ServingImageBuilder(ImageBuilder):
785
785
  )
786
786
 
787
787
  non_root_user = os.getenv("BT_USE_NON_ROOT_USER", False)
788
- enable_model_container_admin_commands = os.getenv(
789
- "BT_ENABLE_MODEL_CONTAINER_ADMIN_CMDS"
790
- )
791
788
  dockerfile_contents = dockerfile_template.render(
792
789
  should_install_server_requirements=should_install_server_requirements,
793
790
  base_image_name_and_tag=base_image_name_and_tag,
@@ -822,7 +819,6 @@ class ServingImageBuilder(ImageBuilder):
822
819
  use_local_src=config.use_local_src,
823
820
  passthrough_environment_variables=passthrough_environment_variables,
824
821
  non_root_user=non_root_user,
825
- enable_model_container_admin_commands=enable_model_container_admin_commands,
826
822
  **FILENAME_CONSTANTS_MAP,
827
823
  )
828
824
  # Consolidate repeated empty lines to single empty lines.
@@ -1,4 +1,5 @@
1
1
  ARG PYVERSION={{ config.python_version }}
2
+ ARG HOME
2
3
  FROM {{ base_image_name_and_tag }} AS truss_server
3
4
 
4
5
  {%- set python_exec_path = config.base_image.python_executable_path or '$(which python3)' %}
@@ -13,9 +14,14 @@ ENV PYTHON_EXECUTABLE="{{ python_executable }}"
13
14
  {%- set app_user_uid = 60000 %}
14
15
  {%- set control_server_dir = "/control" %}
15
16
  {%- set default_owner = "root:root" %}
17
+ {%- if non_root_user %}
16
18
  {# The non-root user's home directory. #}
17
19
  {# uv will use $HOME to install packages. #}
18
- ENV HOME=/home/{{ app_username }}
20
+ ENV HOME=${HOME:-/home/{{ app_username }}}
21
+ {%- else %}
22
+ {# This is the default, but we use this variable later so ... setting it here too.#}
23
+ ENV HOME=${HOME:-/root}
24
+ {%- endif %} {#- endif non_root_user #}
19
25
  {# Directory containing inference server code. #}
20
26
  ENV APP_HOME=/{{ app_username }}
21
27
  RUN mkdir -p ${APP_HOME} {{ control_server_dir }}
@@ -26,16 +32,6 @@ RUN useradd -u {{ app_user_uid }} -ms /bin/bash {{ app_username }}
26
32
  {#- at the very beginning, set non-interactive mode for apt #}
27
33
  ENV DEBIAN_FRONTEND=noninteractive
28
34
 
29
- {# If non-root user is enabled and model container admin commands are enabled, install sudo #}
30
- {# to allow the non-root user to install packages. #}
31
- {%- if non_root_user and enable_model_container_admin_commands %}
32
- RUN apt update && apt install -y sudo
33
- {%- set allowed_admin_commands = ["/usr/bin/apt install *", "/usr/bin/apt update"] %}
34
- RUN echo "Defaults:{{ app_username }} passwd_tries=0\n{{ app_username }} ALL=(root) NOPASSWD: {{ allowed_admin_commands | join(", ") }}" > /etc/sudoers.d/app-packages
35
- RUN chmod 0440 /etc/sudoers.d/app-packages
36
- {#- optional but good practice: check if the sudoers file is valid #}
37
- RUN visudo -c
38
- {%- endif %} {#- endif non_root_user and enable_model_container_admin_commands #}
39
35
 
40
36
  {%- set UV_VERSION = "0.7.19" %}
41
37
  {#
@@ -182,6 +182,12 @@ class BasetenEndpoints:
182
182
  """
183
183
  Executes a predictive endpoint
184
184
  """
185
+ request_id = request.headers.get("x-baseten-request-id")
186
+
187
+ logging.debug(
188
+ f"Request received - {request.method} {method.__name__} "
189
+ f", Request ID: {request_id}"
190
+ )
185
191
  self.check_healthy()
186
192
  trace_ctx = otel_propagate.extract(request.headers) or None
187
193
  # This is the top-level span in the truss-server, so we set the context here.
@@ -464,6 +470,8 @@ class TrussServer:
464
470
  if self._config["runtime"].get("enable_debug_logs", False)
465
471
  else "INFO"
466
472
  )
473
+
474
+ logging.info(f"Starting truss server with log level {log_level}")
467
475
  extra_kwargs = {}
468
476
  # We don't pass these if not set, to not override the default.
469
477
  if (
@@ -64,12 +64,7 @@ RUN {% for secret,path in config.build.secret_to_path_mapping.items() %} --mount
64
64
 
65
65
  {# Copy data before code for better caching #}
66
66
  {%- if data_dir_exists %}
67
- {# If non-root user is enabled, copy data to the app home directory with the correct ownership #}
68
- {%- if non_root_user %}
69
67
  COPY --chown={{ default_owner }} ./{{ config.data_dir }} ${APP_HOME}/data
70
- {%- else %}
71
- COPY ./{{ config.data_dir }} ${APP_HOME}/data
72
- {%- endif %} {#- endif non_root_user #}
73
68
  {%- endif %} {#- endif data_dir_exists #}
74
69
 
75
70
  {%- if model_cache_v2 %}
@@ -160,7 +160,7 @@ class TestGetTrainInitExampleInfo:
160
160
  """Test cases for _get_train_init_example_info function"""
161
161
 
162
162
  @patch("requests.get")
163
- def test_successful_request_without_token(self, mock_get):
163
+ def test_request_without_token(self, mock_get):
164
164
  """Test successful API call without authentication token"""
165
165
  # Arrange
166
166
  mock_response = Mock()
@@ -179,12 +179,32 @@ class TestGetTrainInitExampleInfo:
179
179
  "https://api.github.com/repos/basetenlabs/ml-cookbook/contents/examples/test_example",
180
180
  headers={},
181
181
  )
182
- assert len(result) == 2
183
- assert result[0]["name"] == "file1.py"
184
- assert result[1]["name"] == "file2.py"
182
+ assert len(result) == 0 # No training subdir in mock response
185
183
 
186
184
  @patch("requests.get")
187
- def test_successful_request_with_token(self, mock_get):
185
+ def test_successful_request_without_token(self, mock_get):
186
+ """Test successful API call without authentication token"""
187
+ # Arrange
188
+ mock_response = Mock()
189
+ mock_response.json.return_value = [
190
+ {"name": "training", "path": "git_path_1", "type": "dir"},
191
+ {"name": "file2.py", "type": "file"},
192
+ ]
193
+ mock_response.raise_for_status.return_value = None
194
+ mock_get.return_value = mock_response
195
+
196
+ # Act
197
+ result = _get_train_init_example_info(example_name="test_example")
198
+
199
+ # Assert
200
+ mock_get.assert_called_once_with(
201
+ "https://api.github.com/repos/basetenlabs/ml-cookbook/contents/examples/test_example",
202
+ headers={},
203
+ )
204
+ assert len(result) == 1 # One training subdir in mock response
205
+
206
+ @patch("requests.get")
207
+ def test_request_with_token(self, mock_get):
188
208
  """Test successful API call with authentication token"""
189
209
  # Arrange
190
210
  mock_response = Mock()
@@ -202,7 +222,7 @@ class TestGetTrainInitExampleInfo:
202
222
  "https://api.github.com/repos/basetenlabs/ml-cookbook/contents/examples/test_example",
203
223
  headers={"Authorization": "token test_token"},
204
224
  )
205
- assert len(result) == 1
225
+ assert len(result) == 0 # No training subdir in mock response
206
226
 
207
227
  @patch("requests.get")
208
228
  def test_custom_repo_and_subdir(self, mock_get):
@@ -226,22 +246,6 @@ class TestGetTrainInitExampleInfo:
226
246
  headers={},
227
247
  )
228
248
 
229
- @patch("requests.get")
230
- def test_single_item_response(self, mock_get):
231
- """Test when API returns a single item instead of a list"""
232
- # Arrange
233
- mock_response = Mock()
234
- mock_response.json.return_value = {"name": "single_file.py", "type": "file"}
235
- mock_response.raise_for_status.return_value = None
236
- mock_get.return_value = mock_response
237
-
238
- # Act
239
- result = _get_train_init_example_info(example_name="test_example")
240
-
241
- # Assert
242
- assert len(result) == 1
243
- assert result[0]["name"] == "single_file.py"
244
-
245
249
  @patch("requests.get")
246
250
  @patch("click.echo")
247
251
  def test_404_error_returns_empty_list(self, mock_echo, mock_get):
@@ -1,7 +1,8 @@
1
1
  ARG PYVERSION=py39
2
+ ARG HOME
2
3
  FROM baseten/truss-server-base:3.9-v0.4.3 AS truss_server
3
4
  ENV PYTHON_EXECUTABLE="/usr/local/bin/python3"
4
- ENV HOME=/home/app
5
+ ENV HOME=${HOME:-/root}
5
6
  ENV APP_HOME=/app
6
7
  RUN mkdir -p ${APP_HOME} /control
7
8
  RUN useradd -u 60000 -ms /bin/bash app
@@ -30,7 +31,7 @@ RUN UV_HTTP_TIMEOUT=${UV_HTTP_TIMEOUT:-300} uv pip install --index-strategy unsa
30
31
  COPY --chown= ./requirements.txt requirements.txt
31
32
  RUN UV_HTTP_TIMEOUT=${UV_HTTP_TIMEOUT:-300} uv pip install --index-strategy unsafe-best-match --python /usr/local/bin/python3 -r requirements.txt --no-cache-dir
32
33
  WORKDIR $APP_HOME
33
- COPY ./data ${APP_HOME}/data
34
+ COPY --chown= ./data ${APP_HOME}/data
34
35
  COPY --chown= ./server ${APP_HOME}
35
36
  COPY --chown= ./config.yaml ${APP_HOME}/config.yaml
36
37
  COPY --chown= ./model ${APP_HOME}/model
@@ -990,8 +990,8 @@ def test_is_healthy_returns_503_on_load_failure():
990
990
  # when the model goes down, this will throw an exception
991
991
  break
992
992
  diff = container.diff()
993
- # the crash file is written to the app user's home directory
994
- crash_file_path = "/home/app/inference_server_crashed.txt"
993
+ # the crash file is written to the user's home directory
994
+ crash_file_path = "/root/inference_server_crashed.txt"
995
995
  assert crash_file_path in diff
996
996
  assert diff[crash_file_path] == "A"
997
997
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: truss
3
- Version: 0.11.6rc1
3
+ Version: 0.11.6rc101
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
@@ -17,7 +17,7 @@ truss/cli/logs/model_log_watcher.py,sha256=NACcP-wkcaroYa2Cb9BZC7Yr0554WZa_FSM2L
17
17
  truss/cli/logs/training_log_watcher.py,sha256=r6HRqrLnz-PiKTUXiDYYxg4ZnP8vYcXlEX1YmgHhzlo,1173
18
18
  truss/cli/logs/utils.py,sha256=z-U_FG4BUzdZLbE3BnXb4DZQ0zt3LSZ3PiQpLaDuc3o,1031
19
19
  truss/cli/train/common.py,sha256=xTR41U5FeSndXfNBBHF9wF5XwZH1sOIVFlv-XHjsKIU,1547
20
- truss/cli/train/core.py,sha256=4vPnREmaJh8R_rlwR0_H5NRaXhdyY2g07w11uab-9qw,25908
20
+ truss/cli/train/core.py,sha256=Xyl0SgCXIyvoQJLnkIvX6R2gWUVyeDiFHLB1caWJZjs,26154
21
21
  truss/cli/train/deploy_from_checkpoint_config.yml,sha256=mktaVrfhN8Kjx1UveC4xr-gTW-kjwbHvq6bx_LpO-Wg,371
22
22
  truss/cli/train/deploy_from_checkpoint_config_whisper.yml,sha256=6GbOorYC8ml0UyOUvuBpFO_fuYtYE646JqsalR-D4oY,406
23
23
  truss/cli/train/metrics_watcher.py,sha256=smz-zrEsBj_-wJHI0pAZ-EAPrvfCWzq1eQjGiFNM-Mk,12755
@@ -36,7 +36,7 @@ truss/contexts/docker_build_setup.py,sha256=cF4ExZgtYvrWxvyCAaUZUvV_DB_7__MqVomU
36
36
  truss/contexts/truss_context.py,sha256=uS6L-ACHxNk0BsJwESOHh1lA0OGGw0pb33aFKGsASj4,436
37
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
- truss/contexts/image_builder/serving_image_builder.py,sha256=ywPV6qsItc7FgxAvgVq1ktQdtFAAQ6tyy5nzwO6pBaA,33647
39
+ truss/contexts/image_builder/serving_image_builder.py,sha256=n6MTHMZsANSTGXPfkKDJ1Ch4fEc6HIjbOXA_1B9zt9Q,33438
40
40
  truss/contexts/image_builder/util.py,sha256=y2-CjUKv0XV-0w2sr1fUCflysDJLsoU4oPp6tvvoFnk,1203
41
41
  truss/contexts/local_loader/docker_build_emulator.py,sha256=3n0eIlJblz_sldh4AN8AHQDyfjQGdYyld5FabBdd9wE,3563
42
42
  truss/contexts/local_loader/dockerfile_parser.py,sha256=GoRJ0Af_3ILyLhjovK5lrCGn1rMxz6W3l681ro17ZzI,1344
@@ -66,12 +66,12 @@ truss/remote/baseten/utils/time.py,sha256=Ry9GMjYnbIGYVIGwtmv4V8ljWjvdcaCf5NOQzl
66
66
  truss/remote/baseten/utils/transfer.py,sha256=d3VptuQb6M1nyS6kz0BAfeOYDLkMKUjatJXpY-mp-As,1548
67
67
  truss/templates/README.md.jinja,sha256=N7CJdyldZuJamj5jLh47le0hFBdu9irVsTBqoxhPNPQ,2476
68
68
  truss/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
- truss/templates/base.Dockerfile.jinja,sha256=irked6fWbiZ4tMkhR3zi3njpaaI9bANVqq7PTjp_Tmc,5610
69
+ truss/templates/base.Dockerfile.jinja,sha256=93UgFjjDzmRILsWjvQBMcWuHY2j-HlP8pkCLmvZz_0o,5098
70
70
  truss/templates/cache.Dockerfile.jinja,sha256=1qZqDo1phrcqi-Vwol-VafYJkADsBbQWU6huQ-_1x00,1146
71
71
  truss/templates/cache_requirements.txt,sha256=xoPoJ-OVnf1z6oq_RVM3vCr3ionByyqMLj7wGs61nUs,87
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
- truss/templates/server.Dockerfile.jinja,sha256=f81E1X621fGJhGyCQzRgZAQW4qDkiZXnJOH4sUzBAEo,7291
74
+ truss/templates/server.Dockerfile.jinja,sha256=CUYnF_hgxPGq2re7__0UPWlwzOHMoFkxp6NVKi3U16s,7071
75
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
@@ -97,7 +97,7 @@ truss/templates/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
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
99
  truss/templates/server/requirements.txt,sha256=lhJYYExWE1IdBlYYFW-kmfmuKZTWyIg1TNyoWIIuuDg,780
100
- truss/templates/server/truss_server.py,sha256=noXfGJMsKIhgF4oI_8LC1UHkcx8Vg8nGSITZJ_bkRFQ,19598
100
+ truss/templates/server/truss_server.py,sha256=e19dGJnuO1oro6TpTZu2z91STOLHaid0aZgQyhUok1s,19884
101
101
  truss/templates/server/common/__init__.py,sha256=qHIqr68L5Tn4mV6S-PbORpcuJ4jmtBR8aCuRTIWDvNo,85
102
102
  truss/templates/server/common/errors.py,sha256=My0P6-Y7imVTICIhazHT0vlSu3XJDH7As06OyVzu4Do,8589
103
103
  truss/templates/server/common/patches.py,sha256=uEOzvDnXsHOkTSa8zygGYuR4GHhrFNVHNQc5peJcwvo,1393
@@ -134,7 +134,7 @@ truss/tests/test_context_builder_image.py,sha256=fVZNJSzZNiWa7Dr1X_VhhMJtyJ5HzsL
134
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
- truss/tests/test_model_inference.py,sha256=9QfPMa1kjxvKCWg5XKocjwcpfDkKB7pWd8bn4hIkshk,76213
137
+ truss/tests/test_model_inference.py,sha256=Q8mgNDNbwAUi7AQTgmyK-QrYuksuARDczYndTh56fKk,76205
138
138
  truss/tests/test_model_schema.py,sha256=Bw28CZ4D0JQOkYdBQJZvgryeW0TRn7Axketp5kvZ_t4,14219
139
139
  truss/tests/test_testing_utilities_for_other_tests.py,sha256=YqIKflnd_BUMYaDBSkX76RWiWGWM_UlC2IoT4NngMqE,3048
140
140
  truss/tests/test_truss_gatherer.py,sha256=bn288OEkC49YY0mhly4cAl410ktZPfElNdWwZy82WfA,1261
@@ -144,7 +144,7 @@ truss/tests/cli/test_cli.py,sha256=yfbVS5u1hnAmmA8mJ539vj3lhH-JVGUvC4Q_Mbort44,7
144
144
  truss/tests/cli/train/test_cache_view.py,sha256=aVRCh3atRpFbJqyYgq7N-vAW0DiKMftQ7ajUqO2ClOg,22606
145
145
  truss/tests/cli/train/test_deploy_checkpoints.py,sha256=lDk88uAUPYatJ30JKVVtJDdXv_zWNk1nxXFyUH6IVGw,44800
146
146
  truss/tests/cli/train/test_train_cli_core.py,sha256=vzYfxKdwoa3NaFMrVZbSg5qOoLXivMvZXN1ClQirGTQ,16148
147
- truss/tests/cli/train/test_train_init.py,sha256=pv8BfyLlVG0QtdowTziITjKa_OE1KigatmAGx8XSZrM,17238
147
+ truss/tests/cli/train/test_train_init.py,sha256=SRAZvvD5-PWYlpHHek2MftYTA4I3ZHi7gniHl2fYV98,17464
148
148
  truss/tests/cli/train/resources/test_deploy_from_checkpoint_config.yml,sha256=GF7r9l0KaeXiUYCPSBpeMPd2QG6PeWWyI12NdbqLOgc,1930
149
149
  truss/tests/contexts/image_builder/test_serving_image_builder.py,sha256=16niCXZnuxFHXYQw2vPFZ8svSZafkH5DT0Gx3Z9Xdd8,22377
150
150
  truss/tests/contexts/local_loader/test_load_local.py,sha256=D1qMH2IpYA2j5009v50QMgUnKdeOsX15ndkwXe10a4E,801
@@ -184,7 +184,7 @@ truss/tests/test_data/pima-indians-diabetes.csv,sha256=BvW3ws17ymhv2k-S6rX2Hn_2Q
184
184
  truss/tests/test_data/readme_int_example.md,sha256=fuHvpLtdkJy1f4NAR_djotVBdzusHYNXc-Fwh588XAE,1586
185
185
  truss/tests/test_data/readme_no_example.md,sha256=T2CzFMRvICXeX3_5XbFoqhHchcHGot-xM7izx34B3aQ,1607
186
186
  truss/tests/test_data/readme_str_example.md,sha256=fP4pvMqgLdIapaOf_BgRiV0H7pw4so0RNxrlq5lbROE,1726
187
- truss/tests/test_data/server.Dockerfile,sha256=beeeOlOoEWGe1nP5IZYKmDeMJc7KRuN5PdOj7rSEiKE,1962
187
+ truss/tests/test_data/server.Dockerfile,sha256=64M9aAB-Ar5Yl0k9r5WFxVb-4iUShm_OR1w9pKJfDgg,1985
188
188
  truss/tests/test_data/annotated_types_truss/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
189
189
  truss/tests/test_data/annotated_types_truss/config.yaml,sha256=B-ZyyjLLqtxGfXj2tkH68Hy7NOMB_coYvoWyWom61g0,147
190
190
  truss/tests/test_data/annotated_types_truss/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -363,13 +363,13 @@ truss_chains/remote_chainlet/model_skeleton.py,sha256=8ZReLOO2MLcdg7bNZ61C-6j-e6
363
363
  truss_chains/remote_chainlet/stub.py,sha256=Y2gDUzMY9WRaQNHIz-o4dfLUfFyYV9dUhIRQcfgrY8g,17209
364
364
  truss_chains/remote_chainlet/utils.py,sha256=Zn3GZRvK8f65WUa-qa-8uPFZ2pD7ukRFxbLOvT-BL0Q,24063
365
365
  truss_train/__init__.py,sha256=A3MzRPMInZfmzLvPpZI7gdKgshAVCw6bwhU-6JYU2zs,939
366
- truss_train/definitions.py,sha256=3wVxkxMtHlcc-hb2umtj74FjA9TjenfiPTX7EQSh6zw,8245
366
+ truss_train/definitions.py,sha256=TGoeG86aG76wt3h3giufg1rfm9K0W8y9bDJSITe76Aw,8209
367
367
  truss_train/deployment.py,sha256=lWWANSuzBWu2M4oK4qD7n-oVR1JKdmw2Pn5BJQHg-Ck,3074
368
368
  truss_train/loader.py,sha256=0o66EjBaHc2YY4syxxHVR4ordJWs13lNXnKjKq2wq0U,1630
369
369
  truss_train/public_api.py,sha256=9N_NstiUlmBuLUwH_fNG_1x7OhGCytZLNvqKXBlStrM,1220
370
- truss_train/restore_from_checkpoint.py,sha256=KmJuTUVpvtvlkEClcmllxAF2TKgbp-FuzfblfGh06XA,1239
371
- truss-0.11.6rc1.dist-info/METADATA,sha256=0HhYjVZUCL_-tTTPOf5I4ihkHdH2apkHemb9f2exVD0,6680
372
- truss-0.11.6rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
- truss-0.11.6rc1.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
374
- truss-0.11.6rc1.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
375
- truss-0.11.6rc1.dist-info/RECORD,,
370
+ truss_train/restore_from_checkpoint.py,sha256=8hdPm-WSgkt74HDPjvCjZMBpvA9MwtoYsxVjOoa7BaM,1176
371
+ truss-0.11.6rc101.dist-info/METADATA,sha256=l0391m_ptDQh-8Z7va3wwkZafcK6-h0zQrSmuZo0RB4,6682
372
+ truss-0.11.6rc101.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
+ truss-0.11.6rc101.dist-info/entry_points.txt,sha256=-MwKfHHQHQ6j0HqIgvxrz3CehCmczDLTD-OsRHnjjuU,130
374
+ truss-0.11.6rc101.dist-info/licenses/LICENSE,sha256=FTqGzu85i-uw1Gi8E_o0oD60bH9yQ_XIGtZbA1QUYiw,1064
375
+ truss-0.11.6rc101.dist-info/RECORD,,
@@ -3,7 +3,7 @@ from abc import ABC
3
3
  from typing import Dict, List, Literal, Optional, Union
4
4
 
5
5
  import pydantic
6
- from pydantic import field_validator, model_validator
6
+ from pydantic import ValidationError, field_validator, model_validator
7
7
 
8
8
  from truss.base import constants, custom_types, truss_config
9
9
 
@@ -68,8 +68,7 @@ class _BasetenLatestCheckpoint(_CheckpointBase):
68
68
 
69
69
  class _BasetenNamedCheckpoint(_CheckpointBase):
70
70
  checkpoint_name: str
71
- job_id: Optional[str]
72
- project_name: Optional[str]
71
+ job_id: str
73
72
  typ: Literal["baseten_named_checkpoint"] = "baseten_named_checkpoint"
74
73
 
75
74
 
@@ -78,18 +77,15 @@ class BasetenCheckpoint:
78
77
  def from_latest_checkpoint(
79
78
  project_name: Optional[str] = None, job_id: Optional[str] = None
80
79
  ) -> _BasetenLatestCheckpoint:
80
+ if not job_id and not project_name:
81
+ raise ValidationError("job_id or project_name is required")
81
82
  return _BasetenLatestCheckpoint(project_name=project_name, job_id=job_id)
82
83
 
83
84
  @classmethod
84
85
  def from_named_checkpoint(
85
- cls,
86
- checkpoint_name: str,
87
- project_name: Optional[str] = None,
88
- job_id: Optional[str] = None,
86
+ cls, checkpoint_name: str, job_id: str
89
87
  ) -> _BasetenNamedCheckpoint:
90
- return _BasetenNamedCheckpoint(
91
- checkpoint_name=checkpoint_name, project_name=project_name, job_id=job_id
92
- )
88
+ return _BasetenNamedCheckpoint(checkpoint_name=checkpoint_name, job_id=job_id)
93
89
 
94
90
 
95
91
  class LoadCheckpointConfig(custom_types.SafeModelNoExtra):
@@ -18,9 +18,7 @@ load_most_recent_checkpoint = BasetenCheckpoint.from_latest_checkpoint(
18
18
  )
19
19
 
20
20
  load_from_named_checkpoint = BasetenCheckpoint.from_named_checkpoint(
21
- checkpoint_name="checkpoint-24",
22
- project_name="first-project", # Optional
23
- job_id="lqz4pw4", # Optional
21
+ checkpoint_name="checkpoint-24", job_id="lqz4pw4"
24
22
  )
25
23
 
26
24
  load_checkpoint_config = LoadCheckpointConfig(