Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-OSD
Implementation of OSD-TMA
Commits
2c556431
Commit
2c556431
authored
Sep 23, 2024
by
Mattia Bergagio
Browse files
no DinD
parent
d8fd914a
Changes
3
Hide whitespace changes
Inline
Side-by-side
compose.yml
View file @
2c556431
...
...
@@ -199,14 +199,7 @@ services:
-
MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
-
GIT_NAME=${GIT_NAME}
-
GIT_TOKEN=${GIT_TOKEN}
-
TAG=${TAG}
volumes
:
# access my host's Docker service from inside container
# https://stackoverflow.com/a/71543340
-
type
:
bind
source
:
/var/run/docker.sock
target
:
/var/run/docker.sock
-
type
:
bind
source
:
${PATH_SHARED}
target
:
${AI_FW_DIR}
...
...
controller/requirements.txt
View file @
2c556431
docker
pika==1.3.1
typeguard==4.1.5
typing_extensions==4.8.0
\ No newline at end of file
controller/src/run_funs.py
View file @
2c556431
import
os
import
docker
from
typeguard
import
typechecked
try
:
...
...
@@ -13,61 +10,8 @@ try:
except
ModuleNotFoundError
:
from
common_module.common_utils.logger
import
create_logger
# Docker client
docker_client
=
docker
.
from_env
()
LOGGER
=
create_logger
(
__name__
)
@
typechecked
def
run_container
(
module
:
str
)
->
int
:
"""
Runs container.
"""
# read vols
# key: path on my machine/host
# value of key "bind": path inside container
# "ro": read only
# "rw": read & write
# https://stackoverflow.com/a/74524696
# Docker prepends dir name to named vols to prevent clashes w existing containers!
# https://forums.docker.com/t/docker-compose-prepends-directory-name-to-named-volumes/32835/2
# TODO
# change prepended str if dir is renamed
vols
=
{
"ai-framework_namedin"
:
{
"bind"
:
"/in"
,
"mode"
:
"rw"
},
"ai-framework_namedout"
:
{
"bind"
:
"/out"
,
"mode"
:
"rw"
},
}
# solver
# network: name of the network the container will be connected to at creation time
# Docker prepends dir name to network!
solver_container
=
docker_client
.
containers
.
run
(
image
=
f
"
{
module
}
:
{
os
.
environ
[
'TAG'
]
}
"
,
detach
=
True
,
auto_remove
=
False
,
environment
=
envs
,
volumes
=
vols
,
device_requests
=
[
docker
.
types
.
DeviceRequest
(
device_ids
=
[
"0"
],
capabilities
=
[[
'gpu'
]])],
network
=
"ai-framework_aifw_net"
,
)
return
solver_container
.
id
@
typechecked
def
kill_container
(
solver_container_id
:
int
):
"""
Kills container.
"""
# get container
running_containers
=
docker_client
.
containers
.
list
(
filters
=
{
"id"
:
solver_container_id
}
)
for
container
in
running_containers
:
container
.
kill
()
@
typechecked
def
run
(
message_body
:
dict
,
worker
:
rabbitmq
.
Worker
)
->
bool
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment