Skip to content

dependencies is a set not a list #254

Open

Description

@dvot197007

Hello,
The documentation section titled "keywords with task metadata" says:

dependencies: list of file_dep

In trying dependencies[0] in a task, the interpreter told me that dependencies is actually a set and can't be indexed. Hence, the documentation should be changed to reflect that.

By the way, the work around suggested on stack exchange is to use list(dependencies)[0].

I haven't checked, but it may be that the keyword 'changed' also refers to a set rather than a list as stated in the documentation?

Thanks,
David

Activity

  1. schettino72 commented on May 26, 2018

    @schettino72
    Member

    I think better change the code 😄

    Internally doit converts file_dep to set but i think it makes more sense to pass a list as mentioned in the docs.

    Should be an easy fix...

  2. added this to the 0.32 milestone on May 26, 2018
  3. averagehat commented on Aug 1, 2019

    @averagehat

    Is the order of dependencies passed to the command or python actions guaranteed?

    I would think it would match the order it was declared in the task's dictionary. i.e. if I only specify file_dep to be a list of [a, b, c] then %(dependencies)s should guarantee a b c and not b c a.

  4. valrus commented on Nov 24, 2019

    @valrus

    I just ran into this - the order seems to be arbitrary. I specified a file_depas ['a.txt', 'b.txt'] and then in the task assigned a, b = dependencies. I ended up with a == 'b.txt' and b == 'a.txt'.
    This was quite surprising.

  5. schettino72 commented on Nov 24, 2019

    @schettino72
    Member

    can you try master? i will do a release next week (hopefully).

  6. valrus commented on Nov 25, 2019

    @valrus

    Just checked and it looks like the order of dependencies is maintained in master. Thanks @schettino72!

  7. valrus commented on Nov 25, 2019

    @valrus

    Oops, I was mistaken - sorry. dependencies is now a list, not a set, but apparently it's still a set somewhere in the process because the order of the list isn't stable. I stuck a debugger call in a Task and ran it twice, inspecting a two-element dependencies list during each run, and the first run had ['a.txt', 'b.txt'] and the second had ['b.txt', 'a.txt'].

  8. removed this from the 0.32 milestone on Mar 4, 2021
  9. added a commit that references this issue on Jun 30, 2022
    af4283e
  10. gambolputty commented on Aug 8, 2022

    @gambolputty

    Just ran into this. I have a task that has several dependencies of different type (data structure). How am I supposed to process them, when the order from the file_dep-field is not preserved? I can't split it into multiple tasks.
    Are file dependencies supposed to be of the same type in doit, because of set()?

  11. added a commit that references this issue on Aug 16, 2022
    65ac309
  12. sdahdah commented on Oct 10, 2023

    @sdahdah
    Contributor

    @schettino72 if the order of file_dep is not guaranteed, what's the expected/correct way to handle multiple file dependencies? I'm still struggling with this today, and I've resorted to searching the file paths for substrings.

  13. schettino72 commented on Oct 10, 2023

    @schettino72
    Member

    @sdahdah why would you need the order of file_dep to be guaranteed?

    @gambolputty just save your structure of which filename is what in a separate place. I guess you could use the meta task parameter for this.

  14. sdahdah commented on Oct 10, 2023

    @sdahdah
    Contributor

    @schettino72 Thanks for answering so fast. I have two different datasets from different sensors that are both required by the algorithm I'm running. One is a CSV and one is a pickle.

    My current workaround is to search the dependency list for *.pickle to load the first file, and *.csv to load the second file. How would you recommend I handle this? I'd appreciate any insight you have

  15. schettino72 commented on Oct 11, 2023

    @schettino72
    Member
    def task_hello():
        def python_hello(pickle, json, dependencies):
            print(f'Dependencies are: {dependencies}')
            print(f'pickle is: {pickle}')
            print(f'json is: {json}')
    
        pickle = 'foo.pickle'
        json = 'bar.json'
        return {
            'actions': [(python_hello, [pickle, json])],
            'file_dep': [pickle, json],
            'verbosity': 2,
        }
    
  16. sdahdah commented on Oct 11, 2023

    @sdahdah
    Contributor

    @schettino72 This makes sense! I was making all my Python actions have the signature python_hello(dependencies, targets). I did not realize adding extra parameters was the way to go. Thank you!

  17. cosineblast commented on Jan 19, 2024

    @cosineblast

    I think dependency order preservation is great when the order of the input files to a program affect the hash of the output, and you expect doit to compile your files and produce an output with a specific hash.

  18. added a commit that references this issue on Nov 13, 2025
    2744307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions