Unverified Commit f98ee672 authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

[v2.0] Refactor code hierarchy (part 1) (#2962)

parent f1105409
......@@ -9,8 +9,9 @@ import random
import time
import tempfile
from subprocess import Popen, check_call, CalledProcessError, PIPE, STDOUT
from nni_annotation import expand_annotations, generate_search_space
from nni.package_utils import get_builtin_module_class_name, get_nni_installation_path
from nni.nni_annotation import expand_annotations, generate_search_space
from nni.package_utils import get_builtin_module_class_name
import nni_node
from .launcher_utils import validate_all_content
from .rest_utils import rest_put, rest_post, check_rest_server, check_response
from .url_utils import cluster_metadata_url, experiment_url, get_local_urls
......@@ -52,15 +53,16 @@ def start_rest_server(port, platform, mode, config_file_name, foreground=False,
print_normal('Starting restful server...')
entry_dir = get_nni_installation_path()
entry_dir = nni_node.__path__[0]
if (not entry_dir) or (not os.path.exists(entry_dir)):
print_error('Fail to find nni under python library')
exit(1)
entry_file = os.path.join(entry_dir, 'main.js')
node_command = 'node'
if sys.platform == 'win32':
node_command = os.path.join(entry_dir[:-3], 'Scripts', 'node.exe')
node_command = os.path.join(entry_dir, 'node.exe')
else:
node_command = 'node'
cmds = [node_command, '--max-old-space-size=4096', entry_file, '--port', str(port), '--mode', platform]
if mode == 'view':
cmds += ['--start_mode', 'resume']
......
......@@ -13,8 +13,8 @@ from functools import cmp_to_key
from datetime import datetime, timezone
from subprocess import Popen
from pyhdfs import HdfsClient
from nni.package_utils import get_nni_installation_path
from nni_annotation import expand_annotations
from nni.nni_annotation import expand_annotations
import nni_node
from .rest_utils import rest_get, rest_delete, check_rest_server_quick, check_response
from .url_utils import trial_jobs_url, experiment_url, trial_job_id_url, export_data_url, metric_data_url
from .config_utils import Config, Experiments
......@@ -424,13 +424,14 @@ def webui_nas(args):
'''launch nas ui'''
print_normal('Starting NAS UI...')
try:
entry_dir = get_nni_installation_path()
entry_dir = nni_node.__path__[0]
entry_file = os.path.join(entry_dir, 'nasui', 'server.js')
node_command = 'node'
if sys.platform == 'win32':
node_command = os.path.join(entry_dir[:-3], 'Scripts', 'node.exe')
node_command = os.path.join(entry_dir, 'node.exe')
else:
node_command = 'node'
cmds = [node_command, '--max-old-space-size=4096', entry_file, '--port', str(args.port), '--logdir', args.logdir]
subprocess.run(cmds)
subprocess.run(cmds, cwd=entry_dir)
except KeyboardInterrupt:
pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment