"test/test_cpp_models.py" did not exist on "394de98e093e16195c9745394a45b207caeace56"
Commit 552586eb authored by Andrew Cowie's avatar Andrew Cowie Committed by Copybara-Service
Browse files

Simplify mounting of files.

PiperOrigin-RevId: 430450270
Change-Id: Ie9f30b253d1cabf6b20e596732b9bab4963dc776
parent 16bab4d3
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Docker run components of AlphaFold v2.0."""
...@@ -97,15 +97,23 @@ _ROOT_MOUNT_DIRECTORY = '/mnt/' ...@@ -97,15 +97,23 @@ _ROOT_MOUNT_DIRECTORY = '/mnt/'
def _create_mount(mount_name: str, path: str) -> Tuple[types.Mount, str]: def _create_mount(mount_name: str, path: str) -> Tuple[types.Mount, str]:
path = os.path.abspath(path) """Create a mount point for each file and directory used by the model."""
source_path = os.path.dirname(path) path = pathlib.Path(path).absolute()
target_path = os.path.join(_ROOT_MOUNT_DIRECTORY, mount_name) target_path = pathlib.Path(_ROOT_MOUNT_DIRECTORY, mount_name)
if not os.path.exists(source_path):
if path.is_dir():
source_path = path
mounted_path = target_path
else:
source_path = path.parent
mounted_path = pathlib.Path(target_path, path.name)
if not source_path.exists():
raise ValueError(f'Failed to find source directory "{source_path}" to ' raise ValueError(f'Failed to find source directory "{source_path}" to '
'mount in Docker container.') 'mount in Docker container.')
logging.info('Mounting %s -> %s', source_path, target_path) logging.info('Mounting %s -> %s', source_path, target_path)
mount = types.Mount(target_path, source_path, type='bind', read_only=True) mount = types.Mount(target=str(target_path), source=str(source_path),
return mount, os.path.join(target_path, os.path.basename(path)) type='bind', read_only=True)
return mount, str(mounted_path)
def main(argv): def main(argv):
......
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