Skip to content

Commit 3c6c79e

Browse files
committed
feat: add --download_only flag and visdom-download CLI for offline setups
Adds a dedicated mechanism to download all required static assets (JS, CSS, fonts) without starting the Tornado server. This addresses the workflow described in issue #942 where users on air-gapped machines need to pre-download assets on an online machine. Three ways to use: - visdom --download_only - visdom-download - python -m visdom.server --download_only Closes #942
1 parent 1835965 commit 3c6c79e

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

py/visdom/server/__main__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
assert sys.version_info[0] >= 3, "To use visdom with python 2, downgrade to v0.1.8.9"
1212

1313
if __name__ == "__main__":
14-
from visdom.server.run_server import download_scripts_and_run
14+
if "--download_only" in sys.argv:
15+
from visdom.server.run_server import download_only
1516

16-
download_scripts_and_run()
17+
download_only()
18+
else:
19+
from visdom.server.run_server import download_scripts_and_run
20+
21+
download_scripts_and_run()

py/visdom/server/run_server.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,20 @@ def main(print_func=None):
143143
action="store_true",
144144
help="Load data from filesystem when starting server (and not lazily upon first request).",
145145
)
146+
parser.add_argument(
147+
"--download_only",
148+
default=False,
149+
action="store_true",
150+
help="Download all required scripts (JS, CSS, fonts) and exit "
151+
"without starting the server. Useful for offline/air-gapped setups.",
152+
)
146153
FLAGS = parser.parse_args()
147154

155+
if FLAGS.download_only:
156+
download_scripts()
157+
print("Downloaded all required scripts. Exiting.")
158+
return
159+
148160
# Process base_url
149161
base_url = FLAGS.base_url if FLAGS.base_url != DEFAULT_BASE_URL else ""
150162
assert base_url == "" or base_url.startswith("/"), "base_url should start with /"
@@ -236,5 +248,11 @@ def download_scripts_and_run():
236248
main()
237249

238250

251+
def download_only():
252+
"""Download all required scripts and exit without starting the server."""
253+
download_scripts()
254+
print("Downloaded all required scripts. Exiting.")
255+
256+
239257
if __name__ == "__main__":
240258
download_scripts_and_run()

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,8 @@ def get_dist(pkgname):
7070
include_package_data=True,
7171
zip_safe=False,
7272
install_requires=requirements,
73-
entry_points={'console_scripts': ['visdom=visdom.server.run_server:download_scripts_and_run']}
73+
entry_points={'console_scripts': [
74+
'visdom=visdom.server.run_server:download_scripts_and_run',
75+
'visdom-download=visdom.server.run_server:download_only',
76+
]}
7477
)

0 commit comments

Comments
 (0)