mirror of
https://github.com/clearml/clearml-session
synced 2025-03-13 07:08:08 +00:00
add traitlets to the requirements to help pip resolve new jupyterlab versions. allow to override vscode deb source
This commit is contained in:
parent
210ce5ae4b
commit
a833af8a2a
@ -149,7 +149,8 @@ def create_base_task(state, project_name=None, task_name=None):
|
|||||||
task_script['working_dir'] = '.'
|
task_script['working_dir'] = '.'
|
||||||
task_script['entry_point'] = 'interactive_session.py'
|
task_script['entry_point'] = 'interactive_session.py'
|
||||||
task_script['requirements'] = {'pip': '\n'.join(
|
task_script['requirements'] = {'pip': '\n'.join(
|
||||||
["clearml>=1.1.5"] + (["jupyter", "jupyterlab", "jupyterlab_git"] if state.get('jupyter_lab') else []) +
|
["clearml>=1.1.5"] +
|
||||||
|
(["jupyter", "jupyterlab", "jupyterlab_git", "traitlets"] if state.get('jupyter_lab') else []) +
|
||||||
(['pylint'] if state.get('vscode_server') else []))}
|
(['pylint'] if state.get('vscode_server') else []))}
|
||||||
|
|
||||||
section, _, _ = _get_config_section_name()
|
section, _, _ = _get_config_section_name()
|
||||||
@ -326,9 +327,8 @@ def _b64_encode_file(file):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_project_id(state):
|
def get_project_id(project_name):
|
||||||
project_id = None
|
project_id = None
|
||||||
project_name = state.get('project') or None
|
|
||||||
if project_name:
|
if project_name:
|
||||||
projects = Task.get_projects()
|
projects = Task.get_projects()
|
||||||
project_id = [p for p in projects if p.name == project_name]
|
project_id = [p for p in projects if p.name == project_name]
|
||||||
@ -457,13 +457,15 @@ def load_state(state_file):
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
|
|
||||||
def clone_task(state, project_id):
|
def clone_task(state, project_id=None):
|
||||||
new_task = False
|
new_task = False
|
||||||
if state.get('debugging_session'):
|
if state.get('debugging_session'):
|
||||||
print('Starting new debugging session to {}'.format(state.get('debugging_session')))
|
print('Starting new debugging session to {}'.format(state.get('debugging_session')))
|
||||||
task = create_debugging_task(state, state.get('debugging_session'))
|
task = create_debugging_task(state, state.get('debugging_session'))
|
||||||
elif state.get('base_task_id'):
|
elif state.get('base_task_id'):
|
||||||
print('Cloning base session {}'.format(state['base_task_id']))
|
print('Cloning base session {}'.format(state['base_task_id']))
|
||||||
|
project_id = \
|
||||||
|
project_id or (get_project_id(project_name=state.get('project')) if state.get('project') else None)
|
||||||
task = Task.clone(source_task=state['base_task_id'], project=project_id, parent=state['base_task_id'])
|
task = Task.clone(source_task=state['base_task_id'], project=project_id, parent=state['base_task_id'])
|
||||||
task.set_system_tags([system_tag])
|
task.set_system_tags([system_tag])
|
||||||
else:
|
else:
|
||||||
@ -654,6 +656,9 @@ def wait_for_machine(state, task):
|
|||||||
print('\n')
|
print('\n')
|
||||||
|
|
||||||
if task.get_status() != 'in_progress':
|
if task.get_status() != 'in_progress':
|
||||||
|
log_lines = task.get_reported_console_output(10)
|
||||||
|
log_lines = "\n".join("\n".join("> " + l for l in line.split("\n")) for line in log_lines)
|
||||||
|
print("\n".join(log_lines.split("\n")[-10:]))
|
||||||
raise ValueError("Remote setup failed (status={}) see details: {}".format(
|
raise ValueError("Remote setup failed (status={}) see details: {}".format(
|
||||||
task.get_status(), task.get_output_log_web_page()))
|
task.get_status(), task.get_output_log_web_page()))
|
||||||
print('\nRemote machine is ready')
|
print('\nRemote machine is ready')
|
||||||
@ -1025,14 +1030,11 @@ def cli():
|
|||||||
# save state
|
# save state
|
||||||
save_state(state, state_file)
|
save_state(state, state_file)
|
||||||
|
|
||||||
# get project name
|
|
||||||
project_id = get_project_id(state)
|
|
||||||
|
|
||||||
# remove old Tasks created by us.
|
# remove old Tasks created by us.
|
||||||
delete_old_tasks(state, client, state.get('base_task_id'))
|
delete_old_tasks(state, client, state.get('base_task_id'))
|
||||||
|
|
||||||
# Clone the Task and adjust parameters
|
# Clone the Task and adjust parameters
|
||||||
task = clone_task(state, project_id)
|
task = clone_task(state)
|
||||||
state['task_id'] = task.id
|
state['task_id'] = task.id
|
||||||
save_state(state, state_file)
|
save_state(state, state_file)
|
||||||
|
|
||||||
|
@ -263,6 +263,13 @@ def start_vscode_server(hostname, hostnames, param, task, env):
|
|||||||
env = dict(**env)
|
env = dict(**env)
|
||||||
env.pop('PYTHONPATH', None)
|
env.pop('PYTHONPATH', None)
|
||||||
|
|
||||||
|
python_ext_download_link = \
|
||||||
|
os.environ.get("CLEARML_SESSION_VSCODE_PY_EXT") or \
|
||||||
|
'https://github.com/microsoft/vscode-python/releases/download/{}/ms-python-release.vsix'
|
||||||
|
code_server_deb_download_link = \
|
||||||
|
os.environ.get("CLEARML_SESSION_VSCODE_SERVER_DEB") or \
|
||||||
|
'https://github.com/cdr/code-server/releases/download/v{version}/code-server_{version}_amd64.deb'
|
||||||
|
|
||||||
pre_installed = False
|
pre_installed = False
|
||||||
python_ext = None
|
python_ext = None
|
||||||
|
|
||||||
@ -282,12 +289,10 @@ def start_vscode_server(hostname, hostnames, param, task, env):
|
|||||||
# installing VSCODE:
|
# installing VSCODE:
|
||||||
try:
|
try:
|
||||||
python_ext = StorageManager.get_local_copy(
|
python_ext = StorageManager.get_local_copy(
|
||||||
'https://github.com/microsoft/vscode-python/releases/download/{}/ms-python-release.vsix'.format(
|
python_ext_download_link.format(python_ext_version),
|
||||||
python_ext_version),
|
|
||||||
extract_archive=False)
|
extract_archive=False)
|
||||||
code_server_deb = StorageManager.get_local_copy(
|
code_server_deb = StorageManager.get_local_copy(
|
||||||
'https://github.com/cdr/code-server/releases/download/'
|
code_server_deb_download_link.format(version=vscode_version),
|
||||||
'v{version}/code-server_{version}_amd64.deb'.format(version=vscode_version),
|
|
||||||
extract_archive=False)
|
extract_archive=False)
|
||||||
os.system("dpkg -i {}".format(code_server_deb))
|
os.system("dpkg -i {}".format(code_server_deb))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
Loading…
Reference in New Issue
Block a user