Skip to content

Commit

Permalink
vdk-jupyter: fix server error in jupyter ui and remove unneeded code (#…
Browse files Browse the repository at this point in the history
…2361)

What:
1.removed some unneeded code
2. fixed some issues with deployment from jupyter
3. fixed server fail on not present config.ini 

Why: 
1. there was an error in the server that was failing when config.ini is
not present, I put that in try catch
2. the deploy was failing because of enabled flag

Signed-off-by: Duygu Hasan [[email protected]](mailto:[email protected])
  • Loading branch information
duyguHsnHsn authored Jul 10, 2023
1 parent b608cbd commit b751ec6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export async function getNotebookInfo(cellId: string): Promise<{
cellIndex: data['cellIndex']
};
} catch (error) {
showError(error);
return {
path: '',
cellIndex: ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021-2023 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
import json
import os
import logging

import tornado
from jupyter_server.base.handlers import APIHandler
Expand All @@ -11,6 +11,8 @@
from .vdk_options.vdk_options import VdkOption
from .vdk_ui import VdkUI

log = logging.getLogger(__name__)


class LoadJobDataHandler(APIHandler):
"""
Expand All @@ -22,16 +24,30 @@ class LoadJobDataHandler(APIHandler):
@tornado.web.authenticated
def post(self):
working_directory = json.loads(self.get_json_body())[VdkOption.PATH.value]
data = JobDataLoader(working_directory)
self.finish(
json.dumps(
{
VdkOption.PATH.value: data.get_job_path(),
VdkOption.NAME.value: data.get_job_name(),
VdkOption.TEAM.value: data.get_team_name(),
}
try:
data = JobDataLoader(working_directory)
self.finish(
json.dumps(
{
VdkOption.PATH.value: data.get_job_path(),
VdkOption.NAME.value: data.get_job_name(),
VdkOption.TEAM.value: data.get_team_name(),
}
)
)
except Exception as e:
log.debug(
f"Failed to load job information from config.ini with error: {e}."
)
self.finish(
json.dumps(
{
VdkOption.PATH.value: "",
VdkOption.NAME.value: "",
VdkOption.TEAM.value: "",
}
)
)
)


class RunJobHandler(APIHandler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from vdk.internal.control.command_groups.job.deploy_cli_impl import JobDeploy
from vdk.internal.control.command_groups.job.download_job import JobDownloadSource
from vdk.internal.control.utils import cli_utils
from vdk.internal.control.utils.cli_utils import get_or_prompt


class RestApiUrlConfiguration:
Expand Down Expand Up @@ -152,22 +151,27 @@ def create_deployment(name: str, team: str, path: str, reason: str, enabled: boo
:param enabled: flag whether the job is enabled (that will basically un-pause the job)
:return: output string of the operation
"""
output = ""
output = "text"
cmd = JobDeploy(RestApiUrlConfiguration.get_rest_api_url(), output)
path = get_or_prompt("Job Path", path)
default_name = os.path.basename(path)
name = get_or_prompt("Job Name", name, default_name)
reason = get_or_prompt("Reason", reason)
cmd.create(
name=name,
team=team,
job_path=path,
reason=reason,
output=output,
vdk_version=None,
enabled=enabled,
)
return output
if enabled:
cmd.create(
name=name,
team=team,
job_path=path,
reason=reason,
vdk_version=None,
enabled=True,
)
else:
cmd.create(
name=name,
team=team,
job_path=path,
reason=reason,
vdk_version=None,
enabled=False,
)
return f"Job with name {name} and team {team} is deployed successfully!"

@staticmethod
def get_notebook_info(cell_id: str, pr_path: str):
Expand Down

0 comments on commit b751ec6

Please sign in to comment.