cometx 2.3.4__tar.gz → 2.3.6__tar.gz
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.
- cometx-2.3.6/MANIFEST.in +1 -0
- {cometx-2.3.4 → cometx-2.3.6}/PKG-INFO +1 -1
- {cometx-2.3.4 → cometx-2.3.6}/cometx/_version.py +1 -1
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/admin.py +17 -7
- {cometx-2.3.4 → cometx-2.3.6}/cometx/framework/wandb.py +6 -4
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/PKG-INFO +1 -1
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/SOURCES.txt +5 -1
- cometx-2.3.6/tests/__init__.py +12 -0
- cometx-2.3.6/tests/integration/__init__.py +0 -0
- cometx-2.3.6/tests/integration/test_download.py +583 -0
- {cometx-2.3.4 → cometx-2.3.6}/LICENSE +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/README.md +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/__init__.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/_typing.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/_ui.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/api.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/audio.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/__init__.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/config.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/copy.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/copy_utils.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/delete_assets.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/download.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/list_command.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/log.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/reproduce.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/smoke_test.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/update.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/cli/utils.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/framework/__init__.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/framework/comet/__init__.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/framework/comet/download_manager.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/generate_utils.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/magics.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/optimizer.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/panel_utils.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/tools/__init__.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/tools/dataset.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/tools/pointcloud.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx/utils.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/dependency_links.txt +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/entry_points.txt +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/requires.txt +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/cometx.egg-info/top_level.txt +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/setup.cfg +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/setup.py +0 -0
- {cometx-2.3.4 → cometx-2.3.6}/tests/testlib.py +0 -0
cometx-2.3.6/MANIFEST.in
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include cometx/panels *
|
|
@@ -34,9 +34,11 @@ def get_parser_arguments(parser):
|
|
|
34
34
|
)
|
|
35
35
|
parser.add_argument(
|
|
36
36
|
"YEAR_MONTH",
|
|
37
|
-
|
|
37
|
+
nargs="?",
|
|
38
|
+
help="(deprecated) The YEAR-MONTH to run report for, eg 2024-09",
|
|
38
39
|
metavar="YEAR-MONTH",
|
|
39
40
|
type=str,
|
|
41
|
+
default=None,
|
|
40
42
|
)
|
|
41
43
|
parser.add_argument(
|
|
42
44
|
"--host",
|
|
@@ -73,13 +75,21 @@ def admin(parsed_args, remaining=None):
|
|
|
73
75
|
admin_url += "/api/admin/chargeback/report"
|
|
74
76
|
|
|
75
77
|
print("Attempting to get chargeback report from %s..." % admin_url)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if parsed_args.YEAR_MONTH:
|
|
79
|
+
response = api._client.get(
|
|
80
|
+
admin_url + ("?reportMonth=%s" % parsed_args.YEAR_MONTH),
|
|
81
|
+
headers={"Authorization": api.api_key},
|
|
82
|
+
params={},
|
|
83
|
+
)
|
|
84
|
+
filename = "comet-chargeback-report-%s.json" % parsed_args.YEAR_MONTH
|
|
85
|
+
else:
|
|
86
|
+
response = api._client.get(
|
|
87
|
+
admin_url,
|
|
88
|
+
headers={"Authorization": api.api_key},
|
|
89
|
+
params={},
|
|
90
|
+
)
|
|
91
|
+
filename = "comet-chargeback-report.json"
|
|
81
92
|
print("Attempting to save chargeback report...")
|
|
82
|
-
filename = "comet-chargeback-report-%s.json" % parsed_args.YEAR_MONTH
|
|
83
93
|
with open(filename, "w") as fp:
|
|
84
94
|
fp.write(json.dumps(response.json()))
|
|
85
95
|
print("Chargeback report is saved in %r" % filename)
|
|
@@ -218,7 +218,9 @@ class DownloadManager:
|
|
|
218
218
|
"workspaceName": workspace,
|
|
219
219
|
"filePath": info.get("program", "unknown"),
|
|
220
220
|
"fileName": (
|
|
221
|
-
os.path.basename(info
|
|
221
|
+
os.path.basename(info.get("program"))
|
|
222
|
+
if info.get("program")
|
|
223
|
+
else "unknown"
|
|
222
224
|
),
|
|
223
225
|
"cometDownloadVersion": comet_ml.__version__,
|
|
224
226
|
}
|
|
@@ -577,12 +579,12 @@ class DownloadManager:
|
|
|
577
579
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
578
580
|
system_and_os_info = json.load(file.download(root=tmpdirname))
|
|
579
581
|
|
|
580
|
-
args = system_and_os_info
|
|
582
|
+
args = system_and_os_info.get("args", [])
|
|
581
583
|
system_details = {
|
|
582
584
|
"command": (
|
|
583
|
-
[system_and_os_info
|
|
585
|
+
[system_and_os_info.get("program", "unknown")] + args
|
|
584
586
|
if args
|
|
585
|
-
else [system_and_os_info
|
|
587
|
+
else [system_and_os_info.get("program", "unknown")]
|
|
586
588
|
),
|
|
587
589
|
"env": None,
|
|
588
590
|
"hostname": system_and_os_info.get("host", "unknown"),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
2
3
|
README.md
|
|
3
4
|
setup.py
|
|
4
5
|
cometx/__init__.py
|
|
@@ -38,4 +39,7 @@ cometx/framework/comet/download_manager.py
|
|
|
38
39
|
cometx/tools/__init__.py
|
|
39
40
|
cometx/tools/dataset.py
|
|
40
41
|
cometx/tools/pointcloud.py
|
|
41
|
-
tests/
|
|
42
|
+
tests/__init__.py
|
|
43
|
+
tests/testlib.py
|
|
44
|
+
tests/integration/__init__.py
|
|
45
|
+
tests/integration/test_download.py
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ****************************************
|
|
3
|
+
# __
|
|
4
|
+
# _________ ____ ___ ___ / /__ __
|
|
5
|
+
# / ___/ __ \/ __ `__ \/ _ \/ __/ |/_/
|
|
6
|
+
# / /__/ /_/ / / / / / / __/ /__> <
|
|
7
|
+
# \___/\____/_/ /_/ /_/\___/\__/_/|_|
|
|
8
|
+
#
|
|
9
|
+
#
|
|
10
|
+
# Copyright (c) 2022 Cometx Development
|
|
11
|
+
# Team. All rights reserved.
|
|
12
|
+
# ****************************************
|
|
File without changes
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ******************************************
|
|
3
|
+
# __
|
|
4
|
+
# _________ ____ ___ ___ / /__ __
|
|
5
|
+
# / ___/ __ \/ __ `__ \/ _ \/ __/ |/_/
|
|
6
|
+
# / /__/ /_/ / / / / / / __/ /__> <
|
|
7
|
+
# \___/\____/_/ /_/ /_/\___/\__/_/|_|
|
|
8
|
+
#
|
|
9
|
+
#
|
|
10
|
+
# Copyright (C) 2022 Cometx Development Team
|
|
11
|
+
# All rights reserved.
|
|
12
|
+
# ******************************************
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import random
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
import tempfile
|
|
19
|
+
|
|
20
|
+
import comet_ml
|
|
21
|
+
from comet_ml.config import get_config
|
|
22
|
+
from comet_ml.utils import proper_registry_model_name
|
|
23
|
+
from mock import patch
|
|
24
|
+
|
|
25
|
+
from cometx.cli.download import main
|
|
26
|
+
from cometx.framework.comet import DownloadManager
|
|
27
|
+
|
|
28
|
+
from ..testlib import environ, until
|
|
29
|
+
|
|
30
|
+
THIS_DIR = os.path.dirname(__file__)
|
|
31
|
+
MODEL_PATH = os.path.join(THIS_DIR, "../model")
|
|
32
|
+
DIFF_CONTENTS = """diff --git a/repo-name/file.py b/repo-name/file.py
|
|
33
|
+
index ed4da9e..00e5b87 100644
|
|
34
|
+
--- a/repo-name/file.py
|
|
35
|
+
+++ b/repo-name/file.py
|
|
36
|
+
@@ -502,3 +502,27 @@
|
|
37
|
+
|
|
38
|
+
def function(self):
|
|
39
|
+
x = 40
|
|
40
|
+
+
|
|
41
|
+
+ def function(self):
|
|
42
|
+
+ x = 42
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def make_project_name():
|
|
47
|
+
return "test-project-" + str(random.randint(1, 10000))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def command(command_list):
|
|
51
|
+
output = subprocess.check_output(command_list)
|
|
52
|
+
output = output.decode(sys.stdout.encoding)
|
|
53
|
+
output = output.strip()
|
|
54
|
+
return output.split("\n")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class TestDownload:
|
|
58
|
+
@classmethod
|
|
59
|
+
def setup_class(cls):
|
|
60
|
+
cls.USER = os.environ.get("COMET_USER")
|
|
61
|
+
if cls.USER is None:
|
|
62
|
+
raise Exception("define in env 'COMET_USER' to run tests")
|
|
63
|
+
cls.WORKSPACE = get_config("comet.workspace") or cls.USER
|
|
64
|
+
cls.API_KEY = get_config("comet.api_key")
|
|
65
|
+
|
|
66
|
+
# create an experiment, and log everything
|
|
67
|
+
cls.MODEL_NAME = "model-%s" % random.randint(1000000, 9000000)
|
|
68
|
+
cls.ARTIFACT_NAME = "artifact-%s" % random.randint(1000000, 9000000)
|
|
69
|
+
cls.PROPER_MODEL_NAME = proper_registry_model_name(cls.MODEL_NAME)
|
|
70
|
+
|
|
71
|
+
# No cache:
|
|
72
|
+
cls.api = comet_ml.API(api_key=cls.API_KEY, cache=False)
|
|
73
|
+
cls.PROJECT_NAME = make_project_name()
|
|
74
|
+
|
|
75
|
+
exp = comet_ml.Experiment(
|
|
76
|
+
api_key=cls.API_KEY,
|
|
77
|
+
workspace=cls.WORKSPACE,
|
|
78
|
+
project_name=cls.PROJECT_NAME,
|
|
79
|
+
log_git_metadata=False,
|
|
80
|
+
log_git_patch=False,
|
|
81
|
+
log_code=True,
|
|
82
|
+
)
|
|
83
|
+
cls.EXPERIMENT_ID = exp.id
|
|
84
|
+
cls.EXPERIMENT_NAME = exp.name
|
|
85
|
+
exp.log_model(cls.MODEL_NAME, MODEL_PATH)
|
|
86
|
+
|
|
87
|
+
# Metrics
|
|
88
|
+
for i in range(15):
|
|
89
|
+
exp.log_metric("loss", random.random() * i, step=i)
|
|
90
|
+
|
|
91
|
+
# Parameters
|
|
92
|
+
exp.log_parameters({"learning_rate": 0.1, "hidden_layer_size": 150})
|
|
93
|
+
# Assets
|
|
94
|
+
exp.log_asset_folder(MODEL_PATH)
|
|
95
|
+
# Artifacts
|
|
96
|
+
artifact = comet_ml.Artifact(cls.ARTIFACT_NAME, "dataset")
|
|
97
|
+
artifact.add(os.path.join(MODEL_PATH, "keras_module.txt"))
|
|
98
|
+
exp.log_artifact(artifact)
|
|
99
|
+
|
|
100
|
+
exp.end()
|
|
101
|
+
|
|
102
|
+
assert until(
|
|
103
|
+
lambda: cls.api.get(cls.WORKSPACE, cls.PROJECT_NAME, cls.EXPERIMENT_ID)
|
|
104
|
+
is not None
|
|
105
|
+
)
|
|
106
|
+
cls.api_exp = cls.api.get(cls.WORKSPACE, cls.PROJECT_NAME, cls.EXPERIMENT_ID)
|
|
107
|
+
|
|
108
|
+
assert until(
|
|
109
|
+
lambda: cls.api.get_project(cls.WORKSPACE, cls.PROJECT_NAME) is not None
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
cls.PROJECT_ID = cls.api.get_project(cls.WORKSPACE, cls.PROJECT_NAME)[
|
|
113
|
+
"projectId"
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
# After everything has uploaded:
|
|
117
|
+
exp = cls.api.get_experiment_by_key(exp.id)
|
|
118
|
+
assert until(lambda: cls.MODEL_NAME in exp.get_model_names())
|
|
119
|
+
exp.register_model(cls.MODEL_NAME, tags=["Production"])
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def teardown_class(cls):
|
|
123
|
+
cls.api.delete_project(cls.WORKSPACE, cls.PROJECT_NAME, delete_experiments=True)
|
|
124
|
+
cls.api.delete_registry_model(cls.WORKSPACE, cls.MODEL_NAME)
|
|
125
|
+
# TODO: remove artifact
|
|
126
|
+
|
|
127
|
+
def setup_method(self):
|
|
128
|
+
self.DIR = ""
|
|
129
|
+
|
|
130
|
+
def download(self, comet_path, capsys, **kwargs):
|
|
131
|
+
dm = DownloadManager(api_key=self.API_KEY)
|
|
132
|
+
dm.download(comet_path, **kwargs)
|
|
133
|
+
captured = capsys.readouterr()
|
|
134
|
+
return captured.out.strip().split("\n")
|
|
135
|
+
|
|
136
|
+
def test_download_workspaces_list(self, capsys):
|
|
137
|
+
result = self.USER
|
|
138
|
+
output = self.download(None, capsys, list_items=True)
|
|
139
|
+
assert len(output) >= 0
|
|
140
|
+
assert result in output
|
|
141
|
+
|
|
142
|
+
def test_download_project_list(self, capsys):
|
|
143
|
+
comet_path = "%s" % (self.WORKSPACE)
|
|
144
|
+
result = "%s/%s" % (self.WORKSPACE, self.PROJECT_NAME)
|
|
145
|
+
output = self.download(comet_path, capsys, list_items=True)
|
|
146
|
+
assert len(output) >= 1 # projects
|
|
147
|
+
assert result in output
|
|
148
|
+
|
|
149
|
+
def test_download_experiment_list(self, capsys):
|
|
150
|
+
comet_path = "%s/%s" % (self.WORKSPACE, self.PROJECT_NAME)
|
|
151
|
+
result = "%s/%s/%s" % (self.WORKSPACE, self.PROJECT_NAME, self.EXPERIMENT_ID)
|
|
152
|
+
output = self.download(comet_path, capsys, list_items=True)
|
|
153
|
+
assert len(output) == 1
|
|
154
|
+
assert result in output
|
|
155
|
+
|
|
156
|
+
def test_download_experiment_list_2(self, capsys):
|
|
157
|
+
comet_path = "%s/%s/%s" % (
|
|
158
|
+
self.WORKSPACE,
|
|
159
|
+
self.PROJECT_NAME,
|
|
160
|
+
self.EXPERIMENT_ID,
|
|
161
|
+
)
|
|
162
|
+
result = "%s/%s/%s" % (self.WORKSPACE, self.PROJECT_NAME, self.EXPERIMENT_ID)
|
|
163
|
+
output = self.download(comet_path, capsys, list_items=True)
|
|
164
|
+
assert len(output) == 1
|
|
165
|
+
assert result in output
|
|
166
|
+
|
|
167
|
+
def test_download_artifact_list(self, capsys):
|
|
168
|
+
comet_path = "%s/artifacts/%s" % (
|
|
169
|
+
self.WORKSPACE,
|
|
170
|
+
self.ARTIFACT_NAME,
|
|
171
|
+
)
|
|
172
|
+
results = [
|
|
173
|
+
self.make_path("{ws}/artifacts/{aname}/1.0.0 (Latest)"),
|
|
174
|
+
]
|
|
175
|
+
output = self.download(comet_path, capsys, list_items=True)
|
|
176
|
+
for result in results:
|
|
177
|
+
assert result in output
|
|
178
|
+
|
|
179
|
+
def test_download_model_list(self, capsys):
|
|
180
|
+
comet_path = "%s/model-registry/%s" % (
|
|
181
|
+
self.WORKSPACE,
|
|
182
|
+
self.MODEL_NAME,
|
|
183
|
+
)
|
|
184
|
+
results = [
|
|
185
|
+
self.make_path("{ws}/model-registry/{mname}/1.0.0 (Production)"),
|
|
186
|
+
]
|
|
187
|
+
output = self.download(comet_path, capsys, list_items=True)
|
|
188
|
+
for result in results:
|
|
189
|
+
assert result in output
|
|
190
|
+
|
|
191
|
+
def make_path(self, comet_path):
|
|
192
|
+
return comet_path.format(
|
|
193
|
+
dir=self.DIR,
|
|
194
|
+
ws=self.USER,
|
|
195
|
+
proj=self.PROJECT_NAME,
|
|
196
|
+
exp=self.EXPERIMENT_ID,
|
|
197
|
+
ename=self.EXPERIMENT_NAME,
|
|
198
|
+
mname=self.MODEL_NAME,
|
|
199
|
+
aname=self.ARTIFACT_NAME,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
@patch("comet_ml.API.get_project_notes")
|
|
203
|
+
def test_download_project(self, mock_get_project_notes, capsys):
|
|
204
|
+
mock_get_project_notes.return_value = "Project Notes Text"
|
|
205
|
+
|
|
206
|
+
comet_path = "%s/%s" % (self.WORKSPACE, self.PROJECT_NAME)
|
|
207
|
+
self.DIR = tempfile.mkdtemp()
|
|
208
|
+
results = [
|
|
209
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
210
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metrics.jsonl"),
|
|
211
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metadata.json"),
|
|
212
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/parameters.json"),
|
|
213
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/others.jsonl"),
|
|
214
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/system_details.json"),
|
|
215
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/script.py"),
|
|
216
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/assets_metadata.jsonl"),
|
|
217
|
+
self.make_path(
|
|
218
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/keras_module.txt"
|
|
219
|
+
),
|
|
220
|
+
self.make_path(
|
|
221
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/model.h5"
|
|
222
|
+
),
|
|
223
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/model.h5"),
|
|
224
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/keras_module.txt"),
|
|
225
|
+
# Via mock:
|
|
226
|
+
self.make_path("{dir}/{ws}/{proj}/project_notes.md"),
|
|
227
|
+
]
|
|
228
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
229
|
+
assert len(output) > 0
|
|
230
|
+
actual_results = command(["find", self.DIR])
|
|
231
|
+
for result in results:
|
|
232
|
+
assert result in actual_results
|
|
233
|
+
|
|
234
|
+
def test_download_project_use_name(self, capsys):
|
|
235
|
+
comet_path = "%s/%s" % (self.WORKSPACE, self.PROJECT_NAME)
|
|
236
|
+
self.DIR = tempfile.mkdtemp()
|
|
237
|
+
results = [
|
|
238
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
239
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/metrics.jsonl"),
|
|
240
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/metadata.json"),
|
|
241
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/parameters.json"),
|
|
242
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/others.jsonl"),
|
|
243
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/system_details.json"),
|
|
244
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/run/script.py"),
|
|
245
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/assets/assets_metadata.jsonl"),
|
|
246
|
+
self.make_path(
|
|
247
|
+
"{dir}/{ws}/{proj}/{ename}/assets/model-element/model/keras_module.txt"
|
|
248
|
+
),
|
|
249
|
+
self.make_path(
|
|
250
|
+
"{dir}/{ws}/{proj}/{ename}/assets/model-element/model/model.h5"
|
|
251
|
+
),
|
|
252
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/assets/asset/model.h5"),
|
|
253
|
+
self.make_path("{dir}/{ws}/{proj}/{ename}/assets/asset/keras_module.txt"),
|
|
254
|
+
]
|
|
255
|
+
output = self.download(comet_path, capsys, output=self.DIR, use_name=True)
|
|
256
|
+
assert len(output) > 0
|
|
257
|
+
actual_results = command(["find", self.DIR])
|
|
258
|
+
for result in results:
|
|
259
|
+
assert result in actual_results
|
|
260
|
+
|
|
261
|
+
@patch("comet_ml.APIExperiment.get_model_graph")
|
|
262
|
+
@patch("comet_ml.APIExperiment.get_output")
|
|
263
|
+
@patch("comet_ml.APIExperiment.get_html")
|
|
264
|
+
def test_download_experiment_id(self, mock_html, mock_output, mock_graph, capsys):
|
|
265
|
+
mock_html.return_value = "<b>This is HTML</b>"
|
|
266
|
+
mock_output.return_value = "This is output"
|
|
267
|
+
mock_graph.return_value = "This the the model graph"
|
|
268
|
+
|
|
269
|
+
comet_path = "%s/%s/%s" % (
|
|
270
|
+
self.WORKSPACE,
|
|
271
|
+
self.PROJECT_NAME,
|
|
272
|
+
self.EXPERIMENT_ID,
|
|
273
|
+
)
|
|
274
|
+
self.DIR = tempfile.mkdtemp()
|
|
275
|
+
results = [
|
|
276
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metrics.jsonl"),
|
|
277
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metadata.json"),
|
|
278
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/parameters.json"),
|
|
279
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/others.jsonl"),
|
|
280
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/system_details.json"),
|
|
281
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/script.py"),
|
|
282
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/assets_metadata.jsonl"),
|
|
283
|
+
self.make_path(
|
|
284
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/keras_module.txt"
|
|
285
|
+
),
|
|
286
|
+
self.make_path(
|
|
287
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/model.h5"
|
|
288
|
+
),
|
|
289
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/model.h5"),
|
|
290
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/keras_module.txt"),
|
|
291
|
+
# Via mock:
|
|
292
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/html/experiment.html"),
|
|
293
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/output.txt"),
|
|
294
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/graph_definition.txt"),
|
|
295
|
+
]
|
|
296
|
+
not_results = [
|
|
297
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
298
|
+
]
|
|
299
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
300
|
+
assert len(output) > 0
|
|
301
|
+
actual_results = command(["find", self.DIR])
|
|
302
|
+
for result in results:
|
|
303
|
+
assert result in actual_results
|
|
304
|
+
for result in not_results:
|
|
305
|
+
assert result not in actual_results
|
|
306
|
+
|
|
307
|
+
def test_download_experiment_id_alone(self, capsys):
|
|
308
|
+
comet_path = "%s" % (self.EXPERIMENT_ID,)
|
|
309
|
+
self.DIR = tempfile.mkdtemp()
|
|
310
|
+
results = [
|
|
311
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metrics.jsonl"),
|
|
312
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metadata.json"),
|
|
313
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/parameters.json"),
|
|
314
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/others.jsonl"),
|
|
315
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/system_details.json"),
|
|
316
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/script.py"),
|
|
317
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/assets_metadata.jsonl"),
|
|
318
|
+
self.make_path(
|
|
319
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/keras_module.txt"
|
|
320
|
+
),
|
|
321
|
+
self.make_path(
|
|
322
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/model.h5"
|
|
323
|
+
),
|
|
324
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/model.h5"),
|
|
325
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/keras_module.txt"),
|
|
326
|
+
]
|
|
327
|
+
not_results = [
|
|
328
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
329
|
+
]
|
|
330
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
331
|
+
assert len(output) > 0
|
|
332
|
+
actual_results = command(["find", self.DIR])
|
|
333
|
+
for result in results:
|
|
334
|
+
assert result in actual_results
|
|
335
|
+
for result in not_results:
|
|
336
|
+
assert result not in actual_results
|
|
337
|
+
|
|
338
|
+
def test_download_experiment_name(self, capsys):
|
|
339
|
+
comet_path = "%s/%s/%s" % (
|
|
340
|
+
self.WORKSPACE,
|
|
341
|
+
self.PROJECT_NAME,
|
|
342
|
+
self.EXPERIMENT_NAME,
|
|
343
|
+
)
|
|
344
|
+
self.DIR = tempfile.mkdtemp()
|
|
345
|
+
results = [
|
|
346
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metrics.jsonl"),
|
|
347
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metadata.json"),
|
|
348
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/parameters.json"),
|
|
349
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/others.jsonl"),
|
|
350
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/system_details.json"),
|
|
351
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/script.py"),
|
|
352
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/assets_metadata.jsonl"),
|
|
353
|
+
self.make_path(
|
|
354
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/keras_module.txt"
|
|
355
|
+
),
|
|
356
|
+
self.make_path(
|
|
357
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/model.h5"
|
|
358
|
+
),
|
|
359
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/model.h5"),
|
|
360
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/keras_module.txt"),
|
|
361
|
+
]
|
|
362
|
+
not_results = [
|
|
363
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
364
|
+
]
|
|
365
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
366
|
+
assert len(output) > 0
|
|
367
|
+
actual_results = command(["find", self.DIR])
|
|
368
|
+
for result in results:
|
|
369
|
+
assert result in actual_results
|
|
370
|
+
for result in not_results:
|
|
371
|
+
assert result not in actual_results
|
|
372
|
+
|
|
373
|
+
def test_download_experiment_flat(self, capsys):
|
|
374
|
+
comet_path = "%s/%s/%s" % (
|
|
375
|
+
self.WORKSPACE,
|
|
376
|
+
self.PROJECT_NAME,
|
|
377
|
+
self.EXPERIMENT_ID,
|
|
378
|
+
)
|
|
379
|
+
self.DIR = tempfile.mkdtemp()
|
|
380
|
+
results = [
|
|
381
|
+
self.make_path("{dir}/assets_metadata.jsonl"),
|
|
382
|
+
self.make_path("{dir}/script.py"),
|
|
383
|
+
self.make_path("{dir}/keras_module.txt"),
|
|
384
|
+
self.make_path("{dir}/metadata.json"),
|
|
385
|
+
self.make_path("{dir}/metrics.jsonl"),
|
|
386
|
+
self.make_path("{dir}/model/keras_module.txt"),
|
|
387
|
+
self.make_path("{dir}/model/model.h5"),
|
|
388
|
+
self.make_path("{dir}/model.h5"),
|
|
389
|
+
self.make_path("{dir}/others.jsonl"),
|
|
390
|
+
self.make_path("{dir}/parameters.json"),
|
|
391
|
+
self.make_path("{dir}/system_details.json"),
|
|
392
|
+
]
|
|
393
|
+
output = self.download(comet_path, capsys, output=self.DIR, flat=True)
|
|
394
|
+
assert len(output) > 0
|
|
395
|
+
actual_results = command(["find", self.DIR])
|
|
396
|
+
for result in results:
|
|
397
|
+
assert result in actual_results
|
|
398
|
+
|
|
399
|
+
def test_download_experiment_flat_ignore(self, capsys):
|
|
400
|
+
comet_path = "%s/%s/%s" % (
|
|
401
|
+
self.WORKSPACE,
|
|
402
|
+
self.PROJECT_NAME,
|
|
403
|
+
self.EXPERIMENT_ID,
|
|
404
|
+
)
|
|
405
|
+
self.DIR = tempfile.mkdtemp()
|
|
406
|
+
results = [
|
|
407
|
+
self.make_path("{dir}/assets_metadata.jsonl"),
|
|
408
|
+
self.make_path("{dir}/keras_module.txt"),
|
|
409
|
+
self.make_path("{dir}/metadata.json"),
|
|
410
|
+
self.make_path("{dir}/metrics.jsonl"),
|
|
411
|
+
self.make_path("{dir}/model/keras_module.txt"),
|
|
412
|
+
self.make_path("{dir}/model/model.h5"),
|
|
413
|
+
self.make_path("{dir}/model.h5"),
|
|
414
|
+
self.make_path("{dir}/others.jsonl"),
|
|
415
|
+
self.make_path("{dir}/parameters.json"),
|
|
416
|
+
self.make_path("{dir}/system_details.json"),
|
|
417
|
+
]
|
|
418
|
+
not_results = [
|
|
419
|
+
self.make_path("{dir}/script.py"),
|
|
420
|
+
]
|
|
421
|
+
output = self.download(
|
|
422
|
+
comet_path,
|
|
423
|
+
capsys,
|
|
424
|
+
output=self.DIR,
|
|
425
|
+
flat=True,
|
|
426
|
+
ignore=["code"],
|
|
427
|
+
)
|
|
428
|
+
assert len(output) > 0
|
|
429
|
+
actual_results = command(["find", self.DIR])
|
|
430
|
+
for result in results:
|
|
431
|
+
assert result in actual_results
|
|
432
|
+
for result in not_results:
|
|
433
|
+
assert result not in actual_results
|
|
434
|
+
|
|
435
|
+
def test_download_model(self, capsys):
|
|
436
|
+
comet_path = "%s/model-registry/%s" % (
|
|
437
|
+
self.WORKSPACE,
|
|
438
|
+
self.MODEL_NAME,
|
|
439
|
+
)
|
|
440
|
+
self.DIR = tempfile.mkdtemp()
|
|
441
|
+
results = [
|
|
442
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/keras_module.txt"),
|
|
443
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/model.h5"),
|
|
444
|
+
]
|
|
445
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
446
|
+
assert len(output) > 0
|
|
447
|
+
actual_results = command(["find", self.DIR])
|
|
448
|
+
for result in results:
|
|
449
|
+
assert result in actual_results
|
|
450
|
+
|
|
451
|
+
def test_download_model_version(self, capsys):
|
|
452
|
+
comet_path = "%s/model-registry/%s/1.0.0" % (
|
|
453
|
+
self.WORKSPACE,
|
|
454
|
+
self.MODEL_NAME,
|
|
455
|
+
)
|
|
456
|
+
self.DIR = tempfile.mkdtemp()
|
|
457
|
+
results = [
|
|
458
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/keras_module.txt"),
|
|
459
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/model.h5"),
|
|
460
|
+
]
|
|
461
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
462
|
+
assert len(output) > 0
|
|
463
|
+
actual_results = command(["find", self.DIR])
|
|
464
|
+
for result in results:
|
|
465
|
+
assert result in actual_results
|
|
466
|
+
|
|
467
|
+
def test_download_model_tag(self, capsys):
|
|
468
|
+
comet_path = "%s/model-registry/%s/production" % (
|
|
469
|
+
self.WORKSPACE,
|
|
470
|
+
self.MODEL_NAME,
|
|
471
|
+
)
|
|
472
|
+
self.DIR = tempfile.mkdtemp()
|
|
473
|
+
results = [
|
|
474
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/keras_module.txt"),
|
|
475
|
+
self.make_path("{dir}/{ws}/model-registry/{mname}/model/model.h5"),
|
|
476
|
+
]
|
|
477
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
478
|
+
assert len(output) > 0
|
|
479
|
+
actual_results = command(["find", self.DIR])
|
|
480
|
+
for result in results:
|
|
481
|
+
assert result in actual_results
|
|
482
|
+
|
|
483
|
+
def test_download_artifact(self, capsys):
|
|
484
|
+
comet_path = "%s/artifacts/%s" % (
|
|
485
|
+
self.WORKSPACE,
|
|
486
|
+
self.ARTIFACT_NAME,
|
|
487
|
+
)
|
|
488
|
+
self.DIR = tempfile.mkdtemp()
|
|
489
|
+
results = [
|
|
490
|
+
self.make_path("{dir}/{ws}/artifacts/{aname}/keras_module.txt"),
|
|
491
|
+
]
|
|
492
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
493
|
+
assert len(output) > 0
|
|
494
|
+
actual_results = command(["find", self.DIR])
|
|
495
|
+
for result in results:
|
|
496
|
+
assert result in actual_results
|
|
497
|
+
|
|
498
|
+
def test_download_artifact_latest(self, capsys):
|
|
499
|
+
comet_path = "%s/artifacts/%s/latest" % (
|
|
500
|
+
self.WORKSPACE,
|
|
501
|
+
self.ARTIFACT_NAME,
|
|
502
|
+
)
|
|
503
|
+
self.DIR = tempfile.mkdtemp()
|
|
504
|
+
results = [
|
|
505
|
+
self.make_path("{dir}/{ws}/artifacts/{aname}/keras_module.txt"),
|
|
506
|
+
]
|
|
507
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
508
|
+
assert len(output) > 0
|
|
509
|
+
actual_results = command(["find", self.DIR])
|
|
510
|
+
for result in results:
|
|
511
|
+
assert result in actual_results
|
|
512
|
+
|
|
513
|
+
@patch("comet_ml.API.get_projects")
|
|
514
|
+
def test_download_workspace(self, mock_get_projects, capsys):
|
|
515
|
+
# Fake it, so we don't download all of self.USER
|
|
516
|
+
# but just this one project
|
|
517
|
+
mock_get_projects.return_value = [self.PROJECT_NAME]
|
|
518
|
+
|
|
519
|
+
comet_path = "%s" % (self.WORKSPACE,)
|
|
520
|
+
self.DIR = tempfile.mkdtemp()
|
|
521
|
+
results = [
|
|
522
|
+
self.make_path("{dir}/{ws}/{proj}/project_metadata.json"),
|
|
523
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metrics.jsonl"),
|
|
524
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/metadata.json"),
|
|
525
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/parameters.json"),
|
|
526
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/others.jsonl"),
|
|
527
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/system_details.json"),
|
|
528
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/script.py"),
|
|
529
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/assets_metadata.jsonl"),
|
|
530
|
+
self.make_path(
|
|
531
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/keras_module.txt"
|
|
532
|
+
),
|
|
533
|
+
self.make_path(
|
|
534
|
+
"{dir}/{ws}/{proj}/{exp}/assets/model-element/model/model.h5"
|
|
535
|
+
),
|
|
536
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/model.h5"),
|
|
537
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/assets/asset/keras_module.txt"),
|
|
538
|
+
]
|
|
539
|
+
output = self.download(comet_path, capsys, output=self.DIR)
|
|
540
|
+
assert len(output) > 0
|
|
541
|
+
actual_results = command(["find", self.DIR])
|
|
542
|
+
for result in results:
|
|
543
|
+
assert result in actual_results
|
|
544
|
+
|
|
545
|
+
@patch("comet_ml.APIExperiment.get_git_patch")
|
|
546
|
+
@patch("comet_ml.APIExperiment.get_git_metadata")
|
|
547
|
+
def test_download_git(self, mock_get_git_metadata, mock_get_git_patch, capsys):
|
|
548
|
+
|
|
549
|
+
mock_get_git_patch.return_value = DIFF_CONTENTS
|
|
550
|
+
mock_get_git_metadata.return_value = {
|
|
551
|
+
"user": self.USER,
|
|
552
|
+
"root": "e16d344d042fda7e02cdefe337063bd902281962",
|
|
553
|
+
"branch": "refs/heads/%s/branch-name" % self.USER,
|
|
554
|
+
"parent": "0e9752d81146f299d344de2b6ac653c5cc601de2",
|
|
555
|
+
"origin": "git@github.com:%s/repo-name" % self.USER,
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
comet_path = "%s/%s/%s" % (
|
|
559
|
+
self.WORKSPACE,
|
|
560
|
+
self.PROJECT_NAME,
|
|
561
|
+
self.EXPERIMENT_ID,
|
|
562
|
+
)
|
|
563
|
+
self.DIR = tempfile.mkdtemp()
|
|
564
|
+
results = [
|
|
565
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/git_diff.patch"),
|
|
566
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/git_metadata.json"),
|
|
567
|
+
self.make_path("{dir}/{ws}/{proj}/{exp}/run/README.md"),
|
|
568
|
+
]
|
|
569
|
+
output = self.download(comet_path, capsys, include=["git"], output=self.DIR)
|
|
570
|
+
assert len(output) > 0
|
|
571
|
+
actual_results = command(["find", self.DIR])
|
|
572
|
+
for result in results:
|
|
573
|
+
assert result in actual_results
|
|
574
|
+
|
|
575
|
+
def test_download_cli(self, capsys):
|
|
576
|
+
comet_path = "%s/%s" % (self.WORKSPACE, self.PROJECT_NAME)
|
|
577
|
+
with environ({"COMET_API_KEY": self.API_KEY}):
|
|
578
|
+
main([comet_path, "--list"])
|
|
579
|
+
captured = capsys.readouterr()
|
|
580
|
+
results = ["%s/%s/%s" % (self.WORKSPACE, self.PROJECT_NAME, self.EXPERIMENT_ID)]
|
|
581
|
+
output = captured.out.strip().split("\n")
|
|
582
|
+
for result in results:
|
|
583
|
+
assert result in output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|