Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nomad-remote-tools-hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
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
nomad-lab
nomad-remote-tools-hub
Commits
96cfc491
Commit
96cfc491
authored
3 years ago
by
Lauri Himanen
Browse files
Options
Downloads
Plain Diff
Merge branch 'async-docker-launch' into 'develop'
Async docker launch See merge request
!17
parents
567463be
5423e31e
No related branches found
No related tags found
1 merge request
!17
Async docker launch
Pipeline
#112362
passed
3 years ago
Stage: build
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
north/app/routes/instances.py
+20
-13
20 additions, 13 deletions
north/app/routes/instances.py
with
20 additions
and
13 deletions
north/app/routes/instances.py
+
20
−
13
View file @
96cfc491
...
...
@@ -17,6 +17,7 @@
#
from
typing
import
List
import
asyncio
from
fastapi
import
APIRouter
,
HTTPException
,
Request
,
Depends
from
collections
import
deque
from
datetime
import
datetime
,
timedelta
...
...
@@ -112,18 +113,24 @@ async def post_instances(request: Request, instance: InstanceModel, token=Depend
path
=
current_containers
[
0
].
labels
[
'
path
'
]
return
InstanceResponseModel
(
path
=
path
)
docker_client
.
containers
.
run
(
image
=
"
jupyter/datascience-notebook
"
,
command
=
(
f
'
start-notebook.sh --NotebookApp.base_url=
{
path
}
'
'
--NotebookApp.token=
""
--NotebookApp.password=
""'
),
ports
=
{
"
8888
"
:
int
(
f
'
1000
{
channel
}
'
)},
detach
=
True
,
name
=
container_name
,
user
=
"
1000:1000
"
,
group_add
=
[
"
1000
"
],
labels
=
{
"
path
"
:
path
}
)
# We use an async function to run the container so that the API does not
# get blocked even if docker needs to do some heavier container startup
# routines (e.g. download the container image).
async
def
run_container
():
docker_client
.
containers
.
run
(
image
=
"
jupyter/datascience-notebook
"
,
command
=
(
f
'
start-notebook.sh --NotebookApp.base_url=
{
path
}
'
'
--NotebookApp.token=
""
--NotebookApp.password=
""'
),
ports
=
{
"
8888
"
:
int
(
f
'
1000
{
channel
}
'
)},
detach
=
True
,
name
=
container_name
,
user
=
"
1000:1000
"
,
group_add
=
[
"
1000
"
],
labels
=
{
"
path
"
:
path
}
)
loop
=
asyncio
.
get_event_loop
()
loop
.
create_task
(
run_container
())
return
InstanceResponseModel
(
path
=
path
)
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