Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PMCV force field correction web
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vladimír Višňovský
PMCV force field correction web
Commits
5a1a9e2e
Commit
5a1a9e2e
authored
3 years ago
by
Vladimír Višňovský
Browse files
Options
Downloads
Patches
Plain Diff
atomized notebook 2
parent
e2b6fda5
No related branches found
No related tags found
2 merge requests
!8
Development
,
!7
Remodule (v1.0 -> v1.1)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/pmcff/notebook/routes.py
+5
-30
5 additions, 30 deletions
app/pmcff/notebook/routes.py
with
5 additions
and
30 deletions
app/pmcff/notebook/routes.py
+
5
−
30
View file @
5a1a9e2e
...
...
@@ -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>
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment