ZTWHHH commited on
Commit
5b5717d
·
verified ·
1 Parent(s): 40a7560

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. parrot/lib/python3.10/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl +3 -0
  3. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/__init__.cpython-310.pyc +0 -0
  4. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_alerts.cpython-310.pyc +0 -0
  5. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_config.cpython-310.pyc +0 -0
  6. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_helper.cpython-310.pyc +0 -0
  7. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_init.cpython-310.pyc +0 -0
  8. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_login.cpython-310.pyc +0 -0
  9. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_manager.cpython-310.pyc +0 -0
  10. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_metric.cpython-310.pyc +0 -0
  11. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_require.cpython-310.pyc +0 -0
  12. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_require_helpers.cpython-310.pyc +0 -0
  13. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_settings.cpython-310.pyc +0 -0
  14. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_setup.cpython-310.pyc +0 -0
  15. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_summary.cpython-310.pyc +0 -0
  16. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_sweep.cpython-310.pyc +0 -0
  17. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_sync.cpython-310.pyc +0 -0
  18. parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_watch.cpython-310.pyc +0 -0
  19. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_download_logger.py +43 -0
  20. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifest.py +72 -0
  21. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifests/__pycache__/__init__.cpython-310.pyc +0 -0
  22. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifests/__pycache__/artifact_manifest_v1.cpython-310.pyc +0 -0
  23. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_saver.py +267 -0
  24. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/staging.py +25 -0
  25. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handler.py +60 -0
  26. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  27. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/azure_handler.cpython-310.pyc +0 -0
  28. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/gcs_handler.cpython-310.pyc +0 -0
  29. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/local_file_handler.cpython-310.pyc +0 -0
  30. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/multi_handler.cpython-310.pyc +0 -0
  31. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/s3_handler.cpython-310.pyc +0 -0
  32. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/wb_artifact_handler.cpython-310.pyc +0 -0
  33. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/gcs_handler.py +226 -0
  34. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/http_handler.py +113 -0
  35. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/multi_handler.py +54 -0
  36. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/tracking_handler.py +70 -0
  37. parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_layout.py +6 -0
  38. parrot/lib/python3.10/site-packages/wandb/sdk/backend/__pycache__/__init__.cpython-310.pyc +0 -0
  39. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/__init__.cpython-310.pyc +0 -0
  40. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/_settings_toposort_generate.cpython-310.pyc +0 -0
  41. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/_wburls_generate.cpython-310.pyc +0 -0
  42. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/apikey.cpython-310.pyc +0 -0
  43. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/capped_dict.cpython-310.pyc +0 -0
  44. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/deprecate.cpython-310.pyc +0 -0
  45. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/exit_hooks.cpython-310.pyc +0 -0
  46. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/file_stream_utils.cpython-310.pyc +0 -0
  47. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/filenames.cpython-310.pyc +0 -0
  48. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/filesystem.cpython-310.pyc +0 -0
  49. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/fsm.cpython-310.pyc +0 -0
  50. parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/gitlib.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -147,3 +147,4 @@ parrot/lib/python3.10/site-packages/wandb/vendor/pygments/lexers/__pycache__/_ph
147
  parrot/lib/python3.10/site-packages/aiohttp/_http_writer.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
148
  parrot/lib/libquadmath.so filter=lfs diff=lfs merge=lfs -text
149
  parrot/lib/python3.10/site-packages/pyarrow/_dataset_parquet.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
147
  parrot/lib/python3.10/site-packages/aiohttp/_http_writer.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
148
  parrot/lib/libquadmath.so filter=lfs diff=lfs merge=lfs -text
149
  parrot/lib/python3.10/site-packages/pyarrow/_dataset_parquet.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
150
+ parrot/lib/python3.10/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text
parrot/lib/python3.10/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f62ea9da9ed6289bfe868cd6845968a2c854d1427f8548d52cae02a42b4f0356
3
+ size 1232695
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (982 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_alerts.cpython-310.pyc ADDED
Binary file (413 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_config.cpython-310.pyc ADDED
Binary file (11.1 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_helper.cpython-310.pyc ADDED
Binary file (1.71 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_init.cpython-310.pyc ADDED
Binary file (38.4 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_login.cpython-310.pyc ADDED
Binary file (9.59 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_manager.cpython-310.pyc ADDED
Binary file (7.76 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_metric.cpython-310.pyc ADDED
Binary file (3.13 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_require.cpython-310.pyc ADDED
Binary file (3.58 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_require_helpers.cpython-310.pyc ADDED
Binary file (2 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_settings.cpython-310.pyc ADDED
Binary file (53.8 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_setup.cpython-310.pyc ADDED
Binary file (12.5 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_summary.cpython-310.pyc ADDED
Binary file (5.69 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_sweep.cpython-310.pyc ADDED
Binary file (3.72 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_sync.cpython-310.pyc ADDED
Binary file (1.94 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_watch.cpython-310.pyc ADDED
Binary file (3.19 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_download_logger.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Artifact download logger."""
2
+
3
+ import multiprocessing.dummy
4
+ import time
5
+ from typing import Callable
6
+
7
+ from wandb.errors.term import termlog
8
+
9
+
10
+ class ArtifactDownloadLogger:
11
+ def __init__(
12
+ self,
13
+ nfiles: int,
14
+ clock_for_testing: Callable[[], float] = time.monotonic,
15
+ termlog_for_testing: Callable[..., None] = termlog,
16
+ ) -> None:
17
+ self._nfiles = nfiles
18
+ self._clock = clock_for_testing
19
+ self._termlog = termlog_for_testing
20
+
21
+ self._n_files_downloaded = 0
22
+ self._spinner_index = 0
23
+ self._last_log_time = self._clock()
24
+ self._lock = multiprocessing.dummy.Lock()
25
+
26
+ def notify_downloaded(self) -> None:
27
+ with self._lock:
28
+ self._n_files_downloaded += 1
29
+ if self._n_files_downloaded == self._nfiles:
30
+ self._termlog(
31
+ f" {self._nfiles} of {self._nfiles} files downloaded. ",
32
+ # ^ trailing spaces to wipe out ellipsis from previous logs
33
+ newline=True,
34
+ )
35
+ self._last_log_time = self._clock()
36
+ elif self._clock() - self._last_log_time > 0.1:
37
+ self._spinner_index += 1
38
+ spinner = r"-\|/"[self._spinner_index % 4]
39
+ self._termlog(
40
+ f"{spinner} {self._n_files_downloaded} of {self._nfiles} files downloaded...\r",
41
+ newline=False,
42
+ )
43
+ self._last_log_time = self._clock()
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifest.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Artifact manifest."""
2
+
3
+ from typing import TYPE_CHECKING, Dict, List, Mapping, Optional
4
+
5
+ from wandb.sdk.internal.internal_api import Api as InternalApi
6
+ from wandb.sdk.lib.hashutil import HexMD5
7
+
8
+ if TYPE_CHECKING:
9
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
10
+ from wandb.sdk.artifacts.storage_policy import StoragePolicy
11
+
12
+
13
+ class ArtifactManifest:
14
+ entries: Dict[str, "ArtifactManifestEntry"]
15
+
16
+ @classmethod
17
+ def from_manifest_json(
18
+ cls, manifest_json: Dict, api: Optional[InternalApi] = None
19
+ ) -> "ArtifactManifest":
20
+ if "version" not in manifest_json:
21
+ raise ValueError("Invalid manifest format. Must contain version field.")
22
+ version = manifest_json["version"]
23
+ for sub in cls.__subclasses__():
24
+ if sub.version() == version:
25
+ return sub.from_manifest_json(manifest_json, api=api)
26
+ raise ValueError("Invalid manifest version.")
27
+
28
+ @classmethod
29
+ def version(cls) -> int:
30
+ raise NotImplementedError
31
+
32
+ def __init__(
33
+ self,
34
+ storage_policy: "StoragePolicy",
35
+ entries: Optional[Mapping[str, "ArtifactManifestEntry"]] = None,
36
+ ) -> None:
37
+ self.storage_policy = storage_policy
38
+ self.entries = dict(entries) if entries else {}
39
+
40
+ def __len__(self) -> int:
41
+ return len(self.entries)
42
+
43
+ def to_manifest_json(self) -> Dict:
44
+ raise NotImplementedError
45
+
46
+ def digest(self) -> HexMD5:
47
+ raise NotImplementedError
48
+
49
+ def add_entry(self, entry: "ArtifactManifestEntry") -> None:
50
+ if (
51
+ entry.path in self.entries
52
+ and entry.digest != self.entries[entry.path].digest
53
+ ):
54
+ raise ValueError("Cannot add the same path twice: {}".format(entry.path))
55
+ self.entries[entry.path] = entry
56
+
57
+ def remove_entry(self, entry: "ArtifactManifestEntry") -> None:
58
+ if entry.path not in self.entries:
59
+ raise FileNotFoundError(f"Cannot remove missing entry: '{entry.path}'")
60
+ del self.entries[entry.path]
61
+
62
+ def get_entry_by_path(self, path: str) -> Optional["ArtifactManifestEntry"]:
63
+ return self.entries.get(path)
64
+
65
+ def get_entries_in_directory(self, directory: str) -> List["ArtifactManifestEntry"]:
66
+ return [
67
+ self.entries[entry_key]
68
+ for entry_key in self.entries
69
+ if entry_key.startswith(
70
+ directory + "/"
71
+ ) # entries use forward slash even for windows
72
+ ]
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (190 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifests/__pycache__/artifact_manifest_v1.cpython-310.pyc ADDED
Binary file (3.76 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_saver.py ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Artifact saver."""
2
+
3
+ import concurrent.futures
4
+ import json
5
+ import os
6
+ import sys
7
+ import tempfile
8
+ from typing import TYPE_CHECKING, Awaitable, Dict, Optional, Sequence
9
+
10
+ import wandb
11
+ import wandb.filesync.step_prepare
12
+ from wandb import util
13
+ from wandb.sdk.artifacts.artifact_manifest import ArtifactManifest
14
+ from wandb.sdk.lib.hashutil import B64MD5, b64_to_hex_id, md5_file_b64
15
+ from wandb.sdk.lib.paths import URIStr
16
+
17
+ if TYPE_CHECKING:
18
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
19
+ from wandb.sdk.internal.file_pusher import FilePusher
20
+ from wandb.sdk.internal.internal_api import Api as InternalApi
21
+ from wandb.sdk.internal.progress import ProgressFn
22
+
23
+ if sys.version_info >= (3, 8):
24
+ from typing import Protocol
25
+ else:
26
+ from typing_extensions import Protocol
27
+
28
+ class SaveFn(Protocol):
29
+ def __call__(
30
+ self, entry: "ArtifactManifestEntry", progress_callback: "ProgressFn"
31
+ ) -> bool:
32
+ pass
33
+
34
+ class SaveFnAsync(Protocol):
35
+ def __call__(
36
+ self, entry: "ArtifactManifestEntry", progress_callback: "ProgressFn"
37
+ ) -> Awaitable[bool]:
38
+ pass
39
+
40
+
41
+ class ArtifactSaver:
42
+ _server_artifact: Optional[Dict] # TODO better define this dict
43
+
44
+ def __init__(
45
+ self,
46
+ api: "InternalApi",
47
+ digest: str,
48
+ manifest_json: Dict,
49
+ file_pusher: "FilePusher",
50
+ is_user_created: bool = False,
51
+ ) -> None:
52
+ self._api = api
53
+ self._file_pusher = file_pusher
54
+ self._digest = digest
55
+ self._manifest = ArtifactManifest.from_manifest_json(
56
+ manifest_json,
57
+ api=self._api,
58
+ )
59
+ self._is_user_created = is_user_created
60
+ self._server_artifact = None
61
+
62
+ def save(
63
+ self,
64
+ type: str,
65
+ name: str,
66
+ client_id: str,
67
+ sequence_client_id: str,
68
+ distributed_id: Optional[str] = None,
69
+ finalize: bool = True,
70
+ metadata: Optional[Dict] = None,
71
+ ttl_duration_seconds: Optional[int] = None,
72
+ description: Optional[str] = None,
73
+ aliases: Optional[Sequence[str]] = None,
74
+ tags: Optional[Sequence[str]] = None,
75
+ use_after_commit: bool = False,
76
+ incremental: bool = False,
77
+ history_step: Optional[int] = None,
78
+ base_id: Optional[str] = None,
79
+ ) -> Optional[Dict]:
80
+ return self._save_internal(
81
+ type,
82
+ name,
83
+ client_id,
84
+ sequence_client_id,
85
+ distributed_id,
86
+ finalize,
87
+ metadata,
88
+ ttl_duration_seconds,
89
+ description,
90
+ aliases,
91
+ tags,
92
+ use_after_commit,
93
+ incremental,
94
+ history_step,
95
+ base_id,
96
+ )
97
+
98
+ def _save_internal(
99
+ self,
100
+ type: str,
101
+ name: str,
102
+ client_id: str,
103
+ sequence_client_id: str,
104
+ distributed_id: Optional[str] = None,
105
+ finalize: bool = True,
106
+ metadata: Optional[Dict] = None,
107
+ ttl_duration_seconds: Optional[int] = None,
108
+ description: Optional[str] = None,
109
+ aliases: Optional[Sequence[str]] = None,
110
+ tags: Optional[Sequence[str]] = None,
111
+ use_after_commit: bool = False,
112
+ incremental: bool = False,
113
+ history_step: Optional[int] = None,
114
+ base_id: Optional[str] = None,
115
+ ) -> Optional[Dict]:
116
+ alias_specs = []
117
+ for alias in aliases or []:
118
+ alias_specs.append({"artifactCollectionName": name, "alias": alias})
119
+
120
+ tag_specs = [{"tagName": tag} for tag in tags or []]
121
+
122
+ """Returns the server artifact."""
123
+ self._server_artifact, latest = self._api.create_artifact(
124
+ type,
125
+ name,
126
+ self._digest,
127
+ metadata=metadata,
128
+ ttl_duration_seconds=ttl_duration_seconds,
129
+ aliases=alias_specs,
130
+ tags=tag_specs,
131
+ description=description,
132
+ is_user_created=self._is_user_created,
133
+ distributed_id=distributed_id,
134
+ client_id=client_id,
135
+ sequence_client_id=sequence_client_id,
136
+ history_step=history_step,
137
+ )
138
+
139
+ assert self._server_artifact is not None # mypy optionality unwrapper
140
+ artifact_id = self._server_artifact["id"]
141
+ if base_id is None and latest:
142
+ base_id = latest["id"]
143
+ if self._server_artifact["state"] == "COMMITTED":
144
+ if use_after_commit:
145
+ self._api.use_artifact(artifact_id)
146
+ return self._server_artifact
147
+ if (
148
+ self._server_artifact["state"] != "PENDING"
149
+ # For old servers, see https://github.com/wandb/wandb/pull/6190
150
+ and self._server_artifact["state"] != "DELETED"
151
+ ):
152
+ raise Exception(
153
+ 'Unknown artifact state "{}"'.format(self._server_artifact["state"])
154
+ )
155
+
156
+ manifest_type = "FULL"
157
+ manifest_filename = "wandb_manifest.json"
158
+ if incremental:
159
+ manifest_type = "INCREMENTAL"
160
+ manifest_filename = "wandb_manifest.incremental.json"
161
+ elif distributed_id:
162
+ manifest_type = "PATCH"
163
+ manifest_filename = "wandb_manifest.patch.json"
164
+ artifact_manifest_id, _ = self._api.create_artifact_manifest(
165
+ manifest_filename,
166
+ "",
167
+ artifact_id,
168
+ base_artifact_id=base_id,
169
+ include_upload=False,
170
+ type=manifest_type,
171
+ )
172
+
173
+ step_prepare = wandb.filesync.step_prepare.StepPrepare(
174
+ self._api, 0.1, 0.01, 1000
175
+ ) # TODO: params
176
+ step_prepare.start()
177
+
178
+ # Upload Artifact "L1" files, the actual artifact contents
179
+ self._file_pusher.store_manifest_files(
180
+ self._manifest,
181
+ artifact_id,
182
+ lambda entry, progress_callback: self._manifest.storage_policy.store_file(
183
+ artifact_id,
184
+ artifact_manifest_id,
185
+ entry,
186
+ step_prepare,
187
+ progress_callback=progress_callback,
188
+ ),
189
+ )
190
+
191
+ def before_commit() -> None:
192
+ self._resolve_client_id_manifest_references()
193
+ with tempfile.NamedTemporaryFile("w+", suffix=".json", delete=False) as fp:
194
+ path = os.path.abspath(fp.name)
195
+ json.dump(self._manifest.to_manifest_json(), fp, indent=4)
196
+ digest = md5_file_b64(path)
197
+ if distributed_id or incremental:
198
+ # If we're in the distributed flow, we want to update the
199
+ # patch manifest we created with our finalized digest.
200
+ _, resp = self._api.update_artifact_manifest(
201
+ artifact_manifest_id,
202
+ digest=digest,
203
+ )
204
+ else:
205
+ # In the regular flow, we can recreate the full manifest with the
206
+ # updated digest.
207
+ #
208
+ # NOTE: We do this for backwards compatibility with older backends
209
+ # that don't support the 'updateArtifactManifest' API.
210
+ _, resp = self._api.create_artifact_manifest(
211
+ manifest_filename,
212
+ digest,
213
+ artifact_id,
214
+ base_artifact_id=base_id,
215
+ )
216
+
217
+ # We're duplicating the file upload logic a little, which isn't great.
218
+ upload_url = resp["uploadUrl"]
219
+ upload_headers = resp["uploadHeaders"]
220
+ extra_headers = {}
221
+ for upload_header in upload_headers:
222
+ key, val = upload_header.split(":", 1)
223
+ extra_headers[key] = val
224
+ with open(path, "rb") as fp2:
225
+ self._api.upload_file_retry(
226
+ upload_url,
227
+ fp2,
228
+ extra_headers=extra_headers,
229
+ )
230
+
231
+ commit_result: concurrent.futures.Future[None] = concurrent.futures.Future()
232
+
233
+ # This will queue the commit. It will only happen after all the file uploads are done
234
+ self._file_pusher.commit_artifact(
235
+ artifact_id,
236
+ finalize=finalize,
237
+ before_commit=before_commit,
238
+ result_future=commit_result,
239
+ )
240
+
241
+ # Block until all artifact files are uploaded and the
242
+ # artifact is committed.
243
+ try:
244
+ commit_result.result()
245
+ finally:
246
+ step_prepare.shutdown()
247
+
248
+ if finalize and use_after_commit:
249
+ self._api.use_artifact(artifact_id)
250
+
251
+ return self._server_artifact
252
+
253
+ def _resolve_client_id_manifest_references(self) -> None:
254
+ for entry_path in self._manifest.entries:
255
+ entry = self._manifest.entries[entry_path]
256
+ if entry.ref is not None:
257
+ if entry.ref.startswith("wandb-client-artifact:"):
258
+ client_id = util.host_from_path(entry.ref)
259
+ artifact_file_path = util.uri_from_path(entry.ref)
260
+ artifact_id = self._api._resolve_client_id(client_id)
261
+ if artifact_id is None:
262
+ raise RuntimeError(f"Could not resolve client id {client_id}")
263
+ entry.ref = URIStr(
264
+ "wandb-artifact://{}/{}".format(
265
+ b64_to_hex_id(B64MD5(artifact_id)), artifact_file_path
266
+ )
267
+ )
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/staging.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Manages artifact file staging.
2
+
3
+ Artifact files are copied to the staging area as soon as they are added to an artifact
4
+ in order to avoid file changes corrupting the artifact. Once the upload is complete, the
5
+ file should be moved to the artifact cache.
6
+ """
7
+
8
+ import os
9
+
10
+ from wandb import env
11
+ from wandb.sdk.lib.filesystem import mkdir_exists_ok
12
+ from wandb.sdk.lib.paths import FilePathStr
13
+
14
+
15
+ def get_staging_dir() -> FilePathStr:
16
+ path = os.path.join(env.get_data_dir(), "artifacts", "staging")
17
+ try:
18
+ mkdir_exists_ok(path)
19
+ except OSError as e:
20
+ raise PermissionError(
21
+ f"Unable to write staging files to {path}. To fix this problem, please set "
22
+ f"{env.DATA_DIR} to a directory where you have the necessary write access."
23
+ ) from e
24
+
25
+ return FilePathStr(os.path.abspath(os.path.expanduser(path)))
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handler.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Storage handler."""
2
+
3
+ from typing import TYPE_CHECKING, Optional, Sequence, Union
4
+
5
+ from wandb.sdk.lib.paths import FilePathStr, URIStr
6
+
7
+ if TYPE_CHECKING:
8
+ from urllib.parse import ParseResult
9
+
10
+ from wandb.sdk.artifacts.artifact import Artifact
11
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
12
+
13
+ DEFAULT_MAX_OBJECTS = 10**7
14
+
15
+
16
+ class StorageHandler:
17
+ def can_handle(self, parsed_url: "ParseResult") -> bool:
18
+ """Checks whether this handler can handle the given url.
19
+
20
+ Returns:
21
+ Whether this handler can handle the given url.
22
+ """
23
+ raise NotImplementedError
24
+
25
+ def load_path(
26
+ self,
27
+ manifest_entry: "ArtifactManifestEntry",
28
+ local: bool = False,
29
+ ) -> Union[URIStr, FilePathStr]:
30
+ """Load a file or directory given the corresponding index entry.
31
+
32
+ Args:
33
+ manifest_entry: The index entry to load
34
+ local: Whether to load the file locally or not
35
+
36
+ Returns:
37
+ A path to the file represented by `index_entry`
38
+ """
39
+ raise NotImplementedError
40
+
41
+ def store_path(
42
+ self,
43
+ artifact: "Artifact",
44
+ path: Union[URIStr, FilePathStr],
45
+ name: Optional[str] = None,
46
+ checksum: bool = True,
47
+ max_objects: Optional[int] = None,
48
+ ) -> Sequence["ArtifactManifestEntry"]:
49
+ """Store the file or directory at the given path to the specified artifact.
50
+
51
+ Args:
52
+ path: The path to store
53
+ name: If specified, the logical name that should map to `path`
54
+ checksum: Whether to compute the checksum of the file
55
+ max_objects: The maximum number of objects to store
56
+
57
+ Returns:
58
+ A list of manifest entries to store within the artifact
59
+ """
60
+ raise NotImplementedError
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__init__.py ADDED
File without changes
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/azure_handler.cpython-310.pyc ADDED
Binary file (5.72 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/gcs_handler.cpython-310.pyc ADDED
Binary file (6.4 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/local_file_handler.cpython-310.pyc ADDED
Binary file (4.18 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/multi_handler.cpython-310.pyc ADDED
Binary file (2.19 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/s3_handler.cpython-310.pyc ADDED
Binary file (7.85 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/__pycache__/wb_artifact_handler.cpython-310.pyc ADDED
Binary file (4.08 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/gcs_handler.py ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """GCS storage handler."""
2
+
3
+ import time
4
+ from pathlib import PurePosixPath
5
+ from typing import TYPE_CHECKING, Optional, Sequence, Tuple, Union
6
+ from urllib.parse import ParseResult, urlparse
7
+
8
+ from wandb import util
9
+ from wandb.errors.term import termlog
10
+ from wandb.sdk.artifacts.artifact_file_cache import get_artifact_file_cache
11
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
12
+ from wandb.sdk.artifacts.storage_handler import DEFAULT_MAX_OBJECTS, StorageHandler
13
+ from wandb.sdk.lib.hashutil import ETag
14
+ from wandb.sdk.lib.paths import FilePathStr, StrPath, URIStr
15
+
16
+ if TYPE_CHECKING:
17
+ import google.cloud.storage as gcs_module # type: ignore
18
+
19
+ from wandb.sdk.artifacts.artifact import Artifact
20
+
21
+
22
+ class _GCSIsADirectoryError(Exception):
23
+ """Raised when we try to download a GCS folder."""
24
+
25
+ pass
26
+
27
+
28
+ class GCSHandler(StorageHandler):
29
+ _client: Optional["gcs_module.client.Client"]
30
+
31
+ def __init__(self, scheme: Optional[str] = None) -> None:
32
+ self._scheme = scheme or "gs"
33
+ self._client = None
34
+ self._cache = get_artifact_file_cache()
35
+
36
+ def can_handle(self, parsed_url: "ParseResult") -> bool:
37
+ return parsed_url.scheme == self._scheme
38
+
39
+ def init_gcs(self) -> "gcs_module.client.Client":
40
+ if self._client is not None:
41
+ return self._client
42
+ storage = util.get_module(
43
+ "google.cloud.storage",
44
+ required="gs:// references requires the google-cloud-storage library, run pip install wandb[gcp]",
45
+ )
46
+ self._client = storage.Client()
47
+ return self._client
48
+
49
+ def _parse_uri(self, uri: str) -> Tuple[str, str, Optional[str]]:
50
+ url = urlparse(uri)
51
+ bucket = url.netloc
52
+ key = url.path[1:]
53
+ version = url.fragment if url.fragment else None
54
+ return bucket, key, version
55
+
56
+ def load_path(
57
+ self,
58
+ manifest_entry: ArtifactManifestEntry,
59
+ local: bool = False,
60
+ ) -> Union[URIStr, FilePathStr]:
61
+ assert manifest_entry.ref is not None
62
+ if not local:
63
+ return manifest_entry.ref
64
+
65
+ path, hit, cache_open = self._cache.check_etag_obj_path(
66
+ url=URIStr(manifest_entry.ref),
67
+ etag=ETag(manifest_entry.digest),
68
+ size=manifest_entry.size if manifest_entry.size is not None else 0,
69
+ )
70
+ if hit:
71
+ return path
72
+
73
+ self.init_gcs()
74
+ assert self._client is not None # mypy: unwraps optionality
75
+ assert manifest_entry.ref is not None
76
+ bucket, key, _ = self._parse_uri(manifest_entry.ref)
77
+ version = manifest_entry.extra.get("versionID")
78
+
79
+ if self._is_dir(manifest_entry):
80
+ raise _GCSIsADirectoryError(
81
+ f"Unable to download GCS folder {manifest_entry.ref!r}, skipping"
82
+ )
83
+
84
+ obj = None
85
+ # First attempt to get the generation specified, this will return None if versioning is not enabled
86
+ if version is not None:
87
+ obj = self._client.bucket(bucket).get_blob(key, generation=version)
88
+
89
+ if obj is None:
90
+ # Object versioning is disabled on the bucket, so just get
91
+ # the latest version and make sure the MD5 matches.
92
+ obj = self._client.bucket(bucket).get_blob(key)
93
+ if obj is None:
94
+ raise ValueError(
95
+ f"Unable to download object {manifest_entry.ref} with generation {version}"
96
+ )
97
+ if obj.etag != manifest_entry.digest:
98
+ raise ValueError(
99
+ f"Digest mismatch for object {manifest_entry.ref}: "
100
+ f"expected {manifest_entry.digest} but found {obj.etag}"
101
+ )
102
+
103
+ with cache_open(mode="wb") as f:
104
+ obj.download_to_file(f)
105
+ return path
106
+
107
+ def store_path(
108
+ self,
109
+ artifact: "Artifact",
110
+ path: Union[URIStr, FilePathStr],
111
+ name: Optional[StrPath] = None,
112
+ checksum: bool = True,
113
+ max_objects: Optional[int] = None,
114
+ ) -> Sequence[ArtifactManifestEntry]:
115
+ self.init_gcs()
116
+ assert self._client is not None # mypy: unwraps optionality
117
+
118
+ # After parsing any query params / fragments for additional context,
119
+ # such as version identifiers, pare down the path to just the bucket
120
+ # and key.
121
+ bucket, key, version = self._parse_uri(path)
122
+ path = URIStr(f"{self._scheme}://{bucket}/{key}")
123
+ max_objects = max_objects or DEFAULT_MAX_OBJECTS
124
+
125
+ if not checksum:
126
+ return [ArtifactManifestEntry(path=name or key, ref=path, digest=path)]
127
+
128
+ start_time = None
129
+ obj = self._client.bucket(bucket).get_blob(key, generation=version)
130
+ if obj is None and version is not None:
131
+ raise ValueError(f"Object does not exist: {path}#{version}")
132
+ multi = obj is None
133
+ if multi:
134
+ start_time = time.time()
135
+ termlog(
136
+ 'Generating checksum for up to %i objects with prefix "%s"... '
137
+ % (max_objects, key),
138
+ newline=False,
139
+ )
140
+ objects = self._client.bucket(bucket).list_blobs(
141
+ prefix=key, max_results=max_objects
142
+ )
143
+ else:
144
+ objects = [obj]
145
+
146
+ entries = [
147
+ self._entry_from_obj(obj, path, name, prefix=key, multi=multi)
148
+ for obj in objects
149
+ if not obj.name.endswith("/")
150
+ ]
151
+ if start_time is not None:
152
+ termlog("Done. %.1fs" % (time.time() - start_time), prefix=False)
153
+ if len(entries) > max_objects:
154
+ raise ValueError(
155
+ "Exceeded %i objects tracked, pass max_objects to add_reference"
156
+ % max_objects
157
+ )
158
+ return entries
159
+
160
+ def _entry_from_obj(
161
+ self,
162
+ obj: "gcs_module.blob.Blob",
163
+ path: str,
164
+ name: Optional[StrPath] = None,
165
+ prefix: str = "",
166
+ multi: bool = False,
167
+ ) -> ArtifactManifestEntry:
168
+ """Create an ArtifactManifestEntry from a GCS object.
169
+
170
+ Arguments:
171
+ obj: The GCS object
172
+ path: The GCS-style path (e.g.: "gs://bucket/file.txt")
173
+ name: The user assigned name, or None if not specified
174
+ prefix: The prefix to add (will be the same as `path` for directories)
175
+ multi: Whether or not this is a multi-object add.
176
+ """
177
+ bucket, key, _ = self._parse_uri(path)
178
+
179
+ # Always use posix paths, since that's what S3 uses.
180
+ posix_key = PurePosixPath(obj.name) # the bucket key
181
+ posix_path = PurePosixPath(bucket) / PurePosixPath(
182
+ key
183
+ ) # the path, with the scheme stripped
184
+ posix_prefix = PurePosixPath(prefix) # the prefix, if adding a prefix
185
+ posix_name = PurePosixPath(name or "")
186
+ posix_ref = posix_path
187
+
188
+ if name is None:
189
+ # We're adding a directory (prefix), so calculate a relative path.
190
+ if str(posix_prefix) in str(posix_key) and posix_prefix != posix_key:
191
+ posix_name = posix_key.relative_to(posix_prefix)
192
+ posix_ref = posix_path / posix_name
193
+ else:
194
+ posix_name = PurePosixPath(posix_key.name)
195
+ posix_ref = posix_path
196
+ elif multi:
197
+ # We're adding a directory with a name override.
198
+ relpath = posix_key.relative_to(posix_prefix)
199
+ posix_name = posix_name / relpath
200
+ posix_ref = posix_path / relpath
201
+ return ArtifactManifestEntry(
202
+ path=posix_name,
203
+ ref=URIStr(f"{self._scheme}://{str(posix_ref)}"),
204
+ digest=obj.etag,
205
+ size=obj.size,
206
+ extra={"versionID": obj.generation},
207
+ )
208
+
209
+ def _is_dir(
210
+ self,
211
+ manifest_entry: ArtifactManifestEntry,
212
+ ) -> bool:
213
+ assert self._client is not None
214
+ assert manifest_entry.ref is not None
215
+ bucket, key, _ = self._parse_uri(manifest_entry.ref)
216
+ bucket_obj = self._client.bucket(bucket)
217
+ # A gcs bucket key should end with a forward slash on gcloud, but
218
+ # we save these refs without the forward slash in the manifest entry
219
+ # so we check the size and extension, make sure its not referring to
220
+ # an actual file with this reference, and that the ref with the slash
221
+ # exists on gcloud
222
+ return key.endswith("/") or (
223
+ not (manifest_entry.size or PurePosixPath(key).suffix)
224
+ and bucket_obj.get_blob(key) is None
225
+ and bucket_obj.get_blob(f"{key}/") is not None
226
+ )
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/http_handler.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """HTTP storage handler."""
2
+
3
+ import os
4
+ from typing import TYPE_CHECKING, Dict, Optional, Sequence, Tuple, Union
5
+ from urllib.parse import ParseResult
6
+
7
+ from wandb.sdk.artifacts.artifact_file_cache import get_artifact_file_cache
8
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
9
+ from wandb.sdk.artifacts.storage_handler import StorageHandler
10
+ from wandb.sdk.internal.thread_local_settings import _thread_local_api_settings
11
+ from wandb.sdk.lib.hashutil import ETag
12
+ from wandb.sdk.lib.paths import FilePathStr, StrPath, URIStr
13
+
14
+ if TYPE_CHECKING:
15
+ import requests
16
+
17
+ from wandb.sdk.artifacts.artifact import Artifact
18
+
19
+
20
+ class HTTPHandler(StorageHandler):
21
+ def __init__(
22
+ self, session: "requests.Session", scheme: Optional[str] = None
23
+ ) -> None:
24
+ self._scheme = scheme or "http"
25
+ self._cache = get_artifact_file_cache()
26
+ self._session = session
27
+
28
+ def can_handle(self, parsed_url: "ParseResult") -> bool:
29
+ return parsed_url.scheme == self._scheme
30
+
31
+ def load_path(
32
+ self,
33
+ manifest_entry: ArtifactManifestEntry,
34
+ local: bool = False,
35
+ ) -> Union[URIStr, FilePathStr]:
36
+ if not local:
37
+ assert manifest_entry.ref is not None
38
+ return manifest_entry.ref
39
+
40
+ assert manifest_entry.ref is not None
41
+
42
+ path, hit, cache_open = self._cache.check_etag_obj_path(
43
+ URIStr(manifest_entry.ref),
44
+ ETag(manifest_entry.digest), # TODO(spencerpearson): unsafe cast
45
+ manifest_entry.size if manifest_entry.size is not None else 0,
46
+ )
47
+ if hit:
48
+ return path
49
+
50
+ response = self._session.get(
51
+ manifest_entry.ref,
52
+ stream=True,
53
+ cookies=_thread_local_api_settings.cookies,
54
+ headers=_thread_local_api_settings.headers,
55
+ )
56
+ response.raise_for_status()
57
+
58
+ digest: Optional[Union[ETag, FilePathStr, URIStr]]
59
+ digest, size, extra = self._entry_from_headers(response.headers)
60
+ digest = digest or manifest_entry.ref
61
+ if manifest_entry.digest != digest:
62
+ raise ValueError(
63
+ f"Digest mismatch for url {manifest_entry.ref}: expected {manifest_entry.digest} but found {digest}"
64
+ )
65
+
66
+ with cache_open(mode="wb") as file:
67
+ for data in response.iter_content(chunk_size=16 * 1024):
68
+ file.write(data)
69
+ return path
70
+
71
+ def store_path(
72
+ self,
73
+ artifact: "Artifact",
74
+ path: Union[URIStr, FilePathStr],
75
+ name: Optional[StrPath] = None,
76
+ checksum: bool = True,
77
+ max_objects: Optional[int] = None,
78
+ ) -> Sequence[ArtifactManifestEntry]:
79
+ name = name or os.path.basename(path)
80
+ if not checksum:
81
+ return [ArtifactManifestEntry(path=name, ref=path, digest=path)]
82
+
83
+ with self._session.get(
84
+ path,
85
+ stream=True,
86
+ cookies=_thread_local_api_settings.cookies,
87
+ headers=_thread_local_api_settings.headers,
88
+ ) as response:
89
+ response.raise_for_status()
90
+ digest: Optional[Union[ETag, FilePathStr, URIStr]]
91
+ digest, size, extra = self._entry_from_headers(response.headers)
92
+ digest = digest or path
93
+ return [
94
+ ArtifactManifestEntry(
95
+ path=name, ref=path, digest=digest, size=size, extra=extra
96
+ )
97
+ ]
98
+
99
+ def _entry_from_headers(
100
+ self, headers: "requests.structures.CaseInsensitiveDict"
101
+ ) -> Tuple[Optional[ETag], Optional[int], Dict[str, str]]:
102
+ response_headers = {k.lower(): v for k, v in headers.items()}
103
+ size = None
104
+ if response_headers.get("content-length", None):
105
+ size = int(response_headers["content-length"])
106
+
107
+ digest = response_headers.get("etag", None)
108
+ extra = {}
109
+ if digest:
110
+ extra["etag"] = digest
111
+ if digest and digest[:1] == '"' and digest[-1:] == '"':
112
+ digest = digest[1:-1] # trim leading and trailing quotes around etag
113
+ return digest, size, extra
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/multi_handler.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Multi storage handler."""
2
+
3
+ from typing import TYPE_CHECKING, List, Optional, Sequence, Union
4
+ from urllib.parse import urlparse
5
+
6
+ from wandb.sdk.artifacts.storage_handler import StorageHandler
7
+ from wandb.sdk.lib.paths import FilePathStr, URIStr
8
+
9
+ if TYPE_CHECKING:
10
+ from wandb.sdk.artifacts.artifact import Artifact
11
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
12
+
13
+
14
+ class MultiHandler(StorageHandler):
15
+ _handlers: List[StorageHandler]
16
+
17
+ def __init__(
18
+ self,
19
+ handlers: Optional[List[StorageHandler]] = None,
20
+ default_handler: Optional[StorageHandler] = None,
21
+ ) -> None:
22
+ self._handlers = handlers or []
23
+ self._default_handler = default_handler
24
+
25
+ def _get_handler(self, url: Union[FilePathStr, URIStr]) -> StorageHandler:
26
+ parsed_url = urlparse(url)
27
+ for handler in self._handlers:
28
+ if handler.can_handle(parsed_url):
29
+ return handler
30
+ if self._default_handler is not None:
31
+ return self._default_handler
32
+ raise ValueError('No storage handler registered for url "{}"'.format(str(url)))
33
+
34
+ def load_path(
35
+ self,
36
+ manifest_entry: "ArtifactManifestEntry",
37
+ local: bool = False,
38
+ ) -> Union[URIStr, FilePathStr]:
39
+ assert manifest_entry.ref is not None
40
+ handler = self._get_handler(manifest_entry.ref)
41
+ return handler.load_path(manifest_entry, local=local)
42
+
43
+ def store_path(
44
+ self,
45
+ artifact: "Artifact",
46
+ path: Union[URIStr, FilePathStr],
47
+ name: Optional[str] = None,
48
+ checksum: bool = True,
49
+ max_objects: Optional[int] = None,
50
+ ) -> Sequence["ArtifactManifestEntry"]:
51
+ handler = self._get_handler(path)
52
+ return handler.store_path(
53
+ artifact, path, name=name, checksum=checksum, max_objects=max_objects
54
+ )
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_handlers/tracking_handler.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tracking storage handler."""
2
+
3
+ from typing import TYPE_CHECKING, Optional, Sequence, Union
4
+ from urllib.parse import urlparse
5
+
6
+ from wandb.errors.term import termwarn
7
+ from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
8
+ from wandb.sdk.artifacts.storage_handler import StorageHandler
9
+ from wandb.sdk.lib.paths import FilePathStr, StrPath, URIStr
10
+
11
+ if TYPE_CHECKING:
12
+ from urllib.parse import ParseResult
13
+
14
+ from wandb.sdk.artifacts.artifact import Artifact
15
+
16
+
17
+ class TrackingHandler(StorageHandler):
18
+ def __init__(self, scheme: Optional[str] = None) -> None:
19
+ """Track paths with no modification or special processing.
20
+
21
+ Useful when paths being tracked are on file systems mounted at a standardized
22
+ location.
23
+
24
+ For example, if the data to track is located on an NFS share mounted on
25
+ `/data`, then it is sufficient to just track the paths.
26
+ """
27
+ self._scheme = scheme or ""
28
+
29
+ def can_handle(self, parsed_url: "ParseResult") -> bool:
30
+ return parsed_url.scheme == self._scheme
31
+
32
+ def load_path(
33
+ self,
34
+ manifest_entry: ArtifactManifestEntry,
35
+ local: bool = False,
36
+ ) -> Union[URIStr, FilePathStr]:
37
+ if local:
38
+ # Likely a user error. The tracking handler is
39
+ # oblivious to the underlying paths, so it has
40
+ # no way of actually loading it.
41
+ url = urlparse(manifest_entry.ref)
42
+ raise ValueError(
43
+ f"Cannot download file at path {str(manifest_entry.ref)}, scheme {str(url.scheme)} not recognized"
44
+ )
45
+ # TODO(spencerpearson): should this go through util.to_native_slash_path
46
+ # instead of just getting typecast?
47
+ return FilePathStr(manifest_entry.path)
48
+
49
+ def store_path(
50
+ self,
51
+ artifact: "Artifact",
52
+ path: Union[URIStr, FilePathStr],
53
+ name: Optional[StrPath] = None,
54
+ checksum: bool = True,
55
+ max_objects: Optional[int] = None,
56
+ ) -> Sequence[ArtifactManifestEntry]:
57
+ url = urlparse(path)
58
+ if name is None:
59
+ raise ValueError(
60
+ 'You must pass name="<entry_name>" when tracking references with unknown schemes. ref: {}'.format(
61
+ path
62
+ )
63
+ )
64
+ termwarn(
65
+ "Artifact references with unsupported schemes cannot be checksummed: {}".format(
66
+ path
67
+ )
68
+ )
69
+ name = name or url.path[1:] # strip leading slash
70
+ return [ArtifactManifestEntry(path=name, ref=path, digest=path)]
parrot/lib/python3.10/site-packages/wandb/sdk/artifacts/storage_layout.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ """Storage layout."""
2
+
3
+
4
+ class StorageLayout:
5
+ V1 = "V1"
6
+ V2 = "V2"
parrot/lib/python3.10/site-packages/wandb/sdk/backend/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (169 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (351 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/_settings_toposort_generate.cpython-310.pyc ADDED
Binary file (4.69 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/_wburls_generate.cpython-310.pyc ADDED
Binary file (807 Bytes). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/apikey.cpython-310.pyc ADDED
Binary file (6.24 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/capped_dict.cpython-310.pyc ADDED
Binary file (1.38 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/deprecate.cpython-310.pyc ADDED
Binary file (1.75 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/exit_hooks.cpython-310.pyc ADDED
Binary file (1.92 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/file_stream_utils.cpython-310.pyc ADDED
Binary file (2.6 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/filenames.cpython-310.pyc ADDED
Binary file (2.23 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/filesystem.cpython-310.pyc ADDED
Binary file (12.6 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/fsm.cpython-310.pyc ADDED
Binary file (5.39 kB). View file
 
parrot/lib/python3.10/site-packages/wandb/sdk/lib/__pycache__/gitlib.cpython-310.pyc ADDED
Binary file (6.52 kB). View file