Skip to content

Commit 9928d0d

Browse files
pankajbaid567baidpankaj567
authored andcommitted
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 9928d0d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

py/visdom/server/run_server.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def start_server(
6969
app.sources = []
7070

7171

72-
def main(print_func=None):
72+
def main(print_func=None, _download_only=False):
7373
"""
7474
Run a server from the command line, first parsing arguments from the
7575
command line
@@ -143,8 +143,21 @@ 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+
download_scripts()
156+
157+
if FLAGS.download_only or _download_only:
158+
print("Downloaded all required scripts. Exiting.")
159+
return
160+
148161
# Process base_url
149162
base_url = FLAGS.base_url if FLAGS.base_url != DEFAULT_BASE_URL else ""
150163
assert base_url == "" or base_url.startswith("/"), "base_url should start with /"
@@ -232,9 +245,13 @@ def main(print_func=None):
232245

233246

234247
def download_scripts_and_run():
235-
download_scripts()
236248
main()
237249

238250

251+
def download_only():
252+
"""Download all required scripts and exit without starting the server."""
253+
main(_download_only=True)
254+
255+
239256
if __name__ == "__main__":
240257
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)