How to fix plug conflicts with binding

The example below binds plugs for the mount interface, but the same process works for any other interface that supports bindings.

Suppose you have two SDKs that each declare a plug of the same interface, and the plugs are in conflict. Here, we use fictional torchaudio:hub and torchvision:hub that both point to the ~/.cache/torch/hub directory on the host, where the SDKs store their models.

  1. Create or open your workshop definition and list both SDKs:

    .workshop/digits.yaml
    name: digits
    base: ubuntu@22.04
    sdks:
      - name: torchaudio
      - name: torchvision
    

    Launching this workshop would cause a conflict because both SDKs want to mount the same directory in the workshop, which is not allowed.

  1. To address this issue, bind the torchvision:hub plug to the torchaudio:hub plug by adding a bind attribute in the workshop definition:

    .workshop/digits.yaml
    name: digits
    base: ubuntu@22.04
    sdks:
      - name: torchaudio
      - name: torchvision
        plugs:
          hub:
            bind: torchaudio:hub
    
  2. Launch the workshop. Workshop now recognizes that torchvision:hub is bound to torchaudio:hub and therefore mounts a single directory for both plugs.

    $ workshop launch digits
    
  3. Verify the binding with workshop connections:

    $ workshop connections digits
    
      INTERFACE  PLUG                    SLOT                 NOTES
      mount      digits/torchaudio:hub   digits/system:mount  bind.1
      mount      digits/torchvision:hub  digits/system:mount  bind.1
    

    Both plugs share the same bind.1 note, which implies they reference the same mount.

  4. Any operation on one side automatically applies to the other. For example, after remounting torchaudio:hub, the information for torchvision:hub is updated as well:

    $ mkdir -p .cache/hub
    $ workshop remount digits/torchaudio:hub .cache/hub
    $ workshop info digits
    
      ...
      mounts:
        hub:
          host-source:      /home/user/digits/.cache/hub
          workshop-target:  /home/workshop/.cache/torch/hub
    

See also

Explanation:

Reference: