truefoundry 0.4.4rc8__py3-none-any.whl → 0.4.4rc10__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.

Files changed (47) hide show
  1. truefoundry/common/constants.py +7 -12
  2. truefoundry/common/tfy_signed_url_client.py +84 -86
  3. truefoundry/common/tfy_signed_url_fs.py +13 -7
  4. truefoundry/ml/artifact/truefoundry_artifact_repo.py +433 -415
  5. truefoundry/ml/autogen/client/__init__.py +24 -3
  6. truefoundry/ml/autogen/client/api/experiments_api.py +0 -137
  7. truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +2 -0
  8. truefoundry/ml/autogen/client/models/__init__.py +24 -3
  9. truefoundry/ml/autogen/client/models/artifact_dto.py +9 -0
  10. truefoundry/ml/autogen/client/models/artifact_version_dto.py +26 -0
  11. truefoundry/ml/autogen/client/models/artifact_version_serialization_format.py +34 -0
  12. truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +8 -2
  13. truefoundry/ml/autogen/client/models/create_run_request_dto.py +1 -10
  14. truefoundry/ml/autogen/client/models/dataset_dto.py +9 -0
  15. truefoundry/ml/autogen/client/models/experiment_dto.py +14 -3
  16. truefoundry/ml/autogen/client/models/external_model_source.py +79 -0
  17. truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +11 -0
  18. truefoundry/ml/autogen/client/models/framework.py +154 -0
  19. truefoundry/ml/autogen/client/models/library_name.py +35 -0
  20. truefoundry/ml/autogen/client/models/model_dto.py +9 -0
  21. truefoundry/ml/autogen/client/models/model_version_dto.py +26 -0
  22. truefoundry/ml/autogen/client/models/model_version_manifest.py +119 -0
  23. truefoundry/ml/autogen/client/models/run_info_dto.py +10 -1
  24. truefoundry/ml/autogen/client/models/source.py +177 -0
  25. truefoundry/ml/autogen/client/models/subject.py +79 -0
  26. truefoundry/ml/autogen/client/models/subject_type.py +34 -0
  27. truefoundry/ml/autogen/client/models/tensorflow_framework.py +74 -0
  28. truefoundry/ml/autogen/client/models/transformers_framework.py +90 -0
  29. truefoundry/ml/autogen/client/models/truefoundry_model_source.py +79 -0
  30. truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +11 -0
  31. truefoundry/ml/autogen/client/models/upload_model_source.py +74 -0
  32. truefoundry/ml/autogen/client_README.md +12 -2
  33. truefoundry/ml/autogen/entities/artifacts.py +236 -4
  34. truefoundry/ml/log_types/artifacts/artifact.py +10 -6
  35. truefoundry/ml/log_types/artifacts/dataset.py +13 -5
  36. truefoundry/ml/log_types/artifacts/general_artifact.py +3 -1
  37. truefoundry/ml/log_types/artifacts/model.py +18 -30
  38. truefoundry/ml/log_types/artifacts/utils.py +42 -25
  39. truefoundry/ml/log_types/image/image.py +2 -0
  40. truefoundry/ml/log_types/plot.py +2 -0
  41. truefoundry/ml/mlfoundry_api.py +0 -1
  42. truefoundry/workflow/__init__.py +8 -3
  43. {truefoundry-0.4.4rc8.dist-info → truefoundry-0.4.4rc10.dist-info}/METADATA +1 -1
  44. {truefoundry-0.4.4rc8.dist-info → truefoundry-0.4.4rc10.dist-info}/RECORD +46 -35
  45. truefoundry/ml/autogen/client/models/list_seed_experiments_response_dto.py +0 -81
  46. {truefoundry-0.4.4rc8.dist-info → truefoundry-0.4.4rc10.dist-info}/WHEEL +0 -0
  47. {truefoundry-0.4.4rc8.dist-info → truefoundry-0.4.4rc10.dist-info}/entry_points.txt +0 -0
@@ -78,7 +78,6 @@ Class | Method | HTTP request | Description
78
78
  *ExperimentsApi* | [**list_experiments_get**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#list_experiments_get) | **GET** /api/2.0/mlflow/experiments/list | List Experiments
79
79
  *ExperimentsApi* | [**put_privacy_type_put**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#put_privacy_type_put) | **PUT** /api/2.0/mlflow/experiments/privacy-type | Put Privacy Type
80
80
  *ExperimentsApi* | [**restore_experiment_post**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#restore_experiment_post) | **POST** /api/2.0/mlflow/experiments/restore | Restore Experiment
81
- *ExperimentsApi* | [**seed_list_experiment_get**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#seed_list_experiment_get) | **GET** /api/2.0/mlflow/experiments/seed/list | Seed List Experiment
82
81
  *ExperimentsApi* | [**set_experiment_tag_post**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#set_experiment_tag_post) | **POST** /api/2.0/mlflow/experiments/set-experiment-tag | Set Experiment Tag
83
82
  *ExperimentsApi* | [**update_experiment_post**](truefoundry/ml/autogen/client/docs/ExperimentsApi.md#update_experiment_post) | **POST** /api/2.0/mlflow/experiments/update | Update Experiment
84
83
  *HealthApi* | [**health_get**](truefoundry/ml/autogen/client/docs/HealthApi.md#health_get) | **GET** /health | Health
@@ -166,6 +165,7 @@ Class | Method | HTTP request | Description
166
165
  - [ArtifactType](truefoundry/ml/autogen/client/docs/ArtifactType.md)
167
166
  - [ArtifactVersionDto](truefoundry/ml/autogen/client/docs/ArtifactVersionDto.md)
168
167
  - [ArtifactVersionResponseDto](truefoundry/ml/autogen/client/docs/ArtifactVersionResponseDto.md)
168
+ - [ArtifactVersionSerializationFormat](truefoundry/ml/autogen/client/docs/ArtifactVersionSerializationFormat.md)
169
169
  - [ArtifactVersionStatus](truefoundry/ml/autogen/client/docs/ArtifactVersionStatus.md)
170
170
  - [AssistantMessage](truefoundry/ml/autogen/client/docs/AssistantMessage.md)
171
171
  - [AuthorizeUserForModelRequestDto](truefoundry/ml/autogen/client/docs/AuthorizeUserForModelRequestDto.md)
@@ -206,10 +206,12 @@ Class | Method | HTTP request | Description
206
206
  - [ExperimentIdRequestDto](truefoundry/ml/autogen/client/docs/ExperimentIdRequestDto.md)
207
207
  - [ExperimentResponseDto](truefoundry/ml/autogen/client/docs/ExperimentResponseDto.md)
208
208
  - [ExperimentTagDto](truefoundry/ml/autogen/client/docs/ExperimentTagDto.md)
209
+ - [ExternalModelSource](truefoundry/ml/autogen/client/docs/ExternalModelSource.md)
209
210
  - [FeatureDto](truefoundry/ml/autogen/client/docs/FeatureDto.md)
210
211
  - [FeatureValueType](truefoundry/ml/autogen/client/docs/FeatureValueType.md)
211
212
  - [FileInfoDto](truefoundry/ml/autogen/client/docs/FileInfoDto.md)
212
213
  - [FinalizeArtifactVersionRequestDto](truefoundry/ml/autogen/client/docs/FinalizeArtifactVersionRequestDto.md)
214
+ - [Framework](truefoundry/ml/autogen/client/docs/Framework.md)
213
215
  - [GetExperimentResponseDto](truefoundry/ml/autogen/client/docs/GetExperimentResponseDto.md)
214
216
  - [GetLatestRunLogResponseDto](truefoundry/ml/autogen/client/docs/GetLatestRunLogResponseDto.md)
215
217
  - [GetMetricHistoryResponse](truefoundry/ml/autogen/client/docs/GetMetricHistoryResponse.md)
@@ -227,6 +229,7 @@ Class | Method | HTTP request | Description
227
229
  - [ImageUrl](truefoundry/ml/autogen/client/docs/ImageUrl.md)
228
230
  - [InternalMetadata](truefoundry/ml/autogen/client/docs/InternalMetadata.md)
229
231
  - [LatestRunLogDto](truefoundry/ml/autogen/client/docs/LatestRunLogDto.md)
232
+ - [LibraryName](truefoundry/ml/autogen/client/docs/LibraryName.md)
230
233
  - [ListArtifactVersionsRequestDto](truefoundry/ml/autogen/client/docs/ListArtifactVersionsRequestDto.md)
231
234
  - [ListArtifactVersionsResponseDto](truefoundry/ml/autogen/client/docs/ListArtifactVersionsResponseDto.md)
232
235
  - [ListArtifactsRequestDto](truefoundry/ml/autogen/client/docs/ListArtifactsRequestDto.md)
@@ -248,7 +251,6 @@ Class | Method | HTTP request | Description
248
251
  - [ListModelsResponseDto](truefoundry/ml/autogen/client/docs/ListModelsResponseDto.md)
249
252
  - [ListRunArtifactsResponseDto](truefoundry/ml/autogen/client/docs/ListRunArtifactsResponseDto.md)
250
253
  - [ListRunLogsResponseDto](truefoundry/ml/autogen/client/docs/ListRunLogsResponseDto.md)
251
- - [ListSeedExperimentsResponseDto](truefoundry/ml/autogen/client/docs/ListSeedExperimentsResponseDto.md)
252
254
  - [LogBatchRequestDto](truefoundry/ml/autogen/client/docs/LogBatchRequestDto.md)
253
255
  - [LogMetricRequestDto](truefoundry/ml/autogen/client/docs/LogMetricRequestDto.md)
254
256
  - [LogParamRequestDto](truefoundry/ml/autogen/client/docs/LogParamRequestDto.md)
@@ -261,6 +263,7 @@ Class | Method | HTTP request | Description
261
263
  - [ModelResponseDto](truefoundry/ml/autogen/client/docs/ModelResponseDto.md)
262
264
  - [ModelSchemaDto](truefoundry/ml/autogen/client/docs/ModelSchemaDto.md)
263
265
  - [ModelVersionDto](truefoundry/ml/autogen/client/docs/ModelVersionDto.md)
266
+ - [ModelVersionManifest](truefoundry/ml/autogen/client/docs/ModelVersionManifest.md)
264
267
  - [ModelVersionResponseDto](truefoundry/ml/autogen/client/docs/ModelVersionResponseDto.md)
265
268
  - [MultiPartUploadDto](truefoundry/ml/autogen/client/docs/MultiPartUploadDto.md)
266
269
  - [MultiPartUploadResponseDto](truefoundry/ml/autogen/client/docs/MultiPartUploadResponseDto.md)
@@ -284,17 +287,24 @@ Class | Method | HTTP request | Description
284
287
  - [SetExperimentTagRequestDto](truefoundry/ml/autogen/client/docs/SetExperimentTagRequestDto.md)
285
288
  - [SetTagRequestDto](truefoundry/ml/autogen/client/docs/SetTagRequestDto.md)
286
289
  - [SignedURLDto](truefoundry/ml/autogen/client/docs/SignedURLDto.md)
290
+ - [Source](truefoundry/ml/autogen/client/docs/Source.md)
287
291
  - [Stop](truefoundry/ml/autogen/client/docs/Stop.md)
288
292
  - [StoreRunLogsRequestDto](truefoundry/ml/autogen/client/docs/StoreRunLogsRequestDto.md)
293
+ - [Subject](truefoundry/ml/autogen/client/docs/Subject.md)
294
+ - [SubjectType](truefoundry/ml/autogen/client/docs/SubjectType.md)
289
295
  - [SystemMessage](truefoundry/ml/autogen/client/docs/SystemMessage.md)
296
+ - [TensorflowFramework](truefoundry/ml/autogen/client/docs/TensorflowFramework.md)
290
297
  - [Text](truefoundry/ml/autogen/client/docs/Text.md)
291
298
  - [TextContentPart](truefoundry/ml/autogen/client/docs/TextContentPart.md)
299
+ - [TransformersFramework](truefoundry/ml/autogen/client/docs/TransformersFramework.md)
300
+ - [TruefoundryModelSource](truefoundry/ml/autogen/client/docs/TruefoundryModelSource.md)
292
301
  - [UpdateArtifactVersionRequestDto](truefoundry/ml/autogen/client/docs/UpdateArtifactVersionRequestDto.md)
293
302
  - [UpdateDatasetRequestDto](truefoundry/ml/autogen/client/docs/UpdateDatasetRequestDto.md)
294
303
  - [UpdateExperimentRequestDto](truefoundry/ml/autogen/client/docs/UpdateExperimentRequestDto.md)
295
304
  - [UpdateModelVersionRequestDto](truefoundry/ml/autogen/client/docs/UpdateModelVersionRequestDto.md)
296
305
  - [UpdateRunRequestDto](truefoundry/ml/autogen/client/docs/UpdateRunRequestDto.md)
297
306
  - [UpdateRunResponseDto](truefoundry/ml/autogen/client/docs/UpdateRunResponseDto.md)
307
+ - [UploadModelSource](truefoundry/ml/autogen/client/docs/UploadModelSource.md)
298
308
  - [Url](truefoundry/ml/autogen/client/docs/Url.md)
299
309
  - [UserMessage](truefoundry/ml/autogen/client/docs/UserMessage.md)
300
310
  - [ValidationError](truefoundry/ml/autogen/client/docs/ValidationError.md)
@@ -1,13 +1,13 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: artifacts.json
3
- # timestamp: 2024-09-12T13:40:36+00:00
3
+ # timestamp: 2024-10-25T06:52:16+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
7
  from enum import Enum
8
8
  from typing import Any, Dict, List, Literal, Optional, Union
9
9
 
10
- from truefoundry.pydantic_v1 import BaseModel, Field, constr
10
+ from truefoundry.pydantic_v1 import BaseModel, Field, conint, constr
11
11
 
12
12
 
13
13
  class Agent(BaseModel):
@@ -49,6 +49,17 @@ class AgentWithFQN(Agent):
49
49
  fqn: str
50
50
 
51
51
 
52
+ class BaseArtifactVersion(BaseModel):
53
+ description: Optional[constr(max_length=512)] = Field(
54
+ None,
55
+ description="+label=Description\n+docs=Description of the artifact version",
56
+ )
57
+ metadata: Dict[str, Any] = Field(
58
+ ...,
59
+ description="+label=Metadata\n+docs=Metadata for the model version\n+usage=Metadata for the model version\n+uiType=JsonInput",
60
+ )
61
+
62
+
52
63
  class MimeType(str, Enum):
53
64
  """
54
65
  +label=MIME Type
@@ -78,6 +89,51 @@ class BlobStorageReference(BaseModel):
78
89
  )
79
90
 
80
91
 
92
+ class ExternalModelSource(BaseModel):
93
+ """
94
+ +label=External
95
+ """
96
+
97
+ type: Literal["external"] = Field(
98
+ ...,
99
+ description="+label=Type\n+usage=Type of the source\n+value=external\n+type=External",
100
+ )
101
+ uri: str = Field(..., description="+label=URI\n+usage=URI of the model source")
102
+
103
+
104
+ class FastAIFramework(BaseModel):
105
+ """
106
+ +docs=FastAI framework for the model version
107
+ +label=FastAI
108
+ """
109
+
110
+ type: Literal["fastai"] = Field(
111
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=fastai"
112
+ )
113
+
114
+
115
+ class GluonFramework(BaseModel):
116
+ """
117
+ +docs=Gluon framework for the model version
118
+ +label=Gluon
119
+ """
120
+
121
+ type: Literal["gluon"] = Field(
122
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=gluon"
123
+ )
124
+
125
+
126
+ class H2OFramework(BaseModel):
127
+ """
128
+ +docs=H2O framework for the model version
129
+ +label=H2O
130
+ """
131
+
132
+ type: Literal["h2o"] = Field(
133
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=h2o"
134
+ )
135
+
136
+
81
137
  class ImageUrl(BaseModel):
82
138
  """
83
139
  +label=URL for the image
@@ -108,6 +164,28 @@ class ImageContentPart(BaseModel):
108
164
  )
109
165
 
110
166
 
167
+ class KerasFramework(BaseModel):
168
+ """
169
+ +docs=Keras framework for the model version
170
+ +label=Keras
171
+ """
172
+
173
+ type: Literal["keras"] = Field(
174
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=keras"
175
+ )
176
+
177
+
178
+ class LightGBMFramework(BaseModel):
179
+ """
180
+ +docs=LightGBM framework for the model version
181
+ +label=LightGBM
182
+ """
183
+
184
+ type: Literal["lightgbm"] = Field(
185
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=lightgbm"
186
+ )
187
+
188
+
111
189
  class Parameters(BaseModel):
112
190
  """
113
191
  +usage=Parameters for the provider
@@ -148,6 +226,61 @@ class ModelConfiguration(BaseModel):
148
226
  )
149
227
 
150
228
 
229
+ class PaddleFramework(BaseModel):
230
+ """
231
+ +docs=PaddlePaddle framework for the model version
232
+ +label=Paddle
233
+ """
234
+
235
+ type: Literal["paddle"] = Field(
236
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=paddle"
237
+ )
238
+
239
+
240
+ class PyTorchFramework(BaseModel):
241
+ """
242
+ +docs=PyTorch framework for the model version
243
+ +label=PyTorch
244
+ """
245
+
246
+ type: Literal["pytorch"] = Field(
247
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=pytorch"
248
+ )
249
+
250
+
251
+ class SklearnFramework(BaseModel):
252
+ """
253
+ +docs=Scikit-learn framework for the model version
254
+ +label=Sklearn
255
+ """
256
+
257
+ type: Literal["sklearn"] = Field(
258
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=sklearn"
259
+ )
260
+
261
+
262
+ class SpaCyFramework(BaseModel):
263
+ """
264
+ +docs=spaCy framework for the model version
265
+ +label=SpaCy
266
+ """
267
+
268
+ type: Literal["spacy"] = Field(
269
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=spacy"
270
+ )
271
+
272
+
273
+ class StatsModelsFramework(BaseModel):
274
+ """
275
+ +docs=StatsModels framework for the model version
276
+ +label=StatsModels
277
+ """
278
+
279
+ type: Literal["statsmodels"] = Field(
280
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=statsmodels"
281
+ )
282
+
283
+
151
284
  class SystemMessage(BaseModel):
152
285
  """
153
286
  +usage=System message
@@ -164,6 +297,17 @@ class SystemMessage(BaseModel):
164
297
  )
165
298
 
166
299
 
300
+ class TensorFlowFramework(BaseModel):
301
+ """
302
+ +docs=TensorFlow framework for the model version
303
+ +label=TensorFlow
304
+ """
305
+
306
+ type: Literal["tensorflow"] = Field(
307
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=tensorflow"
308
+ )
309
+
310
+
167
311
  class TextContentPart(BaseModel):
168
312
  """
169
313
  +usage=Text content
@@ -174,6 +318,53 @@ class TextContentPart(BaseModel):
174
318
  text: Union[constr(regex=r"^.[\s\S]*$"), BlobStorageReference]
175
319
 
176
320
 
321
+ class LibraryName(str, Enum):
322
+ """
323
+ +label=Library Name
324
+ +usage=Name of the library for the framework
325
+ """
326
+
327
+ transformers = "transformers"
328
+ sentence_transformers = "sentence-transformers"
329
+ diffusers = "diffusers"
330
+
331
+
332
+ class TransformersFramework(BaseModel):
333
+ """
334
+ +docs=Transformers framework for the model version
335
+ +label=Transformers
336
+ +value=transformers
337
+ """
338
+
339
+ type: Literal["transformers"] = Field(
340
+ ...,
341
+ description="+label=Type\n+usage=Type of the framework\n+value=transformers",
342
+ )
343
+ library_name: Optional[LibraryName] = Field(
344
+ "transformers",
345
+ description="+label=Library Name\n+usage=Name of the library for the framework",
346
+ )
347
+ pipeline_tag: Optional[str] = Field(
348
+ None,
349
+ description="+label=Pipeline Tag\n+usage=Pipeline tag\n+docs=Pipeline tag for the framework",
350
+ )
351
+
352
+
353
+ class TruefoundryModelSource(BaseModel):
354
+ """
355
+ +usage=Source for the Model
356
+ +label=Upload
357
+ """
358
+
359
+ type: Literal["truefoundry"] = Field(
360
+ ...,
361
+ description="+usage=Type of the source\n+type=Upload\n+value=truefoundry\n+label=Upload",
362
+ )
363
+ uri: str = Field(
364
+ ..., description='+label=URI\n+uiType=UploadInput\n+uiProps={"hideClear":true}'
365
+ )
366
+
367
+
177
368
  class UserMessage(BaseModel):
178
369
  """
179
370
  +usage=User message
@@ -194,6 +385,17 @@ class UserMessage(BaseModel):
194
385
  )
195
386
 
196
387
 
388
+ class XGBoostFramework(BaseModel):
389
+ """
390
+ +docs=XGBoost framework for the model version
391
+ +label=XGBoost
392
+ """
393
+
394
+ type: Literal["xgboost"] = Field(
395
+ ..., description="+label=Type\n+usage=Type of the framework\n+value=xgboost"
396
+ )
397
+
398
+
197
399
  class AgentOpenAPITool(BaseModel):
198
400
  type: Literal["openapi-tool"] = Field(..., description="+value=openapi-tool")
199
401
  name: constr(regex=r"^[a-zA-Z][a-zA-Z0-9\-]{1,30}[a-zA-Z0-9]$") = Field(
@@ -275,6 +477,36 @@ class ChatPrompt(BasePrompt):
275
477
  )
276
478
 
277
479
 
480
+ class ModelVersion(BaseArtifactVersion):
481
+ type: Literal["model-version"] = Field(
482
+ ..., description='+label=Type\n+usage=Model Version\n+value="model-version"'
483
+ )
484
+ source: Union[TruefoundryModelSource, ExternalModelSource] = Field(
485
+ ...,
486
+ description="+label=Model Source\n+usage=Source for the model version\n+uiType=Group",
487
+ )
488
+ framework: Optional[
489
+ Union[
490
+ TransformersFramework,
491
+ TensorFlowFramework,
492
+ SklearnFramework,
493
+ PyTorchFramework,
494
+ KerasFramework,
495
+ XGBoostFramework,
496
+ LightGBMFramework,
497
+ FastAIFramework,
498
+ H2OFramework,
499
+ SpaCyFramework,
500
+ StatsModelsFramework,
501
+ GluonFramework,
502
+ PaddleFramework,
503
+ ]
504
+ ] = Field(
505
+ None, description="+label=Framework\n+usage=Framework for the model version"
506
+ )
507
+ step: conint(ge=0) = Field(0, description="+label=Step")
508
+
509
+
278
510
  class AgentApp(BaseModel):
279
511
  type: Literal["agent-app"] = Field(..., description="+value=agent-app")
280
512
  tools: List[AgentOpenAPIToolWithFQN]
@@ -282,5 +514,5 @@ class AgentApp(BaseModel):
282
514
  root_agent: constr(min_length=1)
283
515
 
284
516
 
285
- class Artifacts(BaseModel):
286
- __root__: Union[ChatPrompt, AgentOpenAPITool, Agent, AgentApp]
517
+ class ArtifactsVersion(BaseModel):
518
+ __root__: Union[ChatPrompt, AgentOpenAPITool, Agent, AgentApp, ModelVersion]
@@ -29,9 +29,10 @@ from truefoundry.ml.autogen.entities.artifacts import ChatPrompt
29
29
  from truefoundry.ml.exceptions import MlFoundryException
30
30
  from truefoundry.ml.log_types.artifacts.constants import INTERNAL_METADATA_PATH
31
31
  from truefoundry.ml.log_types.artifacts.utils import (
32
+ _get_src_dest_pairs,
32
33
  _validate_artifact_metadata,
33
34
  _validate_description,
34
- calculate_local_directory_size,
35
+ calculate_total_size,
35
36
  )
36
37
  from truefoundry.ml.logger import logger
37
38
  from truefoundry.ml.session import _get_api_client
@@ -397,7 +398,7 @@ class ChatPromptVersion(ArtifactVersion):
397
398
  @property
398
399
  def extra_parameters(self) -> Dict[str, Any]:
399
400
  _extra_parameters = self._chat_prompt.model_configuration.extra_parameters
400
- return _extra_parameters.dict(exclude_unset=True) if _extra_parameters else {}
401
+ return _extra_parameters if _extra_parameters else {}
401
402
 
402
403
  @property
403
404
  def variables(self) -> Dict[str, Any]:
@@ -409,6 +410,7 @@ def _log_artifact_version_helper(
409
410
  name: str,
410
411
  artifact_type: ArtifactType,
411
412
  artifact_dir: tempfile.TemporaryDirectory,
413
+ dest_to_src_map: Dict[str, str],
412
414
  mlfoundry_artifacts_api: Optional[MlfoundryArtifactsApi] = None,
413
415
  ml_repo_id: Optional[str] = None,
414
416
  description: Optional[str] = None,
@@ -443,15 +445,17 @@ def _log_artifact_version_helper(
443
445
  ),
444
446
  api_client=mlfoundry_artifacts_api.api_client,
445
447
  )
446
- total_size = calculate_local_directory_size(artifact_dir)
448
+
449
+ total_size = calculate_total_size(list(dest_to_src_map.values()))
447
450
  try:
448
451
  logger.info(
449
- "Packaging and uploading files to remote with Artifact Size: %.6f MB",
452
+ "Packaging and uploading files to remote with size: %.6f MB",
450
453
  total_size / 1000000.0,
451
454
  )
452
- artifacts_repo.log_artifacts(
453
- local_dir=artifact_dir.name, artifact_path=None, progress=progress
455
+ src_dest_pairs = _get_src_dest_pairs(
456
+ root_dir=artifact_dir.name, dest_to_src_map=dest_to_src_map
454
457
  )
458
+ artifacts_repo.log_artifacts(src_dest_pairs=src_dest_pairs, progress=progress)
455
459
  except Exception as e:
456
460
  mlfoundry_artifacts_api.notify_failure_post(
457
461
  notify_artifact_version_failure_dto=NotifyArtifactVersionFailureDto(
@@ -19,9 +19,10 @@ from truefoundry.ml.entities import FileInfo
19
19
  from truefoundry.ml.exceptions import MlFoundryException
20
20
  from truefoundry.ml.log_types.artifacts.utils import (
21
21
  _copy_additional_files,
22
+ _get_src_dest_pairs,
22
23
  _validate_artifact_metadata,
23
24
  _validate_description,
24
- calculate_local_directory_size,
25
+ calculate_total_size,
25
26
  )
26
27
  from truefoundry.ml.logger import logger
27
28
  from truefoundry.ml.session import _get_api_client
@@ -139,6 +140,7 @@ class DataDirectory:
139
140
  file_paths: List[
140
141
  Union[Tuple[str], Tuple[str, Optional[str]], DataDirectoryPath]
141
142
  ],
143
+ progress: Optional[bool] = None,
142
144
  ) -> None:
143
145
  """Logs File in the `DataDirectory`.
144
146
 
@@ -207,7 +209,7 @@ class DataDirectory:
207
209
 
208
210
  try:
209
211
  logger.info("Copying the files to add")
210
- _copy_additional_files(
212
+ temp_dest_to_src_map = _copy_additional_files(
211
213
  root_dir=temp_dir.name,
212
214
  files_dir="",
213
215
  model_dir=None,
@@ -219,13 +221,19 @@ class DataDirectory:
219
221
  raise MlFoundryException("Failed to Add Files to DataDirectory") from e
220
222
 
221
223
  artifacts_repo = self._get_artifacts_repo()
222
- total_size = calculate_local_directory_size(temp_dir)
224
+ total_size = calculate_total_size(list(temp_dest_to_src_map.values()))
223
225
  try:
224
226
  logger.info(
225
- "Packaging and uploading files to remote with Size: %.6f MB",
227
+ "Packaging and uploading files to remote with size: %.6f MB",
226
228
  total_size / 1000000.0,
227
229
  )
228
- artifacts_repo.log_artifacts(local_dir=temp_dir.name, artifact_path=None)
230
+ src_dest_pairs = _get_src_dest_pairs(
231
+ root_dir=temp_dir.name, dest_to_src_map=temp_dest_to_src_map
232
+ )
233
+ artifacts_repo.log_artifacts(
234
+ src_dest_pairs=src_dest_pairs,
235
+ progress=progress,
236
+ )
229
237
  except Exception as e:
230
238
  raise MlFoundryException("Failed to Add Files to DataDirectory") from e
231
239
  finally:
@@ -77,7 +77,7 @@ def _log_artifact_version(
77
77
  os.makedirs(local_files_dir, exist_ok=True)
78
78
 
79
79
  logger.info("Copying the files to log")
80
- _copy_additional_files(
80
+ temp_dest_to_src_map = _copy_additional_files(
81
81
  root_dir=temp_dir.name,
82
82
  files_dir=internal_metadata.files_dir,
83
83
  model_dir=None,
@@ -94,6 +94,7 @@ def _log_artifact_version(
94
94
  os.makedirs(os.path.dirname(local_internal_metadata_path), exist_ok=True)
95
95
  with open(local_internal_metadata_path, "w") as f:
96
96
  json.dump(internal_metadata.dict(), f)
97
+ temp_dest_to_src_map[local_internal_metadata_path] = local_internal_metadata_path
97
98
 
98
99
  return _log_artifact_version_helper(
99
100
  run=run,
@@ -101,6 +102,7 @@ def _log_artifact_version(
101
102
  name=name,
102
103
  artifact_type=ArtifactType.ARTIFACT,
103
104
  artifact_dir=temp_dir,
105
+ dest_to_src_map=temp_dest_to_src_map,
104
106
  mlfoundry_artifacts_api=mlfoundry_artifacts_api,
105
107
  description=description,
106
108
  internal_metadata=internal_metadata,
@@ -40,8 +40,10 @@ from truefoundry.ml.log_types.artifacts.constants import (
40
40
  from truefoundry.ml.log_types.artifacts.model_extras import CustomMetric, ModelSchema
41
41
  from truefoundry.ml.log_types.artifacts.utils import (
42
42
  _copy_additional_files,
43
+ _get_src_dest_pairs,
43
44
  _validate_artifact_metadata,
44
45
  _validate_description,
46
+ calculate_total_size,
45
47
  )
46
48
  from truefoundry.ml.session import _get_api_client
47
49
  from truefoundry.pydantic_v1 import BaseModel, Extra
@@ -388,24 +390,6 @@ class ModelVersion:
388
390
  self._set_mutable_attrs()
389
391
 
390
392
 
391
- def calculate_model_size(artifact_dir: tempfile.TemporaryDirectory):
392
- """
393
- Tells about the size of the model
394
-
395
- Args:
396
- artifact_dir (str): directory in which model is present.
397
-
398
- Returns:
399
- total size of the model
400
- """
401
- total_size = 0
402
- for path, _dirs, files in os.walk(artifact_dir.name):
403
- for f in files:
404
- file_path = os.path.join(path, f)
405
- total_size += os.stat(file_path).st_size
406
- return total_size
407
-
408
-
409
393
  def _log_model_version( # noqa: C901
410
394
  run: Optional["MlFoundryRun"],
411
395
  name: str,
@@ -484,28 +468,29 @@ def _log_model_version( # noqa: C901
484
468
  os.makedirs(local_model_dir, exist_ok=True)
485
469
 
486
470
  logger.info("Adding model file/folder to model version content")
487
- model_file_or_folder = [
488
- (model_file_or_folder, MODEL_DIR_NAME.rstrip(os.sep) + os.sep)
471
+ _model_file_or_folder: Sequence[Tuple[str, str]] = [
472
+ (model_file_or_folder, MODEL_DIR_NAME.rstrip(os.sep) + os.sep),
489
473
  ]
490
- _copy_additional_files(
474
+
475
+ temp_dest_to_src_map = _copy_additional_files(
491
476
  root_dir=temp_dir.name,
492
477
  files_dir=internal_metadata.files_dir,
493
478
  model_dir=internal_metadata.model_dir,
494
- additional_files=model_file_or_folder,
479
+ additional_files=_model_file_or_folder,
495
480
  ignore_model_dir_dest_conflict=True,
496
481
  )
497
482
 
498
483
  # verify additional files and paths, copy additional files
499
484
  if additional_files:
500
485
  logger.info("Adding `additional_files` to model version contents")
501
- _copy_additional_files(
486
+ temp_dest_to_src_map = _copy_additional_files(
502
487
  root_dir=temp_dir.name,
503
488
  files_dir=internal_metadata.files_dir,
504
489
  model_dir=internal_metadata.model_dir,
505
490
  additional_files=additional_files,
506
491
  ignore_model_dir_dest_conflict=False,
492
+ existing_dest_to_src_map=temp_dest_to_src_map,
507
493
  )
508
-
509
494
  except Exception as e:
510
495
  temp_dir.cleanup()
511
496
  raise MlFoundryException("Failed to log model") from e
@@ -515,6 +500,7 @@ def _log_model_version( # noqa: C901
515
500
  os.makedirs(os.path.dirname(local_internal_metadata_path), exist_ok=True)
516
501
  with open(local_internal_metadata_path, "w") as f:
517
502
  json.dump(internal_metadata.dict(), f)
503
+ temp_dest_to_src_map[local_internal_metadata_path] = local_internal_metadata_path
518
504
 
519
505
  # create entry
520
506
  _create_artifact_version_response = (
@@ -533,15 +519,17 @@ def _log_model_version( # noqa: C901
533
519
  ),
534
520
  api_client=mlfoundry_artifacts_api.api_client,
535
521
  )
536
- model_size = calculate_model_size(temp_dir)
522
+
523
+ total_size = calculate_total_size(list(temp_dest_to_src_map.values()))
537
524
  try:
538
525
  logger.info(
539
- "Packaging and uploading files to remote with Total Size: %.6f MB",
540
- model_size / 1000000.0,
526
+ "Packaging and uploading files to remote with size: %.6f MB",
527
+ total_size / 1000000.0,
541
528
  )
542
- artifacts_repo.log_artifacts(
543
- local_dir=temp_dir.name, artifact_path=None, progress=progress
529
+ src_dest_pairs = _get_src_dest_pairs(
530
+ root_dir=temp_dir.name, dest_to_src_map=temp_dest_to_src_map
544
531
  )
532
+ artifacts_repo.log_artifacts(src_dest_pairs=src_dest_pairs, progress=progress)
545
533
  except Exception as e:
546
534
  mlfoundry_artifacts_api.notify_failure_post(
547
535
  notify_artifact_version_failure_dto=NotifyArtifactVersionFailureDto(
@@ -562,7 +550,7 @@ def _log_model_version( # noqa: C901
562
550
  finalize_artifact_version_request_dto=FinalizeArtifactVersionRequestDto(
563
551
  id=version_id,
564
552
  run_uuid=run.run_id if run else None,
565
- artifact_size=model_size,
553
+ artifact_size=total_size,
566
554
  internal_metadata=internal_metadata_dto,
567
555
  step=step if run else None,
568
556
  )