pvanheus
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Building a Singularity container builder service for IRIDA/Workbench use Galaxy tools contain a `<requirements>` section that expresses the software (command line programs or software dependencies) the tool requires for operation. These requirements are either software package names or (much less commonly) names of software containers. The requirements for a Galaxy tool are combined together to define its dependencies. The dependency specification is passed to "dependency resolvers" to ensure that the dependencies are satisified at tool runtime. Since installing software is a time consuming process, dependencies are translated into a string name. This is straightforward if there is a single dependency: the name is the package name of the dependency, with, or without, a version number requirement. For example, a requirement for `samtools` might imply a dependency `__samtools@1.13` or (if a version is not specified) `_samtools@_uv_`. If more than one package is required, the requirements are combined using a process of mulling. This means that a hash string is created of the combined requirements, e.g. `mulled-v1-7f197292788ac0c39321dcb559c0e8de191431d8b9522034fbbe44259e040dee`. Historically dependency resolvers involved using various packaging systems, most commonly conda, to install packages and make them available at runtime. You can read more about dependency resolver configuration in the [Galaxy admin docs](https://docs.galaxyproject.org/en/master/admin/dependency_resolvers.html). In recent Galaxy versions, dependency resolvers are supplement by container resolvers that provide links between Galaxy tool execution and software containers (either Docker or Singularity) used to provide required packages. Container resolvers are configured using the [container_resolvers_conf.xml](https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/config/sample/container_resolvers_conf.xml.sample). This provides configuration for: 1. Explicitly named containers (i.e. when a tool states that it requires a particular container by name) 2. Cached mulled containers, i.e. when a container can be looked up in a locally stored cache based string name generated from the requirements (as described above). 3. Mulled containers, where the requirements "mulled" string name is used to look up a containe. The [auto-mulled](https://github.com/BioContainers/auto-mulled) project builds containers for many Galaxy tools, e.g. those in the tools-iuc collection. 4. Building containers: when none of the previously mentioned resolvers find a container, a new container can be built. This uses [involucro](https://github.com/involucro/involucro) to build the container based on the tool's requirements specification. 5. A fallback container that can be configured by the Galaxy admin. Containers either fetched using the mulled container resolver or built using `involucro` are stored in a cache for future use by the cached mulled container resolver. Note that there are Docker and Singularity versions of each of these resolvers. Singularity images are stored on disk, by default in the `database/container_cache` folder. Given the above explanation, there are several steps that are involved in going from Galaxy tool specification to running Galaxy tools with installed container resolvers, with associated questions: 0. Using the `workflow-to-tools` command from [Ephemeris](https://github.com/galaxyproject/ephemeris), we can go from a Galaxy workflow JSON specification (".ga file") to a list of tools to install (in a YAML file). This is used in the [irida-plugin-builder](https://github.com/COMBAT-TB/irida-plugin-builder). 1. A Galaxy toolshed name, tool name, author and toolshed commit ID specifies how to find a Galaxy tool. Ephemeris can install tools from a tool specification (in the YAML file mentioned above) into a Galaxy server. 2. Using the bioblend interface to the toolshed API, we can get info about a tool from its tool specification, e.g. ```python # this is how to get tool info from the toolshed toolshed_name = 'toolshed.g2.bx.psu.edu' tool_name = 'read_it_and_keep' tool_author = 'iuc' tool_revision = '1563b58905f4' toolshed_url = f'https://{toolshed_name}' ts = toolshed.ToolShedInstance(url=toolshed_url) result = ts.repositories.get_repository_revision_install_info( tool_name, tool_author, tool_revision) for dictionary in result: if 'valid_tools' in dictionary: spec_strs = [] # this dict contains a list of installable tools for tool in dictionary['valid_tools']: print(tool['id']) for requirement in tool['requirements']: if 'version' in requirement: spec_str = f'{requirement["name"]}=={requirement["version"]}' spec_strs.append(spec_str) print(spec_str) else: print(f'unversioned {requirement["name"]}', file=sys.stderr) print(','.join(spec_strs)) ``` 3. The `mulled-build` command from the [galaxy-tool-util](https://pypi.org/project/galaxy-tool-util) package can be used to build images using the spec from a tools requirements. Using the above example of Read It And Keep, the spec string is `read-it-and-keep==0.2.2,python==3.10` and the command to use is `mulled-build build-and-test --test echo --singularity 'read-it-and-keep==0.2.2,python==3.10'`. This builds a Docker container image, using conda to install the required tools (so tools need to be in conda-forge or bioconda), runs a test (using the command specfied with `--test`, thus `echo` is a fake test) and then builds a singularity container in the `./singularity_import` directory (or another directory specified with `--singularity-image-dir`). As an aside, this command uses [involucro](https://github.com/involucro/involucro) which is a container building system that relies on Lua files for its list of tasks. In the case of Galaxy [this file](https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/tool_util/deps/mulled/invfile.lua) is used. Look in this file for the `inv.task` sections to understand the available tasks (e.g. `build`, `build-and-test`, `singularity`, etc). A further detail: the current release of `mulled-build` is using Singularity version 2 to build these images. 4. Finally the image from the `./singularity_import` directory can be copied to the cache directory (by default `database/container_cache/singularity/mulled`) of the Galaxy server. The workflow described thus far assumes that containers are going to be built on the Galaxy server where they are used and assumes the presence of all infrastructure (Ephemeris, galaxy-tool-util, Docker) on that server. Alternatively, a list of tools (in the tool specification YAML) can be used to build Singularity container images ahead of time that can then be copied to the Galaxy server as needed. ### From Tool specification to Mulled ID This script - which uses the `bioblend` and `galaxy_util` libraries, prints a mulled ID when given a tool specification (tool, author, revision). ```python #!/usr/bin/env python3 import argparse from typing import Union from bioblend import toolshed from galaxy.tool_util.deps.mulled.mulled_build import target_str_to_targets from galaxy.tool_util.deps.mulled.util import v1_image_name, v2_image_name def get_tool_requirements(tool_name: str, tool_author: str, tool_revision: str, toolshed_name: str = 'toolshed.g2.bx.psu.edu') -> Union[str, None]: "Given a tool description, get the list of requirements" # this is how to get tool info from the toolshed toolshed_url = f'https://{toolshed_name}' ts = toolshed.ToolShedInstance(url=toolshed_url) result = ts.repositories.get_repository_revision_install_info( tool_name, tool_author, tool_revision) for dictionary in result: if 'valid_tools' in dictionary: spec_strs = [] # this dict contains a list of installable tools for tool in dictionary['valid_tools']: for requirement in tool['requirements']: if 'version' in requirement: spec_str = f'{requirement["name"]}=={requirement["version"]}' spec_strs.append(spec_str) else: print(f'unversioned {requirement["name"]}', file=sys.stderr) return ','.join(spec_strs) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--mulled_version', default='v2') parser.add_argument('tool_name') parser.add_argument('tool_author') parser.add_argument('tool_revision') args = parser.parse_args() targets = target_str_to_targets(get_tool_requirements(args.tool_name, args.tool_author, args.tool_revision)) if args.mulled_version == 'v2': image_name = v2_image_name else: image_name = v1_image_name print(image_name(targets)) ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully