abidlabs HF Staff commited on
Commit
6e6d706
·
verified ·
1 Parent(s): 9dfe97e

Upload folder using huggingface_hub

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. __init__.py +258 -0
  3. __pycache__/__init__.cpython-310.pyc +0 -0
  4. __pycache__/__init__.cpython-311.pyc +0 -0
  5. __pycache__/__init__.cpython-312.pyc +0 -0
  6. __pycache__/api.cpython-312.pyc +0 -0
  7. __pycache__/cli.cpython-311.pyc +0 -0
  8. __pycache__/cli.cpython-312.pyc +0 -0
  9. __pycache__/commit_scheduler.cpython-311.pyc +0 -0
  10. __pycache__/commit_scheduler.cpython-312.pyc +0 -0
  11. __pycache__/context.cpython-312.pyc +0 -0
  12. __pycache__/context_vars.cpython-311.pyc +0 -0
  13. __pycache__/context_vars.cpython-312.pyc +0 -0
  14. __pycache__/deploy.cpython-310.pyc +0 -0
  15. __pycache__/deploy.cpython-311.pyc +0 -0
  16. __pycache__/deploy.cpython-312.pyc +0 -0
  17. __pycache__/dummy_commit_scheduler.cpython-310.pyc +0 -0
  18. __pycache__/dummy_commit_scheduler.cpython-311.pyc +0 -0
  19. __pycache__/dummy_commit_scheduler.cpython-312.pyc +0 -0
  20. __pycache__/file_storage.cpython-311.pyc +0 -0
  21. __pycache__/file_storage.cpython-312.pyc +0 -0
  22. __pycache__/imports.cpython-311.pyc +0 -0
  23. __pycache__/imports.cpython-312.pyc +0 -0
  24. __pycache__/media.cpython-311.pyc +0 -0
  25. __pycache__/media.cpython-312.pyc +0 -0
  26. __pycache__/run.cpython-310.pyc +0 -0
  27. __pycache__/run.cpython-311.pyc +0 -0
  28. __pycache__/run.cpython-312.pyc +0 -0
  29. __pycache__/sqlite_storage.cpython-310.pyc +0 -0
  30. __pycache__/sqlite_storage.cpython-311.pyc +0 -0
  31. __pycache__/sqlite_storage.cpython-312.pyc +0 -0
  32. __pycache__/storage.cpython-312.pyc +0 -0
  33. __pycache__/table.cpython-311.pyc +0 -0
  34. __pycache__/table.cpython-312.pyc +0 -0
  35. __pycache__/typehints.cpython-311.pyc +0 -0
  36. __pycache__/typehints.cpython-312.pyc +0 -0
  37. __pycache__/types.cpython-312.pyc +0 -0
  38. __pycache__/ui.cpython-310.pyc +0 -0
  39. __pycache__/ui.cpython-311.pyc +0 -0
  40. __pycache__/ui.cpython-312.pyc +0 -0
  41. __pycache__/utils.cpython-310.pyc +0 -0
  42. __pycache__/utils.cpython-311.pyc +0 -0
  43. __pycache__/utils.cpython-312.pyc +0 -0
  44. assets/trackio_logo_dark.png +0 -0
  45. assets/trackio_logo_light.png +0 -0
  46. assets/trackio_logo_old.png +3 -0
  47. assets/trackio_logo_type_dark.png +0 -0
  48. assets/trackio_logo_type_dark_transparent.png +0 -0
  49. assets/trackio_logo_type_light.png +0 -0
  50. assets/trackio_logo_type_light_transparent.png +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/trackio_logo_old.png filter=lfs diff=lfs merge=lfs -text
__init__.py ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import os
3
+ import warnings
4
+ import webbrowser
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from gradio.blocks import BUILT_IN_THEMES
9
+ from gradio.themes import Default as DefaultTheme
10
+ from gradio.themes import ThemeClass
11
+ from gradio_client import Client
12
+
13
+ from trackio import context_vars, deploy, utils
14
+ from trackio.imports import import_csv, import_tf_events
15
+ from trackio.media import TrackioImage
16
+ from trackio.run import Run
17
+ from trackio.sqlite_storage import SQLiteStorage
18
+ from trackio.table import Table
19
+ from trackio.ui import demo
20
+ from trackio.utils import TRACKIO_DIR, TRACKIO_LOGO_DIR
21
+
22
+ __version__ = Path(__file__).parent.joinpath("version.txt").read_text().strip()
23
+
24
+ __all__ = [
25
+ "init",
26
+ "log",
27
+ "finish",
28
+ "show",
29
+ "import_csv",
30
+ "import_tf_events",
31
+ "Image",
32
+ "Table",
33
+ ]
34
+
35
+ Image = TrackioImage
36
+
37
+
38
+ config = {}
39
+
40
+ DEFAULT_THEME = "citrus"
41
+
42
+
43
+ def init(
44
+ project: str,
45
+ name: str | None = None,
46
+ space_id: str | None = None,
47
+ dataset_id: str | None = None,
48
+ config: dict | None = None,
49
+ resume: str = "never",
50
+ settings: Any = None,
51
+ ) -> Run:
52
+ """
53
+ Creates a new Trackio project and returns a [`Run`] object.
54
+
55
+ Args:
56
+ project (`str`):
57
+ The name of the project (can be an existing project to continue tracking or
58
+ a new project to start tracking from scratch).
59
+ name (`str` or `None`, *optional*, defaults to `None`):
60
+ The name of the run (if not provided, a default name will be generated).
61
+ space_id (`str` or `None`, *optional*, defaults to `None`):
62
+ If provided, the project will be logged to a Hugging Face Space instead of
63
+ a local directory. Should be a complete Space name like
64
+ `"username/reponame"` or `"orgname/reponame"`, or just `"reponame"` in which
65
+ case the Space will be created in the currently-logged-in Hugging Face
66
+ user's namespace. If the Space does not exist, it will be created. If the
67
+ Space already exists, the project will be logged to it.
68
+ dataset_id (`str` or `None`, *optional*, defaults to `None`):
69
+ If a `space_id` is provided, a persistent Hugging Face Dataset will be
70
+ created and the metrics will be synced to it every 5 minutes. Specify a
71
+ Dataset with name like `"username/datasetname"` or `"orgname/datasetname"`,
72
+ or `"datasetname"` (uses currently-logged-in Hugging Face user's namespace),
73
+ or `None` (uses the same name as the Space but with the `"_dataset"`
74
+ suffix). If the Dataset does not exist, it will be created. If the Dataset
75
+ already exists, the project will be appended to it.
76
+ config (`dict` or `None`, *optional*, defaults to `None`):
77
+ A dictionary of configuration options. Provided for compatibility with
78
+ `wandb.init()`.
79
+ resume (`str`, *optional*, defaults to `"never"`):
80
+ Controls how to handle resuming a run. Can be one of:
81
+
82
+ - `"must"`: Must resume the run with the given name, raises error if run
83
+ doesn't exist
84
+ - `"allow"`: Resume the run if it exists, otherwise create a new run
85
+ - `"never"`: Never resume a run, always create a new one
86
+ settings (`Any`, *optional*, defaults to `None`):
87
+ Not used. Provided for compatibility with `wandb.init()`.
88
+
89
+ Returns:
90
+ `Run`: A [`Run`] object that can be used to log metrics and finish the run.
91
+ """
92
+ if settings is not None:
93
+ warnings.warn(
94
+ "* Warning: settings is not used. Provided for compatibility with wandb.init(). Please create an issue at: https://github.com/gradio-app/trackio/issues if you need a specific feature implemented."
95
+ )
96
+
97
+ if space_id is None and dataset_id is not None:
98
+ raise ValueError("Must provide a `space_id` when `dataset_id` is provided.")
99
+ space_id, dataset_id = utils.preprocess_space_and_dataset_ids(space_id, dataset_id)
100
+ url = context_vars.current_server.get()
101
+
102
+ if url is None:
103
+ if space_id is None:
104
+ _, url, _ = demo.launch(
105
+ show_api=False,
106
+ inline=False,
107
+ quiet=True,
108
+ prevent_thread_lock=True,
109
+ show_error=True,
110
+ )
111
+ else:
112
+ url = space_id
113
+ context_vars.current_server.set(url)
114
+
115
+ if (
116
+ context_vars.current_project.get() is None
117
+ or context_vars.current_project.get() != project
118
+ ):
119
+ print(f"* Trackio project initialized: {project}")
120
+
121
+ if dataset_id is not None:
122
+ os.environ["TRACKIO_DATASET_ID"] = dataset_id
123
+ print(
124
+ f"* Trackio metrics will be synced to Hugging Face Dataset: {dataset_id}"
125
+ )
126
+ if space_id is None:
127
+ print(f"* Trackio metrics logged to: {TRACKIO_DIR}")
128
+ utils.print_dashboard_instructions(project)
129
+ else:
130
+ deploy.create_space_if_not_exists(space_id, dataset_id)
131
+ print(
132
+ f"* View dashboard by going to: {deploy.SPACE_URL.format(space_id=space_id)}"
133
+ )
134
+ context_vars.current_project.set(project)
135
+
136
+ client = None
137
+ if not space_id:
138
+ client = Client(url, verbose=False)
139
+
140
+ if resume == "must":
141
+ if name is None:
142
+ raise ValueError("Must provide a run name when resume='must'")
143
+ if name not in SQLiteStorage.get_runs(project):
144
+ raise ValueError(f"Run '{name}' does not exist in project '{project}'")
145
+ resumed = True
146
+ elif resume == "allow":
147
+ resumed = name is not None and name in SQLiteStorage.get_runs(project)
148
+ elif resume == "never":
149
+ if name is not None and name in SQLiteStorage.get_runs(project):
150
+ warnings.warn(
151
+ f"* Warning: resume='never' but a run '{name}' already exists in "
152
+ f"project '{project}'. Generating a new name and instead. If you want "
153
+ "to resume this run, call init() with resume='must' or resume='allow'."
154
+ )
155
+ name = None
156
+ resumed = False
157
+ else:
158
+ raise ValueError("resume must be one of: 'must', 'allow', or 'never'")
159
+
160
+ run = Run(
161
+ url=url,
162
+ project=project,
163
+ client=client,
164
+ name=name,
165
+ config=config,
166
+ space_id=space_id,
167
+ )
168
+
169
+ if resumed:
170
+ print(f"* Resumed existing run: {run.name}")
171
+ else:
172
+ print(f"* Created new run: {run.name}")
173
+
174
+ context_vars.current_run.set(run)
175
+ globals()["config"] = run.config
176
+ return run
177
+
178
+
179
+ def log(metrics: dict, step: int | None = None) -> None:
180
+ """
181
+ Logs metrics to the current run.
182
+
183
+ Args:
184
+ metrics (`dict`):
185
+ A dictionary of metrics to log.
186
+ step (`int` or `None`, *optional*, defaults to `None`):
187
+ The step number. If not provided, the step will be incremented
188
+ automatically.
189
+ """
190
+ run = context_vars.current_run.get()
191
+ if run is None:
192
+ raise RuntimeError("Call trackio.init() before trackio.log().")
193
+ run.log(
194
+ metrics=metrics,
195
+ step=step,
196
+ )
197
+
198
+
199
+ def finish():
200
+ """
201
+ Finishes the current run.
202
+ """
203
+ run = context_vars.current_run.get()
204
+ if run is None:
205
+ raise RuntimeError("Call trackio.init() before trackio.finish().")
206
+ run.finish()
207
+
208
+
209
+ def show(project: str | None = None, theme: str | ThemeClass = DEFAULT_THEME):
210
+ """
211
+ Launches the Trackio dashboard.
212
+
213
+ Args:
214
+ project (`str` or `None`, *optional*, defaults to `None`):
215
+ The name of the project whose runs to show. If not provided, all projects
216
+ will be shown and the user can select one.
217
+ theme (`str` or `ThemeClass`, *optional*, defaults to `"citrus"`):
218
+ A Gradio Theme to use for the dashboard instead of the default `"citrus"`,
219
+ can be a built-in theme (e.g. `'soft'`, `'default'`), a theme from the Hub
220
+ (e.g. `"gstaff/xkcd"`), or a custom Theme class.
221
+ """
222
+ if theme != DEFAULT_THEME:
223
+ # TODO: It's a little hacky to reproduce this theme-setting logic from Gradio Blocks,
224
+ # but in Gradio 6.0, the theme will be set in `launch()` instead, which means that we
225
+ # will be able to remove this code.
226
+ if isinstance(theme, str):
227
+ if theme.lower() in BUILT_IN_THEMES:
228
+ theme = BUILT_IN_THEMES[theme.lower()]
229
+ else:
230
+ try:
231
+ theme = ThemeClass.from_hub(theme)
232
+ except Exception as e:
233
+ warnings.warn(f"Cannot load {theme}. Caught Exception: {str(e)}")
234
+ theme = DefaultTheme()
235
+ if not isinstance(theme, ThemeClass):
236
+ warnings.warn("Theme should be a class loaded from gradio.themes")
237
+ theme = DefaultTheme()
238
+ demo.theme: ThemeClass = theme
239
+ demo.theme_css = theme._get_theme_css()
240
+ demo.stylesheets = theme._stylesheets
241
+ theme_hasher = hashlib.sha256()
242
+ theme_hasher.update(demo.theme_css.encode("utf-8"))
243
+ demo.theme_hash = theme_hasher.hexdigest()
244
+
245
+ _, url, share_url = demo.launch(
246
+ show_api=False,
247
+ quiet=True,
248
+ inline=False,
249
+ prevent_thread_lock=True,
250
+ favicon_path=TRACKIO_LOGO_DIR / "trackio_logo_light.png",
251
+ allowed_paths=[TRACKIO_LOGO_DIR],
252
+ )
253
+
254
+ base_url = share_url + "/" if share_url else url
255
+ dashboard_url = base_url + f"?project={project}" if project else base_url
256
+ print(f"* Trackio UI launched at: {dashboard_url}")
257
+ webbrowser.open(dashboard_url)
258
+ utils.block_except_in_notebook()
__pycache__/__init__.cpython-310.pyc ADDED
Binary file (4.96 kB). View file
 
__pycache__/__init__.cpython-311.pyc ADDED
Binary file (12.2 kB). View file
 
__pycache__/__init__.cpython-312.pyc ADDED
Binary file (11.3 kB). View file
 
__pycache__/api.cpython-312.pyc ADDED
Binary file (4.56 kB). View file
 
__pycache__/cli.cpython-311.pyc ADDED
Binary file (1.57 kB). View file
 
__pycache__/cli.cpython-312.pyc ADDED
Binary file (1.43 kB). View file
 
__pycache__/commit_scheduler.cpython-311.pyc ADDED
Binary file (20.4 kB). View file
 
__pycache__/commit_scheduler.cpython-312.pyc ADDED
Binary file (18.8 kB). View file
 
__pycache__/context.cpython-312.pyc ADDED
Binary file (440 Bytes). View file
 
__pycache__/context_vars.cpython-311.pyc ADDED
Binary file (840 Bytes). View file
 
__pycache__/context_vars.cpython-312.pyc ADDED
Binary file (763 Bytes). View file
 
__pycache__/deploy.cpython-310.pyc ADDED
Binary file (1.72 kB). View file
 
__pycache__/deploy.cpython-311.pyc ADDED
Binary file (8.93 kB). View file
 
__pycache__/deploy.cpython-312.pyc ADDED
Binary file (8 kB). View file
 
__pycache__/dummy_commit_scheduler.cpython-310.pyc ADDED
Binary file (936 Bytes). View file
 
__pycache__/dummy_commit_scheduler.cpython-311.pyc ADDED
Binary file (1.19 kB). View file
 
__pycache__/dummy_commit_scheduler.cpython-312.pyc ADDED
Binary file (1.01 kB). View file
 
__pycache__/file_storage.cpython-311.pyc ADDED
Binary file (3.14 kB). View file
 
__pycache__/file_storage.cpython-312.pyc ADDED
Binary file (2.77 kB). View file
 
__pycache__/imports.cpython-311.pyc ADDED
Binary file (13.8 kB). View file
 
__pycache__/imports.cpython-312.pyc ADDED
Binary file (12.8 kB). View file
 
__pycache__/media.cpython-311.pyc ADDED
Binary file (6.39 kB). View file
 
__pycache__/media.cpython-312.pyc ADDED
Binary file (5.78 kB). View file
 
__pycache__/run.cpython-310.pyc ADDED
Binary file (1.01 kB). View file
 
__pycache__/run.cpython-311.pyc ADDED
Binary file (8.17 kB). View file
 
__pycache__/run.cpython-312.pyc ADDED
Binary file (7.41 kB). View file
 
__pycache__/sqlite_storage.cpython-310.pyc ADDED
Binary file (5.37 kB). View file
 
__pycache__/sqlite_storage.cpython-311.pyc ADDED
Binary file (22.4 kB). View file
 
__pycache__/sqlite_storage.cpython-312.pyc ADDED
Binary file (18.8 kB). View file
 
__pycache__/storage.cpython-312.pyc ADDED
Binary file (4.6 kB). View file
 
__pycache__/table.cpython-311.pyc ADDED
Binary file (2.7 kB). View file
 
__pycache__/table.cpython-312.pyc ADDED
Binary file (2.47 kB). View file
 
__pycache__/typehints.cpython-311.pyc ADDED
Binary file (1.06 kB). View file
 
__pycache__/typehints.cpython-312.pyc ADDED
Binary file (855 Bytes). View file
 
__pycache__/types.cpython-312.pyc ADDED
Binary file (531 Bytes). View file
 
__pycache__/ui.cpython-310.pyc ADDED
Binary file (7.83 kB). View file
 
__pycache__/ui.cpython-311.pyc ADDED
Binary file (34.9 kB). View file
 
__pycache__/ui.cpython-312.pyc ADDED
Binary file (30.2 kB). View file
 
__pycache__/utils.cpython-310.pyc ADDED
Binary file (2.62 kB). View file
 
__pycache__/utils.cpython-311.pyc ADDED
Binary file (17 kB). View file
 
__pycache__/utils.cpython-312.pyc ADDED
Binary file (15.4 kB). View file
 
assets/trackio_logo_dark.png ADDED
assets/trackio_logo_light.png ADDED
assets/trackio_logo_old.png ADDED

Git LFS Details

  • SHA256: 3922c4d1e465270ad4d8abb12023f3beed5d9f7f338528a4c0ac21dcf358a1c8
  • Pointer size: 131 Bytes
  • Size of remote file: 487 kB
assets/trackio_logo_type_dark.png ADDED
assets/trackio_logo_type_dark_transparent.png ADDED
assets/trackio_logo_type_light.png ADDED
assets/trackio_logo_type_light_transparent.png ADDED