truefoundry 0.4.4rc12__py3-none-any.whl → 0.4.6__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.
- truefoundry/common/constants.py +6 -1
- truefoundry/common/utils.py +0 -18
- truefoundry/logger.py +1 -0
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +433 -415
- truefoundry/ml/log_types/artifacts/artifact.py +10 -6
- truefoundry/ml/log_types/artifacts/dataset.py +13 -5
- truefoundry/ml/log_types/artifacts/general_artifact.py +3 -1
- truefoundry/ml/log_types/artifacts/model.py +19 -31
- truefoundry/ml/log_types/artifacts/utils.py +43 -26
- truefoundry/ml/log_types/image/image.py +2 -0
- truefoundry/ml/log_types/plot.py +2 -0
- truefoundry/workflow/__init__.py +3 -1
- truefoundry/workflow/remote_filesystem/__init__.py +6 -0
- truefoundry/workflow/remote_filesystem/logger.py +36 -0
- truefoundry/{common → workflow/remote_filesystem}/tfy_signed_url_client.py +1 -2
- truefoundry/{common → workflow/remote_filesystem}/tfy_signed_url_fs.py +5 -2
- {truefoundry-0.4.4rc12.dist-info → truefoundry-0.4.6.dist-info}/METADATA +1 -1
- {truefoundry-0.4.4rc12.dist-info → truefoundry-0.4.6.dist-info}/RECORD +20 -18
- {truefoundry-0.4.4rc12.dist-info → truefoundry-0.4.6.dist-info}/WHEEL +0 -0
- {truefoundry-0.4.4rc12.dist-info → truefoundry-0.4.6.dist-info}/entry_points.txt +0 -0
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
452
|
+
"Packaging and uploading files to remote with size: %.6f MB",
|
|
450
453
|
total_size / 1000000.0,
|
|
451
454
|
)
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
227
|
+
"Packaging and uploading files to remote with size: %.6f MB",
|
|
226
228
|
total_size / 1000000.0,
|
|
227
229
|
)
|
|
228
|
-
|
|
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
|
|
@@ -50,7 +52,7 @@ from truefoundry.version import __version__
|
|
|
50
52
|
if TYPE_CHECKING:
|
|
51
53
|
from truefoundry.ml.mlfoundry_run import MlFoundryRun
|
|
52
54
|
|
|
53
|
-
logger = logging.getLogger(
|
|
55
|
+
logger = logging.getLogger(__name__)
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
# TODO: Support async download and upload
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
-
|
|
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
|
|
540
|
-
|
|
526
|
+
"Packaging and uploading files to remote with size: %.6f MB",
|
|
527
|
+
total_size / 1000000.0,
|
|
541
528
|
)
|
|
542
|
-
|
|
543
|
-
|
|
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=
|
|
553
|
+
artifact_size=total_size,
|
|
566
554
|
internal_metadata=internal_metadata_dto,
|
|
567
555
|
step=step if run else None,
|
|
568
556
|
)
|
|
@@ -2,31 +2,31 @@ import json
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
import posixpath
|
|
5
|
-
import shutil
|
|
6
|
-
import tempfile
|
|
7
5
|
from pathlib import Path
|
|
8
6
|
from typing import Any, Dict, Optional, Sequence, Tuple, Union
|
|
9
7
|
|
|
10
8
|
from truefoundry.ml.exceptions import MlFoundryException
|
|
11
9
|
from truefoundry.ml.log_types.artifacts.constants import DESCRIPTION_MAX_LENGTH
|
|
12
10
|
|
|
13
|
-
logger = logging.getLogger(
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
14
12
|
|
|
15
13
|
|
|
16
|
-
def _copy_tree(
|
|
14
|
+
def _copy_tree(
|
|
15
|
+
root_dir: str, src_path: str, dest_path: str, dest_to_src: Dict[str, str]
|
|
16
|
+
):
|
|
17
17
|
os.makedirs(dest_path, exist_ok=True)
|
|
18
18
|
for item in os.listdir(src_path):
|
|
19
19
|
src = os.path.join(src_path, item)
|
|
20
20
|
dest = os.path.join(dest_path, item)
|
|
21
21
|
if os.path.isdir(src):
|
|
22
22
|
_copy_tree(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
root_dir=root_dir,
|
|
24
|
+
src_path=src,
|
|
25
|
+
dest_path=dest,
|
|
26
|
+
dest_to_src=dest_to_src,
|
|
27
27
|
)
|
|
28
28
|
else:
|
|
29
|
-
|
|
29
|
+
dest_to_src[dest] = src
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def is_destination_path_dirlike(dest_path) -> bool:
|
|
@@ -48,9 +48,9 @@ def _copy_additional_files(
|
|
|
48
48
|
model_dir: Optional[str], # relative to files_dir e.g "model/"
|
|
49
49
|
additional_files: Sequence[Tuple[Union[str, Path], Optional[str]]],
|
|
50
50
|
ignore_model_dir_dest_conflict: bool = False,
|
|
51
|
-
|
|
51
|
+
existing_dest_to_src_map: Optional[Dict[str, str]] = None,
|
|
52
|
+
) -> Dict[str, str]:
|
|
52
53
|
"""
|
|
53
|
-
|
|
54
54
|
File copying examples:
|
|
55
55
|
# non ambiguous
|
|
56
56
|
# a.txt -> /tmp/ result /tmp/a.txt
|
|
@@ -69,6 +69,7 @@ def _copy_additional_files(
|
|
|
69
69
|
# .gitignore -> /tmp/.gitinclude result /tmp/.gitinclude
|
|
70
70
|
# a.txt -> /tmp/a result /tmp/a
|
|
71
71
|
"""
|
|
72
|
+
dest_to_src = existing_dest_to_src_map or {}
|
|
72
73
|
for src_path, dest_path in additional_files:
|
|
73
74
|
src_path = str(src_path)
|
|
74
75
|
if not os.path.exists(src_path):
|
|
@@ -99,26 +100,47 @@ def _copy_additional_files(
|
|
|
99
100
|
_src = src_path
|
|
100
101
|
if is_destination_path_dirlike(dest_abs_path):
|
|
101
102
|
os.makedirs(dest_abs_path, exist_ok=True)
|
|
102
|
-
|
|
103
|
-
os.path.join(dest_abs_path, os.path.basename(_src)), files_abs_dir
|
|
104
|
-
)
|
|
103
|
+
dest_abs_path = os.path.join(dest_abs_path, os.path.basename(_src))
|
|
105
104
|
else:
|
|
106
105
|
os.makedirs(os.path.dirname(dest_abs_path), exist_ok=True)
|
|
107
|
-
|
|
106
|
+
_dst = os.path.relpath(dest_abs_path, files_abs_dir)
|
|
108
107
|
logger.info(f"Adding file {_src} as /{_dst}")
|
|
109
|
-
|
|
108
|
+
dest_to_src[dest_abs_path] = src_path
|
|
110
109
|
elif os.path.isdir(src_path):
|
|
111
110
|
os.makedirs(dest_abs_path, exist_ok=True)
|
|
112
111
|
_src = src_path.rstrip("/")
|
|
113
112
|
_dst = os.path.relpath(dest_abs_path, files_abs_dir).rstrip("/")
|
|
114
113
|
logger.info(f"Adding contents of {_src}/ to /{_dst}/")
|
|
115
114
|
_copy_tree(
|
|
115
|
+
root_dir=root_dir,
|
|
116
116
|
src_path=src_path,
|
|
117
117
|
dest_path=dest_abs_path,
|
|
118
|
-
|
|
119
|
-
ignore_dangling_symlinks=False,
|
|
118
|
+
dest_to_src=dest_to_src,
|
|
120
119
|
)
|
|
121
120
|
|
|
121
|
+
return dest_to_src
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _make_dest_to_src_map_from_dir(root_dir: str) -> Dict[str, str]:
|
|
125
|
+
dest_to_src_map = {}
|
|
126
|
+
for root, _, files in os.walk(root_dir):
|
|
127
|
+
for file in files:
|
|
128
|
+
src = os.path.join(root, file)
|
|
129
|
+
dest = src
|
|
130
|
+
dest_to_src_map[dest] = src
|
|
131
|
+
return dest_to_src_map
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _get_src_dest_pairs(
|
|
135
|
+
root_dir: str,
|
|
136
|
+
dest_to_src_map: Dict[str, str],
|
|
137
|
+
) -> Sequence[Tuple[str, str]]:
|
|
138
|
+
src_dest_pairs = [
|
|
139
|
+
(src_path, os.path.relpath(dest_abs_path, root_dir))
|
|
140
|
+
for dest_abs_path, src_path in dest_to_src_map.items()
|
|
141
|
+
]
|
|
142
|
+
return src_dest_pairs
|
|
143
|
+
|
|
122
144
|
|
|
123
145
|
def _validate_description(description: Optional[str]):
|
|
124
146
|
if description is not None:
|
|
@@ -141,8 +163,8 @@ def _validate_artifact_metadata(metadata: Dict[str, Any]):
|
|
|
141
163
|
raise MlFoundryException("`metadata` must be json serializable dict") from ve
|
|
142
164
|
|
|
143
165
|
|
|
144
|
-
def
|
|
145
|
-
|
|
166
|
+
def calculate_total_size(
|
|
167
|
+
paths: Sequence[str],
|
|
146
168
|
):
|
|
147
169
|
"""
|
|
148
170
|
Tells about the size of the artifact
|
|
@@ -153,9 +175,4 @@ def calculate_local_directory_size(
|
|
|
153
175
|
Returns:
|
|
154
176
|
total size of the artifact
|
|
155
177
|
"""
|
|
156
|
-
|
|
157
|
-
for path, _dirs, files in os.walk(directory.name):
|
|
158
|
-
for f in files:
|
|
159
|
-
file_path = os.path.join(path, f)
|
|
160
|
-
total_size += os.stat(file_path).st_size
|
|
161
|
-
return total_size
|
|
178
|
+
return sum(os.stat(os.path.realpath(file_path)).st_size for file_path in paths)
|
|
@@ -18,6 +18,7 @@ from truefoundry.ml.log_types.artifacts.constants import (
|
|
|
18
18
|
FILES_DIR,
|
|
19
19
|
INTERNAL_METADATA_PATH,
|
|
20
20
|
)
|
|
21
|
+
from truefoundry.ml.log_types.artifacts.utils import _make_dest_to_src_map_from_dir
|
|
21
22
|
from truefoundry.ml.log_types.image.constants import (
|
|
22
23
|
DEFAULT_IMAGE_FORMAT,
|
|
23
24
|
IMAGE_KEY_REGEX,
|
|
@@ -344,6 +345,7 @@ class Image:
|
|
|
344
345
|
name=key,
|
|
345
346
|
artifact_type=ArtifactType.IMAGE,
|
|
346
347
|
artifact_dir=temp_dir,
|
|
348
|
+
dest_to_src_map=_make_dest_to_src_map_from_dir(root_dir=temp_dir.name),
|
|
347
349
|
internal_metadata=internal_metadata,
|
|
348
350
|
step=step,
|
|
349
351
|
)
|
truefoundry/ml/log_types/plot.py
CHANGED
|
@@ -18,6 +18,7 @@ from truefoundry.ml.log_types.artifacts.constants import (
|
|
|
18
18
|
FILES_DIR,
|
|
19
19
|
INTERNAL_METADATA_PATH,
|
|
20
20
|
)
|
|
21
|
+
from truefoundry.ml.log_types.artifacts.utils import _make_dest_to_src_map_from_dir
|
|
21
22
|
from truefoundry.ml.log_types.pydantic_base import PydanticBase
|
|
22
23
|
from truefoundry.ml.log_types.utils import validate_key_name
|
|
23
24
|
from truefoundry.pydantic_v1 import BaseModel
|
|
@@ -186,6 +187,7 @@ class Plot:
|
|
|
186
187
|
name=key,
|
|
187
188
|
artifact_type=ArtifactType.PLOT,
|
|
188
189
|
artifact_dir=temp_dir,
|
|
190
|
+
dest_to_src_map=_make_dest_to_src_map_from_dir(root_dir=temp_dir.name),
|
|
189
191
|
internal_metadata=internal_metadata,
|
|
190
192
|
step=step,
|
|
191
193
|
)
|
truefoundry/workflow/__init__.py
CHANGED
|
@@ -6,9 +6,9 @@ except ImportError:
|
|
|
6
6
|
|
|
7
7
|
from flytekit import conditional
|
|
8
8
|
from flytekit.types.directory import FlyteDirectory
|
|
9
|
+
from flytekit.types.file import FlyteFile
|
|
9
10
|
|
|
10
11
|
from truefoundry.common.constants import ENV_VARS
|
|
11
|
-
from truefoundry.common.tfy_signed_url_fs import SignedURLFileSystem
|
|
12
12
|
from truefoundry.deploy.v2.lib.patched_models import (
|
|
13
13
|
ContainerTaskConfig,
|
|
14
14
|
PythonTaskConfig,
|
|
@@ -18,6 +18,7 @@ from truefoundry.deploy.v2.lib.patched_models import (
|
|
|
18
18
|
from truefoundry.workflow.container_task import ContainerTask
|
|
19
19
|
from truefoundry.workflow.map_task import map_task
|
|
20
20
|
from truefoundry.workflow.python_task import PythonFunctionTask
|
|
21
|
+
from truefoundry.workflow.remote_filesystem.tfy_signed_url_fs import SignedURLFileSystem
|
|
21
22
|
from truefoundry.workflow.task import task
|
|
22
23
|
from truefoundry.workflow.workflow import ExecutionConfig, workflow
|
|
23
24
|
|
|
@@ -34,6 +35,7 @@ __all__ = [
|
|
|
34
35
|
"ContainerTaskConfig",
|
|
35
36
|
"PythonTaskConfig",
|
|
36
37
|
"ExecutionConfig",
|
|
38
|
+
"FlyteFile",
|
|
37
39
|
]
|
|
38
40
|
|
|
39
41
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
from functools import wraps
|
|
4
|
+
from timeit import default_timer
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("truefoundry.workflow.remote_filesystem")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def init_logger(level=logging.WARNING):
|
|
10
|
+
handler = logging.StreamHandler(sys.stdout)
|
|
11
|
+
handler.setLevel(level)
|
|
12
|
+
formatter = logging.Formatter(
|
|
13
|
+
"[%(name)s] %(asctime)s %(levelname)s %(message)s",
|
|
14
|
+
datefmt="%Y-%m-%dT%H:%M:%S%z",
|
|
15
|
+
)
|
|
16
|
+
handler.setFormatter(formatter)
|
|
17
|
+
logger.addHandler(handler)
|
|
18
|
+
logger.setLevel(logging.DEBUG)
|
|
19
|
+
logger.propagate = False
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def log_time(prefix: str = ""):
|
|
23
|
+
"""Decorator to log the time taken by I/O operations."""
|
|
24
|
+
|
|
25
|
+
def decorator(func):
|
|
26
|
+
@wraps(func)
|
|
27
|
+
def wrapper(*args, **kwargs):
|
|
28
|
+
start_time = default_timer()
|
|
29
|
+
result = func(*args, **kwargs)
|
|
30
|
+
elapsed_time = default_timer() - start_time
|
|
31
|
+
logger.info(f"{prefix}{func.__name__} took {elapsed_time:.2f} seconds")
|
|
32
|
+
return result
|
|
33
|
+
|
|
34
|
+
return wrapper
|
|
35
|
+
|
|
36
|
+
return decorator
|
|
@@ -11,9 +11,8 @@ from truefoundry.common.constants import (
|
|
|
11
11
|
TFY_INTERNAL_SIGNED_URL_SERVER_TOKEN_ENV_KEY,
|
|
12
12
|
)
|
|
13
13
|
from truefoundry.common.request_utils import requests_retry_session
|
|
14
|
-
from truefoundry.common.utils import log_time
|
|
15
|
-
from truefoundry.logger import logger
|
|
16
14
|
from truefoundry.pydantic_v1 import BaseModel, Field
|
|
15
|
+
from truefoundry.workflow.remote_filesystem.logger import log_time, logger
|
|
17
16
|
|
|
18
17
|
LOG_PREFIX = "[tfy][fs]"
|
|
19
18
|
DEFAULT_TTL = ENV_VARS.TFY_INTERNAL_SIGNED_URL_SERVER_DEFAULT_TTL
|
|
@@ -8,8 +8,11 @@ from typing import Optional
|
|
|
8
8
|
from fsspec.spec import DEFAULT_CALLBACK, AbstractBufferedFile, AbstractFileSystem
|
|
9
9
|
|
|
10
10
|
from truefoundry.common.constants import ENV_VARS
|
|
11
|
-
from truefoundry.
|
|
12
|
-
from truefoundry.
|
|
11
|
+
from truefoundry.workflow.remote_filesystem.logger import log_time
|
|
12
|
+
from truefoundry.workflow.remote_filesystem.tfy_signed_url_client import (
|
|
13
|
+
LOG_PREFIX,
|
|
14
|
+
SignedURLClient,
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
class SignedURLFileSystem(AbstractFileSystem):
|
|
@@ -27,16 +27,14 @@ truefoundry/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
27
27
|
truefoundry/cli/__main__.py,sha256=-NkhYlT3mC5MhtekueKAvCw-sWvguj0LJRpXWzvvFjc,727
|
|
28
28
|
truefoundry/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
truefoundry/common/auth_service_client.py,sha256=tZOa0NdATnItsMeTnEnUeTZQIgUJtpU-nvLdWtB4Px8,7978
|
|
30
|
-
truefoundry/common/constants.py,sha256=
|
|
30
|
+
truefoundry/common/constants.py,sha256=OwT8CJxGDhnrfgXCiKG5d5pkGbrd1UGGY-y672Et07Y,2310
|
|
31
31
|
truefoundry/common/credential_file_manager.py,sha256=1yEk1Zm2xS4G0VDFwKSZ4w0VUrcPWQ1nJnoBaz9xyKA,4251
|
|
32
32
|
truefoundry/common/credential_provider.py,sha256=Aht7hFLsnyRgMR34dRbzln7dor0WYSeA8ej8ApNmnKM,4148
|
|
33
33
|
truefoundry/common/entities.py,sha256=8O-EGPk4PKqnyoFMKUTxISCU19rz0KBnfRDJU695DhY,3797
|
|
34
34
|
truefoundry/common/exceptions.py,sha256=ePpiQ_zmWe4e94gOgeMiyP_AZnKwjEBfyXsB5ScGYcI,329
|
|
35
35
|
truefoundry/common/request_utils.py,sha256=5xw4YGUcMf71Ncal3OfFCa-PoWDIvG3hYGCDa4Da4OI,2854
|
|
36
36
|
truefoundry/common/servicefoundry_client.py,sha256=2fxmgCM-ckFHpnm6n_mL-5Z8RWN_q-dYVvFC29bkYSg,3120
|
|
37
|
-
truefoundry/common/
|
|
38
|
-
truefoundry/common/tfy_signed_url_fs.py,sha256=xwUR2Vx892sVuiBN5wUNagWuGxGRMecvYsuKQ5yy1rg,8626
|
|
39
|
-
truefoundry/common/utils.py,sha256=RS_YExw9PHfoxKr0BZhPQAsDBKssqL1PgdW6a6rBqu0,3764
|
|
37
|
+
truefoundry/common/utils.py,sha256=MYFjNtHGqauqhj9tmbdErCJR49AfXDwg-5kYbBh8HpI,3258
|
|
40
38
|
truefoundry/deploy/__init__.py,sha256=ugawKF2G02EmEXX35oZ2tec12d9oWN28Sf6mtGGIERY,2281
|
|
41
39
|
truefoundry/deploy/auto_gen/models.py,sha256=4MaxkG2_5Wg6avaZRlK0D4JiVEM5rk3NU0BCiTx8VyU,82477
|
|
42
40
|
truefoundry/deploy/builder/__init__.py,sha256=1qjHMNBE1poRCZW0WrG46dFM1f1IlivD5352qzsioMU,4953
|
|
@@ -124,10 +122,10 @@ truefoundry/langchain/truefoundry_chat.py,sha256=ZA5iyW56fzJeBGxHUpNLFdpy2g9Kw0U
|
|
|
124
122
|
truefoundry/langchain/truefoundry_embeddings.py,sha256=8nRaZ7W1ao1WF0LHk6nNel1LubA8XtDaffGIlUZYeQM,6104
|
|
125
123
|
truefoundry/langchain/truefoundry_llm.py,sha256=CJXyCgXIMbDsVRuuvEA5PKJsf6aRyVlYuG7zC4qtZXE,3802
|
|
126
124
|
truefoundry/langchain/utils.py,sha256=PGLDe9chZ3BuUjakexOGpIqZRFoHEgu-zJ9yKdpLLmM,1329
|
|
127
|
-
truefoundry/logger.py,sha256=
|
|
125
|
+
truefoundry/logger.py,sha256=u-YCNjg5HBwE70uQcpjIG64Ghos-K2ulTWaxC03BSj4,714
|
|
128
126
|
truefoundry/ml/__init__.py,sha256=2A1l7pgqbVRt3cRW_0Lxg92hyJEkMxkCUh1EFprrmc0,942
|
|
129
127
|
truefoundry/ml/artifact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
130
|
-
truefoundry/ml/artifact/truefoundry_artifact_repo.py,sha256=
|
|
128
|
+
truefoundry/ml/artifact/truefoundry_artifact_repo.py,sha256=VU8i3jnY62MLfzA3rxXuUjdqLz8Yaw4zqqPWSsf0mBg,45850
|
|
131
129
|
truefoundry/ml/autogen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
132
130
|
truefoundry/ml/autogen/client/__init__.py,sha256=B6Z0oUmE-S9YqUCDRpKDuTyNWX2Fmx4es7nWx7Bhy10,17600
|
|
133
131
|
truefoundry/ml/autogen/client/api/__init__.py,sha256=3sMSljMIS3UHYeF0BcNvrPPx6VbBSRt_1IfDn-13Kyc,752
|
|
@@ -319,19 +317,19 @@ truefoundry/ml/exceptions.py,sha256=8aJm2NYtAWWsRLu4MbzaoOqHsQZ6RjOFwBWQWqb6qrc,
|
|
|
319
317
|
truefoundry/ml/git_info.py,sha256=jvAVm9ilqivnGq8qJdUvYdd8Siv0PLtqurB-PXsS5ho,2023
|
|
320
318
|
truefoundry/ml/internal_namespace.py,sha256=QcqMHp6-C2im2H_02hlhi01EIcr1HhNaZprszs13EMU,1790
|
|
321
319
|
truefoundry/ml/log_types/__init__.py,sha256=g4u4D4Jaj0aBK5GtrLV88-qThKZR9pSZ17vFEkN-LmM,125
|
|
322
|
-
truefoundry/ml/log_types/artifacts/artifact.py,sha256=
|
|
320
|
+
truefoundry/ml/log_types/artifacts/artifact.py,sha256=n2EwAupOigDcUXQQFIIESRqp7zipLZieec0vLQ2DVRQ,17593
|
|
323
321
|
truefoundry/ml/log_types/artifacts/constants.py,sha256=qKxQ5mMvJE4j83BvGW3qNTKunxCiBg_EEjTdgbgJtyE,1036
|
|
324
|
-
truefoundry/ml/log_types/artifacts/dataset.py,sha256=
|
|
325
|
-
truefoundry/ml/log_types/artifacts/general_artifact.py,sha256=
|
|
326
|
-
truefoundry/ml/log_types/artifacts/model.py,sha256=
|
|
322
|
+
truefoundry/ml/log_types/artifacts/dataset.py,sha256=a4dxd2EN8p7Ci-cLGGiDOboN3t0395_XhWE1dmTw1Q4,13112
|
|
323
|
+
truefoundry/ml/log_types/artifacts/general_artifact.py,sha256=_EOlNGMg2PFjlevlD6LEOsaQBBwRWs60PkzJases6tE,3927
|
|
324
|
+
truefoundry/ml/log_types/artifacts/model.py,sha256=Q4Phy8-5E8hDxHC-Zg-V1uj_-V3p1z6Wh6JC-zot0Vs,21912
|
|
327
325
|
truefoundry/ml/log_types/artifacts/model_extras.py,sha256=TIE73bLKfwIVzNiVcjmaZ841A70BHBwu4XAM6ZAQRFI,1045
|
|
328
|
-
truefoundry/ml/log_types/artifacts/utils.py,sha256=
|
|
326
|
+
truefoundry/ml/log_types/artifacts/utils.py,sha256=3FVOYlfcvZiW8vTbMe7Ft1cjNPR2GW7J69M3dyAY-qc,6299
|
|
329
327
|
truefoundry/ml/log_types/image/__init__.py,sha256=fcOq8yQnNj1rkLcPeIjLXBpdA1WIeiPsXOlAAvMxx7M,76
|
|
330
328
|
truefoundry/ml/log_types/image/constants.py,sha256=wLtGEOA4T5fZHSlOXPuNDLX3lpbCtwlvGKPFk_1fah0,255
|
|
331
|
-
truefoundry/ml/log_types/image/image.py,sha256=
|
|
329
|
+
truefoundry/ml/log_types/image/image.py,sha256=qQnAVgErAq4Jn6wXFFpaveOd52zcjUuomUCqNRxO2io,12478
|
|
332
330
|
truefoundry/ml/log_types/image/image_normalizer.py,sha256=vrzfuSpVGgIxw_Q2sbFe7kQ_JpAndX0bMwC7wtfi41g,3104
|
|
333
331
|
truefoundry/ml/log_types/image/types.py,sha256=inFQlyAyDvZtfliFpENirNCm1XO9beyZ8DNn97DoDKs,1568
|
|
334
|
-
truefoundry/ml/log_types/plot.py,sha256=
|
|
332
|
+
truefoundry/ml/log_types/plot.py,sha256=HuYvvRA5r8V0xAIuuqMME2IHb9d3SfGHUiuEkOP3Uks,7515
|
|
335
333
|
truefoundry/ml/log_types/pydantic_base.py,sha256=eBlw_AEyAz4iJKDP4zgJOCFWcldwQqpf7FADW1jzIQY,272
|
|
336
334
|
truefoundry/ml/log_types/utils.py,sha256=xjJ21jdPScvFmw3TbVh5NCzbzJwaqiXJyiiT4xxX1EI,335
|
|
337
335
|
truefoundry/ml/logger.py,sha256=VT-BF3BnBYTWVq87O58F0c8uXMu94gYzsiFlGY3_7Ao,458
|
|
@@ -342,7 +340,7 @@ truefoundry/ml/session.py,sha256=F83GTC5WwGBjnJ69Ct8MqMnlutYc56JCc6YhEY1Wl-A,539
|
|
|
342
340
|
truefoundry/ml/validation_utils.py,sha256=XBSUd9OoyriWJpT3M5LKz17iWY3yVMr3hM5vdaVjtf0,12082
|
|
343
341
|
truefoundry/pydantic_v1.py,sha256=jSuhGtz0Mbk1qYu8jJ1AcnIDK4oxUsdhALc4spqstmM,345
|
|
344
342
|
truefoundry/version.py,sha256=bqiT4Q-VWrTC6P4qfK43mez-Ppf-smWfrl6DcwV7mrw,137
|
|
345
|
-
truefoundry/workflow/__init__.py,sha256=
|
|
343
|
+
truefoundry/workflow/__init__.py,sha256=XY83vqtLAclI82atZXyBtF9ZgLROXaaXO5p60XH5hJA,1493
|
|
346
344
|
truefoundry/workflow/container_task.py,sha256=8arieePsX4__OnG337hOtCiNgJwtKJJCsZcmFmCBJtk,402
|
|
347
345
|
truefoundry/workflow/example/deploy.sh,sha256=wfbPRrCi04WYRqCf4g-Xo12uWbcqPD6G_Tz0lV0jU_U,60
|
|
348
346
|
truefoundry/workflow/example/hello_world_package/workflow.py,sha256=IkRKfPY5BcvLPo_PVuNbZKK9PPJ93LRkzb1a3RKQYOw,435
|
|
@@ -351,9 +349,13 @@ truefoundry/workflow/example/truefoundry.yaml,sha256=LlPrMADSPJsiXRoK76N_RVjX1bn
|
|
|
351
349
|
truefoundry/workflow/example/workflow.yaml,sha256=YtYdKXMuW_08gfEo21XSculj2MGI2lfEnGF8qCT8NKE,2858
|
|
352
350
|
truefoundry/workflow/map_task.py,sha256=2m3qGXQ90k9LdS45q8dqCCECc3qr8t2m_LMCVd1mZ7g,1737
|
|
353
351
|
truefoundry/workflow/python_task.py,sha256=SRXRLC4vdBqGjhkwuaY39LEWN6iPCpJAuW17URRdWTY,1128
|
|
352
|
+
truefoundry/workflow/remote_filesystem/__init__.py,sha256=LQ95ViEjJ7Ts4JcCGOxMPs7NZmQdZ4bTiq6qXtsjUhE,206
|
|
353
|
+
truefoundry/workflow/remote_filesystem/logger.py,sha256=em2l7D6sw7xTLDP0kQSLpgfRRCLpN14Qw85TN7ujQcE,1022
|
|
354
|
+
truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=ln3zx72jMElZQIVbPRHVd0OfmsLnDbnrntfJ6g1WdfE,10174
|
|
355
|
+
truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=Hf6Dk6Fu6P7DqsK5ULgraf9DStjgigf-kjaRAMBW-RU,8680
|
|
354
356
|
truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
|
|
355
357
|
truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
|
|
356
|
-
truefoundry-0.4.
|
|
357
|
-
truefoundry-0.4.
|
|
358
|
-
truefoundry-0.4.
|
|
359
|
-
truefoundry-0.4.
|
|
358
|
+
truefoundry-0.4.6.dist-info/METADATA,sha256=xMHeMDZtsbcVayGsYdRaNH6uMXROl-lx1759kIXYwS8,3098
|
|
359
|
+
truefoundry-0.4.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
360
|
+
truefoundry-0.4.6.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
|
|
361
|
+
truefoundry-0.4.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|