bacalhau: Inconsistent behaviour: multiple `--inputs` fail, multiple `--input-urls` do not

This fails:

> bacalhau docker run \
    --inputs bafybeig3xawqpx2i2s6ct5nmfavmm5avyw5h364gzslgrmszgcufpf7zz4 \
    --inputs bafybeig63whfqyuvwqqrp5456fl4anceju24ttyycexef3k5eurg5uvrq4 \
    --wait \
    ubuntu ls /inputs
...
    Stderr:
      Error response from daemon: Duplicate mount point: /inputs

This runs but ignores the second input-urls:

❯ bacalhau docker run \
    --input-urls https://gist.githubusercontent.com/enricorotundo/4c7f158f20ae4997e710e66531b8b54f/raw/ee5228ea06117a6ae97a98fed4ae7b1f1776d564/hepscore-new.md \
    --input-urls https://gist.githubusercontent.com/enricorotundo/990f0ad01a50d08dfb580e4ad404870e/raw/aa6934257351a0da93f1e740c72f27128590cebc/foo_data.txt \
    --wait \
    ubuntu ls /inputs
...
    Stdout:
      foo_data.txt

Tested on v0.3.6

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

So I think we need to provide some clarification on what the job to be done here is. Currently:

  • Using multiple --inputs results in a (server-side) error
  • Using multiple --input-urls results in no error, but missing data

So the scope of this ticket is to ensure that both of those paths return an error, ideally on the client side before submission. So @kcmuspace please go ahead and pick this up if it sounds interesting.

@thetechnocrat-dev You can already use multiple CIDs using the --input-volumes flag, which can be specified multiple times. See https://docs.bacalhau.org/all-flags/#docker-run

@kcmuspace @enricorotundo, multiple CIDS would help us out at LabDAO. Just want to check in on timelines to start this ticket and how I can help get this over the finish line.

If we’re going to change it, why not go one step further and reduce it down to one flag which can optionally take a target mount point? Let’s explore that idea.

  • ANYTIHNG_SUPPORTED means:
    • An IPFS CID (anything that successfully parses in a call to Cid.parse)
    • A local filesystem path
    • A URL (the URL may support certain schemes that result in different storage types e.g. s3://)
  • --inputs ANYTHING-SUPPORTED:target-mount mounts ANYTHING-SUPPORTED into target-mount.
  • --inputs ANYTHING-SUPPORTED mounts ANYTHING-SUPPORTED into /inputs.
  • It is an error for two storagespecs to mount to the same place.
    • As a result, it is an error to use --inputs without a target-mount more than once.

What do you think?

I think the reason that this wasn’t already done is because URLs can of course contain colons, and it’s ambiguous whether that will be a target mount or part of the URL, e.g. with --inputs https://en.wikipedia.org/wiki/Template:Welcome, it’s not clear whether Welcome is a target-mount of part of the URL. However, URLs support percent-encoding, so a way out of this is just to require that colons in the path segment are percent-encoded (or people can just use a job spec).

There is another colon in the URL though, at the start in the protocol section.

I think this therefore would require parsing logic that looks like:

  1. Split the flag on the last colon, and try parsing the first part as a CID, file or URL and the last part as a target-mount.
  2. If this fails, try parsing the whole flag as a CID, file or URL and assume the user is targeting /inputs.

With a simple example of parsing https://example.com, this looks like:

  1. Parse https as the source and //example.com as the target mount.
    • https is not a valid CID, hopefully not an existant file, and is not a valid URL
    • //example.com is not a valid mount point (is this true? – it might be fine on Windows?)
    • So failed.
  2. Parse https://example.com as the source and "" as the target mount.
    • It is a valid URL, so ok.
    • Empty target mount defaults to /inputs, so ok.

… this does not really spark joy, does it? It fails ungracefully in the situation where there are oddly named files on the local filesystem, like https, and certainly is a bit complex to reason about.

So I think I agree with your simpler approach – by telling the client whether it should expect a target-mount component or not, we can do away with trying to deal with the ambiguity.

TL;DR: we should do what Enrico suggested.

Hello @simonwo. I would like to work on this issue.

I’m wondering if the desired behavior is accepting both inputs or making one flag consistent with the other.

Also, Could I have any background information/any pointers related to this bug? thank you so much 😃

Hi @enricorotundo . I’ve been trying but unfortunately I’ve made minimal progress(I think due to my unfamiliarity with the codebase). I can see that this issue is more important( and more complex) than I originally thought evidenced by the linked issues. Would this requirement need to be completed ASAP?

I think this could take me a while. I understand if someone more experienced wants to take over. I can work on something other than this.