Exemple #1
0
 def pull(self, container):
     if self.cli_available:
         cmds = container.build_mulled_singularity_pull_command(
             cache_directory=self.cache_directory.path,
             namespace=self.namespace)
         shell(cmds=cmds)
         self.cache_directory.invalidate_cache()
Exemple #2
0
    def resolve(self, enabled_container_types, tool_info, install=False, **kwds):
        """Find a container explicitly mentioned in tool description.

        This ignores the tool requirements and assumes the tool author crafted
        a correct container. We use singularity here to fetch docker containers,
        hence the container_description hack here.
        """
        for container_description in tool_info.container_descriptions:  # type: ContainerDescription
            if container_description.type == 'docker':
                desc_dict = container_description.to_dict()
                desc_dict['type'] = self.container_type
                desc_dict['identifier'] = f"docker://{container_description.identifier}"
                container_description = container_description.from_dict(desc_dict)
            if not self._container_type_enabled(container_description, enabled_container_types):
                return None
            if not self.cli_available:
                return container_description
            image_id = container_description.identifier
            cache_path = os.path.normpath(os.path.join(self.cache_directory_path, image_id))
            if install and not os.path.exists(cache_path):
                destination_info = {}
                destination_for_container_type = kwds.get(
                    'destination_for_container_type')
                if destination_for_container_type:
                    destination_info = destination_for_container_type(
                        self.container_type)
                container = SingularityContainer(
                    container_description.identifier,
                    self.app_info,
                    tool_info,
                    destination_info,
                    {},
                    container_description)
                command = container.build_singularity_pull_command(cache_path=cache_path)
                shell(command)
            # Point to container in the cache in stead.
            container_description.identifier = cache_path
            return container_description
        else:  # No container descriptions found
            return None
Exemple #3
0
 def pull(self, container):
     cmds = container.build_mulled_singularity_pull_command(
         cache_directory=self.cache_directory, namespace=self.namespace)
     shell(cmds=cmds)
Exemple #4
0
 def pull(self, container):
     command = container.build_pull_command()
     shell(command)
Exemple #5
0
 def pull(self, container):
     if self.cli_available:
         command = container.build_pull_command()
         shell(command)
Exemple #6
0
def shell(cmds, **kwds):
    """Print and execute shell command."""
    cmd_string = args_to_str(cmds)
    info(cmd_string)
    return commands.shell(cmds, **kwds)
Exemple #7
0
def shell(cmds, **kwds):
    cmd_string = args_to_str(cmds)
    info(cmd_string)
    return commands.shell(cmds, **kwds)