Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Specific Configuration of the loading of tasks #538

Open
pradyunsg opened this issue Jun 11, 2018 · 2 comments
Open

Project Specific Configuration of the loading of tasks #538

pradyunsg opened this issue Jun 11, 2018 · 2 comments

Comments

@pradyunsg
Copy link

pradyunsg commented Jun 11, 2018

What's the problem this feature will solve?
What I'm trying to do is move all the files that are supporting tooling/code for the project into a tools/ directory. Invoke's tasks/ folder is one folder that I can not move since it doesn't support configuration of the loading of tasks.

If I am able to configure the loading process, I can:

  • have the clarity of the tools/ directory
  • allow other contributors of the project to use invoke without any additional configuration or CLI arguments, on their end
  • work on other codebases that use invoke without having to pass CLI arguments

Essentially, I will not have to manage the location of the tasks module every time I switch to a different project.

Describe the solution you'd like
One straightforward solution that comes to my mind is loading configuration files from the current directory in the first stage -- before discovering tasks.

Yet another way to achieve this would be to enable this via #537 (which IMO would be really nice).

Alternative Solutions
I am currently using a tasks/ package outside of the tools/ directory but being able to move that into tools/ would be nice. :)

@bitprophet
Copy link
Member

Unless I'm missing something, you should be able to configure this already using the approaches outlined in the docs here: http://docs.pyinvoke.org/en/1.0/concepts/loading.html#configuring-the-loading-process

As you may be able to guess, this tactic only works if you put the tasks.collection_name configuration somewhere that is loaded prior to seeking the collection itself - currently that'd be user, system or runtime level config files.

A quick example from my invoke-1.0.0 using localhost, with no actual valid task files in play so we get the "what was it looking for?" error message:

[14:18] tachi:~/tmp {-} [master]
» inv -l                                                                                            
Can't find any collection named 'tasks'!
[14:19] tachi:~/tmp {-} [master]
» echo "tasks:                                                                                      
dquote>     collection_name: something_else
dquote> " > ~/.invoke.yml
[14:19] tachi:~/tmp {-} [master]
» inv -l
Can't find any collection named 'something_else'!

@bitprophet
Copy link
Member

bitprophet commented Jun 21, 2018

Actually, I realize I'm misreading some of what you wrote, you're saying "their root directory" - I interpreted this as home directory but I think you do literally mean the project directory.

In that case, this becomes an order of operations design problem, because project-level config files do not currently get loaded until after the tasks collection is found, because "the project root" is defined as "where the tasks collection lives". Makes this particular request a bit of a chicken and egg problem!

I assume that the most obvious workaround is to add another pseudo-config-level of "invocation $CWD", which a lot of tools (IMHO not always correctly!) use as a stand-in for actual project root.

As you note, #537 (which would still I think need to be done in tandem with some explicit "we will look for some things in CWD instead of next-to-the-tasks-collection" additions) might be a better way to solve this, instead of making the built-in config stuff that much more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants