From 2f8dbf8ab98e9a1c7f9cf09ab67d8d103c506f5c Mon Sep 17 00:00:00 2001 From: didayolo Date: Wed, 17 May 2023 16:44:13 +0200 Subject: [PATCH 1/2] Mount /codabench/data to /app/data --- compute_worker/compute_worker.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index c8bef06d1..93e709ece 100644 --- a/compute_worker/compute_worker.py +++ b/compute_worker/compute_worker.py @@ -39,9 +39,9 @@ # Setup base directories used by all submissions -HOST_DIRECTORY = os.environ.get("HOST_DIRECTORY", "/tmp/codabench/") # note: we need to pass this directory to - # docker compose so it knows where to store things! -BASE_DIR = "/codabench/" +# note: we need to pass this directory to docker-compose so it knows where to store things! +HOST_DIRECTORY = os.environ.get("HOST_DIRECTORY", "/tmp/codabench/") +BASE_DIR = "/codabench/" # base directory inside the container CACHE_DIR = os.path.join(BASE_DIR, "cache") MAX_CACHE_DIR_SIZE_GB = float(os.environ.get('MAX_CACHE_DIR_SIZE_GB', 10)) @@ -182,6 +182,7 @@ def __init__(self, run_args): self.bundle_dir = os.path.join(self.root_dir, "bundles") self.input_dir = os.path.join(self.root_dir, "input") self.output_dir = os.path.join(self.root_dir, "output") + self.data_dir = os.path.join(HOST_DIRECTORY, "data") # absolute path to data in the host self.logs = {} # Details for submission @@ -522,6 +523,7 @@ async def _run_program_directory(self, program_dir, kind, can_be_output=False): # Set the volumes '-v', f'{self._get_host_path(program_dir)}:/app/program', '-v', f'{self._get_host_path(self.output_dir)}:/app/output', + '-v', f'{self.data_dir}:/app/data', # Start in the right directory '-w', '/app/program', From 9ea0571cccae6a9e3c17446507eec6f50bf85ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Pav=C3=A3o?= Date: Wed, 17 May 2023 17:09:52 +0200 Subject: [PATCH 2/2] Add ":ro" for read-only access --- compute_worker/compute_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index 93e709ece..ef83d1580 100644 --- a/compute_worker/compute_worker.py +++ b/compute_worker/compute_worker.py @@ -523,7 +523,7 @@ async def _run_program_directory(self, program_dir, kind, can_be_output=False): # Set the volumes '-v', f'{self._get_host_path(program_dir)}:/app/program', '-v', f'{self._get_host_path(self.output_dir)}:/app/output', - '-v', f'{self.data_dir}:/app/data', + '-v', f'{self.data_dir}:/app/data:ro', # Start in the right directory '-w', '/app/program',