Skip to content
Snippets Groups Projects
Commit 5a1a9e2e authored by Vladimír Višňovský's avatar Vladimír Višňovský
Browse files

atomized notebook 2

parent e2b6fda5
No related branches found
No related tags found
2 merge requests!8Development,!7Remodule (v1.0 -> v1.1)
......@@ -22,45 +22,20 @@ def open_notebook():
if current_user.is_authenticated:
log.info('%s %s opening notebook', current_user.id, current_user.name)
# Check if the service is running
# Check if the service is running, redirect if so, else tell to wait
if current_user.dns_name:
jupyter_notebook = f'https://{current_user.dns_name}/?token={current_user.token}'
try:
if requests.head(jupyter_notebook).status_code in [200, 405]:
log.info('%s %s redirecting to existing notebook %s', current_user.id, current_user.name, jupyter_notebook)
return redirect(jupyter_notebook)
except requests.exceptions.ConnectionError:
log.info('%s %s connection error to jupyter notebook %s', current_user.id, current_user.name, jupyter_notebook)
log.info('%s %s allocating resources, dns name set (retry later)', current_user.id, current_user.name)
return '<p>Taking longer to allocate needed resources... Please try to open pipeline from main page again later</p>'
return utils.check_running(current_user)
# Check if the pvc is deleted
pvcs = os.popen('kubectl get pvc').read()
user_pvc_name = f'pmcvff-correction-claim-{current_user.id}'
if user_pvc_name in pvcs:
log.info('%s %s pvc still getting deleted %s', current_user.id, current_user.name, pvcs)
return '<p>Your personal storage is still getting deleted... Please try again later</p>'
if out := utils.check_pvc_deleted(current_user):
return out
# Run pipeline container
jupyter_notebook = run_container(current_user.id)
log.info('%s %s running container', current_user.id, current_user.name)
# Periodicaly wait until the container is available or timeout
timeout_threshold = 5
while timeout_threshold >= 0:
time.sleep(4)
timeout_threshold -= 1
try:
response = requests.head(jupyter_notebook)
except requests.exceptions.ConnectionError:
log.info('%s %s connection error in new noteboook', current_user.id, current_user.name)
continue
if response.status_code in [200, 405]:
log.info('%s %s redirecting successfully to new notebook %s', current_user.id, current_user.name, jupyter_notebook)
return redirect(jupyter_notebook)
log.info('%s %s still allocating resources for %s', current_user.id, current_user.name, jupyter_notebook)
return '<p>Taking longer to allocate needed resources... Please try to open pipeline from main page again later</p>'
return utils.container_redirect(current_user)
return '<p>User not authorized to perform opening of notebook</p>'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment