Commit 6e28d902 authored by Samuel GAIST's avatar Samuel GAIST

[execution][docker] Implement database root folder sharing

A new property in the execution configuration allows to
mount the various databases in the algorithm container
in a similar fashion as the database container. It will
only work for containers that needs to access datasets.

Fixes #103
parent b9960cee
...@@ -384,6 +384,15 @@ class DockerExecutor(RemoteExecutor): ...@@ -384,6 +384,15 @@ class DockerExecutor(RemoteExecutor):
file_path = result["path"] file_path = result["path"]
__add_writable_volume(file_path) __add_writable_volume(file_path)
def __share_databases(self, algorithm_container, db_infos):
"""Add volumes to the algorithm container for the datasets"""
for database_name, database in self.databases.items():
db_data = database.data
algorithm_container.add_volume(
db_data["root_folder"], os.path.join("/databases", database_name)
)
def process( def process(
self, virtual_memory_in_megabytes=0, max_cpu_percent=0, timeout_in_minutes=0 self, virtual_memory_in_megabytes=0, max_cpu_percent=0, timeout_in_minutes=0
): ):
...@@ -472,6 +481,8 @@ class DockerExecutor(RemoteExecutor): ...@@ -472,6 +481,8 @@ class DockerExecutor(RemoteExecutor):
network_name = self.data.pop("network_name", "bridge") network_name = self.data.pop("network_name", "bridge")
databases_infos = {} databases_infos = {}
share_databases = self.data.pop("share_databases", False)
if len(self.databases) > 0: if len(self.databases) > 0:
databases_infos["db"] = self.__create_db_container( databases_infos["db"] = self.__create_db_container(
datasets_uid, network_name datasets_uid, network_name
...@@ -526,6 +537,9 @@ class DockerExecutor(RemoteExecutor): ...@@ -526,6 +537,9 @@ class DockerExecutor(RemoteExecutor):
loop_algorithm_container, volume_cache_mount_point, self.data["loop"] loop_algorithm_container, volume_cache_mount_point, self.data["loop"]
) )
if share_databases:
self.__share_databases(loop_algorithm_container, databases_infos)
# Start the container # Start the container
self.host.start( self.host.start(
loop_algorithm_container, loop_algorithm_container,
...@@ -570,6 +584,9 @@ class DockerExecutor(RemoteExecutor): ...@@ -570,6 +584,9 @@ class DockerExecutor(RemoteExecutor):
algorithm_container, volume_cache_mount_point, self.data algorithm_container, volume_cache_mount_point, self.data
) )
if share_databases:
self.__share_databases(algorithm_container, databases_infos)
# Start the container # Start the container
self.host.start( self.host.start(
algorithm_container, algorithm_container,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment