abidlabs HF Staff commited on
Commit
7d79917
·
verified ·
1 Parent(s): 77cc3c9

Upload folder using huggingface_hub

Browse files
.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
+ trackio_logo.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,12 +1,5 @@
1
  ---
2
- title: Ttt2
3
- emoji: 👀
4
- colorFrom: pink
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 5.30.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
 
 
 
 
2
  sdk: gradio
3
  sdk_version: 5.30.0
4
+ app_file: ui.py
5
+ ---
 
 
 
__init__.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import contextvars
2
+ import time
3
+ import webbrowser
4
+ from pathlib import Path
5
+
6
+ from gradio_client import Client
7
+ from httpx import ReadTimeout
8
+ from huggingface_hub.errors import RepositoryNotFoundError
9
+
10
+ from trackio.deploy import deploy_as_space
11
+ from trackio.run import Run
12
+ from trackio.ui import demo
13
+ from trackio.utils import TRACKIO_DIR, TRACKIO_LOGO_PATH, block_except_in_notebook
14
+
15
+ __version__ = Path(__file__).parent.joinpath("version.txt").read_text().strip()
16
+
17
+
18
+ current_run: contextvars.ContextVar[Run | None] = contextvars.ContextVar(
19
+ "current_run", default=None
20
+ )
21
+ current_project: contextvars.ContextVar[str | None] = contextvars.ContextVar(
22
+ "current_project", default=None
23
+ )
24
+ current_server: contextvars.ContextVar[str | None] = contextvars.ContextVar(
25
+ "current_server", default=None
26
+ )
27
+
28
+ config = {}
29
+
30
+
31
+ def init(
32
+ project: str, name: str | None = None, space_id=None, config: dict | None = None
33
+ ) -> Run:
34
+ if not current_server.get():
35
+ if space_id is None:
36
+ _, url, _ = demo.launch(
37
+ show_api=False, inline=False, quiet=True, prevent_thread_lock=True
38
+ )
39
+ else:
40
+ url = space_id
41
+ current_server.set(url)
42
+ else:
43
+ url = current_server.get()
44
+
45
+ client = None
46
+ try:
47
+ client = Client(url, verbose=False)
48
+ except RepositoryNotFoundError as e:
49
+ # if we're passed a space_id, ignore the error here, otherwise re-raise it
50
+ if space_id is None:
51
+ raise e
52
+ if client is None and space_id is not None:
53
+ # try to create the space on demand
54
+ deploy_as_space(space_id)
55
+ # try to wait until the Client can initialize
56
+ max_attempts = 30
57
+ attempts = 0
58
+ while client is None:
59
+ try:
60
+ client = Client(space_id, verbose=False)
61
+ except ReadTimeout:
62
+ print("Space is not yet ready. Waiting 5 seconds...")
63
+ time.sleep(5)
64
+ except ValueError as e:
65
+ print(f"Space gave error {e}. Trying again in 5 seconds...")
66
+ time.sleep(5)
67
+ attempts += 1
68
+ if attempts >= max_attempts:
69
+ break
70
+
71
+ if current_project.get() is None or current_project.get() != project:
72
+ print(f"* Trackio project initialized: {project}")
73
+ if space_id is None:
74
+ print(f"* Trackio metrics logged to: {TRACKIO_DIR}")
75
+ print(
76
+ f'\n* View dashboard by running in your terminal: trackio show --project "{project}"'
77
+ )
78
+ print(f'* or by running in Python: trackio.show(project="{project}")')
79
+ else:
80
+ print(
81
+ f"* Trackio metrics logged to: https://huggingface.co/spaces/{space_id}"
82
+ )
83
+ current_project.set(project)
84
+
85
+ run = Run(project=project, client=client, name=name, config=config)
86
+ current_run.set(run)
87
+ globals()["config"] = run.config
88
+ return run
89
+
90
+
91
+ def log(metrics: dict) -> None:
92
+ if current_run.get() is None:
93
+ raise RuntimeError("Call trackio.init() before log().")
94
+ current_run.get().log(metrics)
95
+
96
+
97
+ def finish():
98
+ if current_run.get() is None:
99
+ raise RuntimeError("Call trackio.init() before finish().")
100
+ current_run.get().finish()
101
+
102
+
103
+ def show(project: str | None = None):
104
+ _, url, share_url = demo.launch(
105
+ show_api=False,
106
+ quiet=True,
107
+ inline=False,
108
+ prevent_thread_lock=True,
109
+ favicon_path=TRACKIO_LOGO_PATH,
110
+ allowed_paths=[TRACKIO_LOGO_PATH],
111
+ )
112
+ base_url = share_url + "/" if share_url else url
113
+ dashboard_url = base_url + f"?project={project}" if project else base_url
114
+ print(f"* Trackio UI launched at: {dashboard_url}")
115
+ webbrowser.open(dashboard_url)
116
+ block_except_in_notebook()
__pycache__/__init__.cpython-312.pyc ADDED
Binary file (5.14 kB). View file
 
__pycache__/cli.cpython-312.pyc ADDED
Binary file (1.11 kB). View file
 
__pycache__/context.cpython-312.pyc ADDED
Binary file (440 Bytes). View file
 
__pycache__/deploy.cpython-312.pyc ADDED
Binary file (1.42 kB). View file
 
__pycache__/run.cpython-312.pyc ADDED
Binary file (1.28 kB). View file
 
__pycache__/sqlite_storage.cpython-312.pyc ADDED
Binary file (6.72 kB). View file
 
__pycache__/storage.cpython-312.pyc ADDED
Binary file (4.6 kB). View file
 
__pycache__/ui.cpython-312.pyc ADDED
Binary file (8.2 kB). View file
 
__pycache__/utils.cpython-312.pyc ADDED
Binary file (3.18 kB). View file
 
cli.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+
3
+ from trackio import show
4
+
5
+
6
+ def main():
7
+ parser = argparse.ArgumentParser(description="Trackio CLI")
8
+ subparsers = parser.add_subparsers(dest="command")
9
+
10
+ ui_parser = subparsers.add_parser(
11
+ "show", help="Show the Trackio dashboard UI for a project"
12
+ )
13
+ ui_parser.add_argument(
14
+ "--project", required=False, help="Project name to show in the dashboard"
15
+ )
16
+
17
+ args = parser.parse_args()
18
+
19
+ if args.command == "show":
20
+ show(args.project)
21
+ else:
22
+ parser.print_help()
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
deploy.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from importlib.resources import files
3
+
4
+ import huggingface_hub
5
+
6
+
7
+ def deploy_as_space(title: str):
8
+ if (
9
+ os.getenv("SYSTEM") == "spaces"
10
+ ): # in case a repo with this function is uploaded to spaces
11
+ return
12
+
13
+ trackio_path = files("trackio")
14
+
15
+ hf_api = huggingface_hub.HfApi()
16
+ whoami = None
17
+ login = False
18
+ try:
19
+ whoami = hf_api.whoami()
20
+ if whoami["auth"]["accessToken"]["role"] != "write":
21
+ login = True
22
+ except OSError:
23
+ login = True
24
+ if login:
25
+ print("Need 'write' access token to create a Spaces repo.")
26
+ huggingface_hub.login(add_to_git_credential=False)
27
+ whoami = hf_api.whoami()
28
+
29
+ space_id = huggingface_hub.create_repo(
30
+ title,
31
+ space_sdk="gradio",
32
+ repo_type="space",
33
+ exist_ok=True,
34
+ ).repo_id
35
+ assert space_id == title # not sure why these would differ
36
+
37
+ hf_api.upload_folder(
38
+ repo_id=space_id,
39
+ repo_type="space",
40
+ folder_path=trackio_path,
41
+ )
run.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gradio_client import Client
2
+
3
+ from trackio.utils import generate_readable_name
4
+
5
+
6
+ class Run:
7
+ def __init__(
8
+ self,
9
+ project: str,
10
+ client: Client,
11
+ name: str | None = None,
12
+ config: dict | None = None,
13
+ ):
14
+ self.project = project
15
+ self.client = client
16
+ self.name = name or generate_readable_name()
17
+ self.config = config or {}
18
+
19
+ def log(self, metrics: dict):
20
+ self.client.predict(
21
+ api_name="/log", project=self.project, run=self.name, metrics=metrics
22
+ )
23
+
24
+ def finish(self):
25
+ pass
sqlite_storage.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import sqlite3
4
+
5
+ try:
6
+ from trackio.utils import RESERVED_KEYS, TRACKIO_DIR
7
+ except: # noqa: E722
8
+ from utils import RESERVED_KEYS, TRACKIO_DIR
9
+
10
+
11
+ class SQLiteStorage:
12
+ def __init__(self, project: str, name: str, config: dict):
13
+ self.project = project
14
+ self.name = name
15
+ self.config = config
16
+ self.db_path = os.path.join(TRACKIO_DIR, "trackio.db")
17
+
18
+ os.makedirs(TRACKIO_DIR, exist_ok=True)
19
+
20
+ self._init_db()
21
+ self._save_config()
22
+
23
+ def _init_db(self):
24
+ """Initialize the SQLite database with required tables."""
25
+ with sqlite3.connect(self.db_path) as conn:
26
+ cursor = conn.cursor()
27
+
28
+ cursor.execute("""
29
+ CREATE TABLE IF NOT EXISTS metrics (
30
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
31
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
32
+ project_name TEXT NOT NULL,
33
+ run_name TEXT NOT NULL,
34
+ metrics TEXT NOT NULL
35
+ )
36
+ """)
37
+
38
+ cursor.execute("""
39
+ CREATE TABLE IF NOT EXISTS configs (
40
+ project_name TEXT NOT NULL,
41
+ run_name TEXT NOT NULL,
42
+ config TEXT NOT NULL,
43
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
44
+ PRIMARY KEY (project_name, run_name)
45
+ )
46
+ """)
47
+
48
+ conn.commit()
49
+
50
+ def _save_config(self):
51
+ """Save the run configuration to the database."""
52
+ with sqlite3.connect(self.db_path) as conn:
53
+ cursor = conn.cursor()
54
+ cursor.execute(
55
+ "INSERT OR REPLACE INTO configs (project_name, run_name, config) VALUES (?, ?, ?)",
56
+ (self.project, self.name, json.dumps(self.config)),
57
+ )
58
+ conn.commit()
59
+
60
+ def log(self, metrics: dict):
61
+ """Log metrics to the database."""
62
+ for k in metrics.keys():
63
+ if k in RESERVED_KEYS or k.startswith("__"):
64
+ raise ValueError(
65
+ f"Please do not use this reserved key as a metric: {k}"
66
+ )
67
+
68
+ with sqlite3.connect(self.db_path) as conn:
69
+ cursor = conn.cursor()
70
+ cursor.execute(
71
+ """
72
+ INSERT INTO metrics
73
+ (project_name, run_name, metrics)
74
+ VALUES (?, ?, ?)
75
+ """,
76
+ (self.project, self.name, json.dumps(metrics)),
77
+ )
78
+ conn.commit()
79
+
80
+ def get_metrics(self, project: str, run: str) -> list[dict]:
81
+ """Retrieve metrics for a specific run."""
82
+ with sqlite3.connect(self.db_path) as conn:
83
+ cursor = conn.cursor()
84
+ cursor.execute(
85
+ """
86
+ SELECT timestamp, metrics
87
+ FROM metrics
88
+ WHERE project_name = ? AND run_name = ?
89
+ ORDER BY timestamp
90
+ """,
91
+ (project, run),
92
+ )
93
+ rows = cursor.fetchall()
94
+
95
+ results = []
96
+ for row in rows:
97
+ timestamp, metrics_json = row
98
+ metrics = json.loads(metrics_json)
99
+ metrics["timestamp"] = timestamp
100
+ results.append(metrics)
101
+
102
+ return results
103
+
104
+ def get_projects(self) -> list[str]:
105
+ """Get list of all projects."""
106
+ with sqlite3.connect(self.db_path) as conn:
107
+ cursor = conn.cursor()
108
+ cursor.execute("SELECT DISTINCT project_name FROM metrics")
109
+ return [row[0] for row in cursor.fetchall()]
110
+
111
+ def get_runs(self, project: str) -> list[str]:
112
+ """Get list of all runs for a project."""
113
+ with sqlite3.connect(self.db_path) as conn:
114
+ cursor = conn.cursor()
115
+ cursor.execute(
116
+ "SELECT DISTINCT run_name FROM metrics WHERE project_name = ?",
117
+ (project,),
118
+ )
119
+ return [row[0] for row in cursor.fetchall()]
120
+
121
+ def finish(self):
122
+ """Cleanup when run is finished."""
123
+ pass
trackio_logo.png ADDED

Git LFS Details

  • SHA256: 3922c4d1e465270ad4d8abb12023f3beed5d9f7f338528a4c0ac21dcf358a1c8
  • Pointer size: 131 Bytes
  • Size of remote file: 487 kB
ui.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any
2
+
3
+ import gradio as gr
4
+ import pandas as pd
5
+
6
+ try:
7
+ from trackio.sqlite_storage import SQLiteStorage
8
+ from trackio.utils import RESERVED_KEYS, TRACKIO_LOGO_PATH
9
+ except: # noqa: E722
10
+ from sqlite_storage import SQLiteStorage
11
+ from utils import RESERVED_KEYS, TRACKIO_LOGO_PATH
12
+
13
+
14
+ def get_projects(request: gr.Request):
15
+ storage = SQLiteStorage("", "", {})
16
+ projects = storage.get_projects()
17
+ if project := request.query_params.get("project"):
18
+ interactive = False
19
+ else:
20
+ interactive = True
21
+ project = projects[0] if projects else None
22
+ return gr.Dropdown(
23
+ label="Project",
24
+ choices=projects,
25
+ value=project,
26
+ allow_custom_value=True,
27
+ interactive=interactive,
28
+ )
29
+
30
+
31
+ def get_runs(project):
32
+ if not project:
33
+ return []
34
+ storage = SQLiteStorage("", "", {})
35
+ return storage.get_runs(project)
36
+
37
+
38
+ def load_run_data(project: str | None, run: str | None, smoothing: bool):
39
+ if not project or not run:
40
+ return None
41
+ storage = SQLiteStorage("", "", {})
42
+ metrics = storage.get_metrics(project, run)
43
+ if not metrics:
44
+ return None
45
+ df = pd.DataFrame(metrics)
46
+ if smoothing:
47
+ numeric_cols = df.select_dtypes(include="number").columns
48
+ numeric_cols = [c for c in numeric_cols if c not in RESERVED_KEYS]
49
+ df[numeric_cols] = df[numeric_cols].ewm(alpha=0.1).mean()
50
+ if "step" not in df.columns:
51
+ df["step"] = range(len(df))
52
+ return df
53
+
54
+
55
+ def update_runs(project):
56
+ if project is None:
57
+ runs = []
58
+ else:
59
+ runs = get_runs(project)
60
+ return gr.Dropdown(choices=runs, value=runs)
61
+
62
+
63
+ def toggle_timer(cb_value):
64
+ if cb_value:
65
+ return gr.Timer(active=True)
66
+ else:
67
+ return gr.Timer(active=False)
68
+
69
+
70
+ def log(project: str, run: str, metrics: dict[str, Any]) -> None:
71
+ storage = SQLiteStorage(project, run, {})
72
+ storage.log(metrics)
73
+
74
+
75
+ def configure(request: gr.Request):
76
+ if metrics := request.query_params.get("metrics"):
77
+ return metrics.split(",")
78
+ else:
79
+ return []
80
+
81
+
82
+ with gr.Blocks(theme="citrus", title="Trackio Dashboard") as demo:
83
+ with gr.Sidebar() as sidebar:
84
+ gr.Markdown(
85
+ f"<div style='display: flex; align-items: center; gap: 8px;'><img src='/gradio_api/file={TRACKIO_LOGO_PATH}' width='32' height='32'><span style='font-size: 2em; font-weight: bold;'>Trackio</span></div>"
86
+ )
87
+ project_dd = gr.Dropdown(label="Project", allow_custom_value=True)
88
+ gr.Markdown("### ⚙️ Settings")
89
+ realtime_cb = gr.Checkbox(label="Refresh realtime", value=True)
90
+ smoothing_cb = gr.Checkbox(label="Smoothing", value=True)
91
+ with gr.Row():
92
+ run_dd = gr.Dropdown(label="Run", choices=[], multiselect=True)
93
+
94
+ timer = gr.Timer(value=1)
95
+ metrics_subset = gr.State([])
96
+
97
+ gr.on(
98
+ [demo.load],
99
+ fn=configure,
100
+ outputs=metrics_subset,
101
+ )
102
+ gr.on(
103
+ [demo.load, timer.tick],
104
+ fn=get_projects,
105
+ outputs=project_dd,
106
+ show_progress="hidden",
107
+ )
108
+ gr.on(
109
+ [demo.load, project_dd.change, timer.tick],
110
+ fn=update_runs,
111
+ inputs=project_dd,
112
+ outputs=run_dd,
113
+ show_progress="hidden",
114
+ )
115
+ realtime_cb.change(
116
+ fn=toggle_timer,
117
+ inputs=realtime_cb,
118
+ outputs=timer,
119
+ api_name="toggle_timer",
120
+ )
121
+
122
+ gr.api(
123
+ fn=log,
124
+ api_name="log",
125
+ )
126
+
127
+ x_lim = gr.State(None)
128
+
129
+ def update_x_lim(select_data: gr.SelectData):
130
+ return select_data.index
131
+
132
+ @gr.render(
133
+ triggers=[
134
+ demo.load,
135
+ run_dd.change,
136
+ timer.tick,
137
+ smoothing_cb.change,
138
+ x_lim.change,
139
+ ],
140
+ inputs=[project_dd, run_dd, smoothing_cb, metrics_subset, x_lim],
141
+ )
142
+ def update_dashboard(project, runs, smoothing, metrics_subset, x_lim_value):
143
+ dfs = []
144
+ for run in runs:
145
+ df = load_run_data(project, run, smoothing)
146
+ if df is not None:
147
+ df["run"] = run
148
+ dfs.append(df)
149
+ if dfs:
150
+ master_df = pd.concat(dfs, ignore_index=True)
151
+ else:
152
+ master_df = pd.DataFrame()
153
+ numeric_cols = master_df.select_dtypes(include="number").columns
154
+ numeric_cols = [c for c in numeric_cols if c not in RESERVED_KEYS]
155
+ if metrics_subset:
156
+ numeric_cols = [c for c in numeric_cols if c in metrics_subset]
157
+ plots: list[gr.LinePlot] = []
158
+ for col in range(len(numeric_cols) // 2):
159
+ with gr.Row(key=f"row-{col}"):
160
+ for i in range(2):
161
+ plot = gr.LinePlot(
162
+ master_df,
163
+ x="step",
164
+ y=numeric_cols[2 * col + i],
165
+ color="run" if "run" in master_df.columns else None,
166
+ title=numeric_cols[2 * col + i],
167
+ key=f"plot-{col}-{i}",
168
+ preserved_by_key=None,
169
+ x_lim=x_lim_value,
170
+ y_lim=[
171
+ min(master_df[numeric_cols[2 * col + i]]),
172
+ max(master_df[numeric_cols[2 * col + i]]),
173
+ ],
174
+ show_fullscreen_button=True,
175
+ )
176
+ plots.append(plot)
177
+
178
+ for plot in plots:
179
+ plot.select(update_x_lim, outputs=x_lim)
180
+ plot.double_click(lambda: None, outputs=x_lim)
181
+
182
+
183
+ if __name__ == "__main__":
184
+ demo.launch(allowed_paths=[TRACKIO_LOGO_PATH])
utils.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import sys
4
+ import time
5
+ from pathlib import Path
6
+
7
+ from huggingface_hub.constants import HF_HOME
8
+
9
+ RESERVED_KEYS = ["project", "run", "timestamp"]
10
+ TRACKIO_DIR = os.path.join(HF_HOME, "trackio")
11
+
12
+ TRACKIO_LOGO_PATH = str(Path(__file__).parent.joinpath("trackio_logo.png"))
13
+
14
+
15
+ def generate_readable_name():
16
+ """
17
+ Generates a random, readable name like "dainty-sunset-1"
18
+ """
19
+ adjectives = [
20
+ "dainty",
21
+ "brave",
22
+ "calm",
23
+ "eager",
24
+ "fancy",
25
+ "gentle",
26
+ "happy",
27
+ "jolly",
28
+ "kind",
29
+ "lively",
30
+ "merry",
31
+ "nice",
32
+ "proud",
33
+ "quick",
34
+ "silly",
35
+ "tidy",
36
+ "witty",
37
+ "zealous",
38
+ "bright",
39
+ "shy",
40
+ "bold",
41
+ "clever",
42
+ "daring",
43
+ "elegant",
44
+ "faithful",
45
+ "graceful",
46
+ "honest",
47
+ "inventive",
48
+ "jovial",
49
+ "keen",
50
+ "lucky",
51
+ "modest",
52
+ "noble",
53
+ "optimistic",
54
+ "patient",
55
+ "quirky",
56
+ "resourceful",
57
+ "sincere",
58
+ "thoughtful",
59
+ "upbeat",
60
+ "valiant",
61
+ "warm",
62
+ "youthful",
63
+ "zesty",
64
+ "adventurous",
65
+ "breezy",
66
+ "cheerful",
67
+ "delightful",
68
+ "energetic",
69
+ "fearless",
70
+ "glad",
71
+ "hopeful",
72
+ "imaginative",
73
+ "joyful",
74
+ "kindly",
75
+ "luminous",
76
+ "mysterious",
77
+ "neat",
78
+ "outgoing",
79
+ "playful",
80
+ "radiant",
81
+ "spirited",
82
+ "tranquil",
83
+ "unique",
84
+ "vivid",
85
+ "wise",
86
+ "zany",
87
+ "artful",
88
+ "bubbly",
89
+ "charming",
90
+ "dazzling",
91
+ "earnest",
92
+ "festive",
93
+ "gentlemanly",
94
+ "hearty",
95
+ "intrepid",
96
+ "jubilant",
97
+ "knightly",
98
+ "lively",
99
+ "magnetic",
100
+ "nimble",
101
+ "orderly",
102
+ "peaceful",
103
+ "quick-witted",
104
+ "robust",
105
+ "sturdy",
106
+ "trusty",
107
+ "upstanding",
108
+ "vibrant",
109
+ "whimsical",
110
+ ]
111
+ nouns = [
112
+ "sunset",
113
+ "forest",
114
+ "river",
115
+ "mountain",
116
+ "breeze",
117
+ "meadow",
118
+ "ocean",
119
+ "valley",
120
+ "sky",
121
+ "field",
122
+ "cloud",
123
+ "star",
124
+ "rain",
125
+ "leaf",
126
+ "stone",
127
+ "flower",
128
+ "bird",
129
+ "tree",
130
+ "wave",
131
+ "trail",
132
+ "island",
133
+ "desert",
134
+ "hill",
135
+ "lake",
136
+ "pond",
137
+ "grove",
138
+ "canyon",
139
+ "reef",
140
+ "bay",
141
+ "peak",
142
+ "glade",
143
+ "marsh",
144
+ "cliff",
145
+ "dune",
146
+ "spring",
147
+ "brook",
148
+ "cave",
149
+ "plain",
150
+ "ridge",
151
+ "wood",
152
+ "blossom",
153
+ "petal",
154
+ "root",
155
+ "branch",
156
+ "seed",
157
+ "acorn",
158
+ "pine",
159
+ "willow",
160
+ "cedar",
161
+ "elm",
162
+ "falcon",
163
+ "eagle",
164
+ "sparrow",
165
+ "robin",
166
+ "owl",
167
+ "finch",
168
+ "heron",
169
+ "crane",
170
+ "duck",
171
+ "swan",
172
+ "fox",
173
+ "wolf",
174
+ "bear",
175
+ "deer",
176
+ "moose",
177
+ "otter",
178
+ "beaver",
179
+ "lynx",
180
+ "hare",
181
+ "badger",
182
+ "butterfly",
183
+ "bee",
184
+ "ant",
185
+ "beetle",
186
+ "dragonfly",
187
+ "firefly",
188
+ "ladybug",
189
+ "moth",
190
+ "spider",
191
+ "worm",
192
+ "coral",
193
+ "kelp",
194
+ "shell",
195
+ "pebble",
196
+ "boulder",
197
+ "cobble",
198
+ "sand",
199
+ "wavelet",
200
+ "tide",
201
+ "current",
202
+ ]
203
+ adjective = random.choice(adjectives)
204
+ noun = random.choice(nouns)
205
+ number = random.randint(1, 99)
206
+ return f"{adjective}-{noun}-{number}"
207
+
208
+
209
+ def block_except_in_notebook():
210
+ in_notebook = bool(getattr(sys, "ps1", sys.flags.interactive))
211
+ if in_notebook:
212
+ return
213
+ try:
214
+ while True:
215
+ time.sleep(0.1)
216
+ except (KeyboardInterrupt, OSError):
217
+ print("Keyboard interruption in main thread... closing dashboard.")
version.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 0.0.8