Skip to content

Commit

Permalink
Merge pull request #162 from hubmapconsortium/development
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
jpuerto-psc authored May 9, 2024
2 parents d8aa4b0 + 975ba5c commit 13e8a72
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b1db4e4
351a34d
9 changes: 9 additions & 0 deletions src/user_workspaces_server/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def update_job_status(job_id):
job.job_details["metrics"]["time_pending"] = time_pending
elif current_job_status in [models.Job.Status.COMPLETE, models.Job.Status.FAILED]:
job.datetime_end = datetime.datetime.now()
elif current_job_status == models.Job.Status.PENDING:
current_time_pending = (
datetime.datetime.now(job.datetime_created.tzinfo) - job.datetime_created
).total_seconds()
time_pending_catch = resource.config.get("time_pending_catch")
if int(time_pending_catch) and current_time_pending > time_pending_catch:
logger.error(
f"Job {job_id} for user {job.user_id.username} has been pending more than {time_pending_catch}"
)

if current_job_status == models.Job.Status.FAILED:
logger.error(f"Job {job_id} for user {job.user_id.username} has failed.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ EOL
# Launch the Jupyter Notebook Server
set -x
export JUPYTER_DATA_DIR="$VENV_PATH/share/jupyter"
export SSL_CERT_FILE="$VENV_PATH/ssl/cert.pem"
python -m jupyterlab --config="${CONFIG_FILE}" &> "$(pwd)/JupyterLabJob_{{ job_id }}_output.log"
12 changes: 8 additions & 4 deletions src/user_workspaces_server/views/job_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ def get(self, request, job_id=None):
for key in set(params.keys()).intersection(set(models.Job.get_query_param_fields())):
job = job.filter(**{key: params[key]})

job = list(job.all().values(*models.Job.get_dict_fields()))
jobs = list(job.all().values(*models.Job.get_dict_fields()))

if job:
return JsonResponse({"message": "Successful.", "success": True, "data": {"jobs": job}})
response = {"message": "Successful.", "success": True, "data": {"jobs": []}}

if jobs:
response["data"]["jobs"] = jobs
else:
raise NotFound("Job matching given parameters could not be found.")
response["message"] = "Job matching given parameters could not be found."

return JsonResponse(response)

def put(self, request, job_id, put_type):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/user_workspaces_server/views/status_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StatusView(APIView):
permission_classes = []

def get(self, request):
base_dir = Path(__file__).resolve().parent.parent
base_dir = Path(__file__).resolve().parent.parent.parent
version_file_path = os.path.join(base_dir, "VERSION")
build_file_path = os.path.join(base_dir, "BUILD")

Expand Down
14 changes: 6 additions & 8 deletions src/user_workspaces_server/views/workspace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ def get(self, request, workspace_id=None):

workspaces = list(workspace.all().values(*models.Workspace.get_dict_fields()))

response = {"message": "Successful.", "success": True, "data": {"workspaces": []}}

if workspaces:
return JsonResponse(
{
"message": "Successful.",
"success": True,
"data": {"workspaces": workspaces},
}
)
response["data"]["workspaces"] = workspaces
else:
raise NotFound("Workspace matching given parameters could not be found.")
response["message"] = "Workspace matching given parameters could not be found."

return JsonResponse(response)

def post(self, request):
try:
Expand Down

0 comments on commit 13e8a72

Please sign in to comment.