truefoundry 0.4.7rc0__py3-none-any.whl → 0.4.7rc2__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 truefoundry might be problematic. Click here for more details.

@@ -111,6 +111,7 @@ def convert_deployment_config_to_python(workspace_fqn: str, application_spec: di
111
111
  application_type = application_obj.type
112
112
  if (
113
113
  hasattr(application_obj, "image")
114
+ and hasattr(application_obj.image, "type")
114
115
  and application_obj.image.type == "build"
115
116
  and application_obj.image.build_source.type == "remote"
116
117
  ):
@@ -1,4 +1,6 @@
1
1
  # file: client.py
2
+ import io
3
+ import os
2
4
  from enum import Enum
3
5
  from typing import Any, Dict, List, Optional, Union
4
6
  from urllib.parse import urlencode, urljoin
@@ -125,7 +127,12 @@ class SignedURLClient:
125
127
  )
126
128
 
127
129
  @log_time(prefix=LOG_PREFIX)
128
- def _upload_data(self, signed_url: str, data: Any) -> None:
130
+ def _upload_data(
131
+ self,
132
+ signed_url: str,
133
+ data: Union[bytes, io.BufferedReader],
134
+ headers: Optional[Dict] = None,
135
+ ) -> None:
129
136
  """
130
137
  Upload data to the specified storage path using a signed URL.
131
138
 
@@ -133,10 +140,15 @@ class SignedURLClient:
133
140
  signed_url: str: The signed URL to upload the data to.
134
141
  data: Bytes or IO: The data to upload.
135
142
  """
143
+ if isinstance(data, io.BufferedReader):
144
+ if os.fstat(data.fileno()).st_size == 0:
145
+ data = b""
136
146
  try:
147
+ headers = headers or {}
148
+ headers["Content-Type"] = "application/octet-stream"
137
149
  response = self.session.put(
138
150
  url=signed_url,
139
- headers={"Content-Type": "application/octet-stream"},
151
+ headers=headers,
140
152
  data=data,
141
153
  timeout=REQUEST_TIMEOUT,
142
154
  )
@@ -153,7 +165,11 @@ class SignedURLClient:
153
165
  headers=self.signed_url_server_headers,
154
166
  )
155
167
  pre_signed_object_dto = SignedURLAPIResponseDto.parse_obj(signed_object)
156
- self._upload_data(pre_signed_object_dto.signed_url, data)
168
+ self._upload_data(
169
+ signed_url=pre_signed_object_dto.signed_url,
170
+ data=data,
171
+ headers=pre_signed_object_dto.headers,
172
+ )
157
173
  return storage_uri
158
174
 
159
175
  @log_time(prefix=LOG_PREFIX)
@@ -167,19 +183,30 @@ class SignedURLClient:
167
183
  )
168
184
  pre_signed_object_dto = SignedURLAPIResponseDto.parse_obj(response)
169
185
  with open(file_path, "rb") as file:
170
- self._upload_data(pre_signed_object_dto.signed_url, file)
186
+ self._upload_data(
187
+ signed_url=pre_signed_object_dto.signed_url,
188
+ data=file,
189
+ headers=pre_signed_object_dto.headers,
190
+ )
171
191
  return storage_uri
172
192
 
173
193
  @log_time(prefix=LOG_PREFIX)
174
194
  def _download_file(
175
- self, signed_url: str, local_path: Optional[str] = None
195
+ self,
196
+ signed_url: str,
197
+ local_path: Optional[str] = None,
198
+ headers: Optional[Dict] = None,
176
199
  ) -> Optional[bytes]:
177
200
  """Common method to download a file using a signed URL."""
178
201
  try:
202
+ if headers is None:
203
+ headers = {"Content-Type": "application/octet-stream"}
204
+ else:
205
+ headers["Content-Type"] = "application/octet-stream"
179
206
  response = self.session.get(
180
207
  signed_url,
181
208
  stream=True,
182
- headers={"Content-Type": "application/octet-stream"},
209
+ headers=headers,
183
210
  timeout=REQUEST_TIMEOUT,
184
211
  )
185
212
  response.raise_for_status()
@@ -202,7 +229,11 @@ class SignedURLClient:
202
229
  headers=self.signed_url_server_headers,
203
230
  )
204
231
  presigned_object = SignedURLAPIResponseDto.parse_obj(response)
205
- self._download_file(presigned_object.signed_url, local_path)
232
+ self._download_file(
233
+ signed_url=presigned_object.signed_url,
234
+ local_path=local_path,
235
+ headers=presigned_object.headers,
236
+ )
206
237
  return local_path
207
238
 
208
239
  @log_time(prefix=LOG_PREFIX)
@@ -214,7 +245,9 @@ class SignedURLClient:
214
245
  headers=self.signed_url_server_headers,
215
246
  )
216
247
  presigned_object = SignedURLAPIResponseDto.parse_obj(response)
217
- return self._download_file(presigned_object.signed_url)
248
+ return self._download_file(
249
+ signed_url=presigned_object.signed_url, headers=presigned_object.headers
250
+ )
218
251
 
219
252
  @log_time(prefix=LOG_PREFIX)
220
253
  def exists(self, uri: str) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: truefoundry
3
- Version: 0.4.7rc0
3
+ Version: 0.4.7rc2
4
4
  Summary: Truefoundry CLI
5
5
  Author: Abhishek Choudhary
6
6
  Author-email: abhishek@truefoundry.com
@@ -107,7 +107,7 @@ truefoundry/deploy/lib/model/entity.py,sha256=fq8hvdJQgQn4uZqxpKrzmaoJhQG53_EbDo
107
107
  truefoundry/deploy/lib/session.py,sha256=Vg6rCA315T0yS0xG4ayJ84Ia_9ZfibH8utOSwPBMAmw,4953
108
108
  truefoundry/deploy/lib/util.py,sha256=3TapV7yczkheC1MMMfmJDGGzTl2l6e4jCYd_Rr5aoQ8,1330
109
109
  truefoundry/deploy/lib/win32.py,sha256=1RcvPTdlOAJ48rt8rCbE2Ufha2ztRqBAE9dueNXArrY,5009
110
- truefoundry/deploy/python_deploy_codegen.py,sha256=z9VSETb3Lrqn7sUD75EksbmA1vRiEl0LNnz9PTqF8ZM,6462
110
+ truefoundry/deploy/python_deploy_codegen.py,sha256=qJHH1BJQII9e6PhkcRFYiE_3De7_VMMm8nM4AX5Eq1o,6513
111
111
  truefoundry/deploy/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
112
112
  truefoundry/deploy/v2/lib/__init__.py,sha256=WEiVMZXOVljzEE3tpGJil14liIn_PCDoACJ6b3tZ6sI,188
113
113
  truefoundry/deploy/v2/lib/deploy.py,sha256=HIcY3SzQ5lWl7avuuKi3J0Z-PBES6Sf4hgMK-m6_53U,11990
@@ -351,11 +351,11 @@ truefoundry/workflow/map_task.py,sha256=2m3qGXQ90k9LdS45q8dqCCECc3qr8t2m_LMCVd1m
351
351
  truefoundry/workflow/python_task.py,sha256=SRXRLC4vdBqGjhkwuaY39LEWN6iPCpJAuW17URRdWTY,1128
352
352
  truefoundry/workflow/remote_filesystem/__init__.py,sha256=LQ95ViEjJ7Ts4JcCGOxMPs7NZmQdZ4bTiq6qXtsjUhE,206
353
353
  truefoundry/workflow/remote_filesystem/logger.py,sha256=em2l7D6sw7xTLDP0kQSLpgfRRCLpN14Qw85TN7ujQcE,1022
354
- truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=ln3zx72jMElZQIVbPRHVd0OfmsLnDbnrntfJ6g1WdfE,10174
354
+ truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=5mBCIc-ON7VSTzdyczeADgqSX5oJgso5gq2yT2AQqTY,11085
355
355
  truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=Hf6Dk6Fu6P7DqsK5ULgraf9DStjgigf-kjaRAMBW-RU,8680
356
356
  truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
357
357
  truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
358
- truefoundry-0.4.7rc0.dist-info/METADATA,sha256=6HYqMZKEbtVgTpk3Uowj4H2IGGPBMGWjaZA3mZkNy7g,3101
359
- truefoundry-0.4.7rc0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
360
- truefoundry-0.4.7rc0.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
361
- truefoundry-0.4.7rc0.dist-info/RECORD,,
358
+ truefoundry-0.4.7rc2.dist-info/METADATA,sha256=ge_sjcw5L2HD-5nIHHFCMtbg5wEdOfNruG0ZKAIQUis,3101
359
+ truefoundry-0.4.7rc2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
360
+ truefoundry-0.4.7rc2.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
361
+ truefoundry-0.4.7rc2.dist-info/RECORD,,