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
e2b6fda5
Commit
e2b6fda5
authored
3 years ago
by
Vladimír Višňovský
Browse files
Options
Downloads
Patches
Plain Diff
atomized notebook
parent
2e230fdd
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/utils.py
+43
-1
43 additions, 1 deletion
app/pmcff/notebook/utils.py
with
43 additions
and
1 deletion
app/pmcff/notebook/utils.py
+
43
−
1
View file @
e2b6fda5
import
os
import
requests
from
flask
import
redirect
log
=
logging
.
getLogger
(
'
__main__
'
)
def
check_running
(
user
):
jupyter_notebook
=
f
'
https://
{
user
.
dns_name
}
/?token=
{
user
.
token
}
'
try
:
if
requests
.
head
(
jupyter_notebook
).
status_code
in
[
200
,
405
]:
log
.
info
(
'
%s %s redirecting to existing notebook %s
'
,
user
.
id
,
user
.
name
,
jupyter_notebook
)
return
redirect
(
jupyter_notebook
)
except
requests
.
exceptions
.
ConnectionError
:
log
.
info
(
'
%s %s connection error to jupyter notebook %s
'
,
user
.
id
,
user
.
name
,
jupyter_notebook
)
log
.
info
(
'
%s %s allocating resources, dns name set (retry later)
'
,
user
.
id
,
user
.
name
)
return
'
<p>Taking longer to allocate needed resources... Please try to open pipeline from main page again later</p>
'
def
check_pvc_deleted
(
user
):
pvcs
=
os
.
popen
(
'
kubectl get pvc
'
).
read
()
user_pvc_name
=
f
'
pmcvff-correction-claim-
{
user
.
id
}
'
if
user_pvc_name
in
pvcs
:
log
.
info
(
'
%s %s pvc still getting deleted %s
'
,
user
.
id
,
user
.
name
,
pvcs
)
return
'
<p>Your personal storage is still getting deleted... Please try again later</p>
'
def
container_redirect
(
user
):
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
'
,
user
.
id
,
user
.
name
)
continue
if
response
.
status_code
in
[
200
,
405
]:
log
.
info
(
'
%s %s redirecting successfully to new notebook %s
'
,
user
.
id
,
user
.
name
,
jupyter_notebook
)
return
redirect
(
jupyter_notebook
)
log
.
info
(
'
%s %s still allocating resources for %s
'
,
user
.
id
,
user
.
name
,
jupyter_notebook
)
return
'
<p>Taking longer to allocate needed resources... Please try to open pipeline from main page again later</p>
'
def
remove_deployment
(
user_id
):
os
.
system
(
f
'
kubectl delete -f /srv/
{
user_id
}
'
)
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