Comments (8)
Have much of this working now.
At one point, considered having the from_module
classmethod suck in Collection members of a module, but realized that the only really useful point of this is to ape the existing "recursively chew my imported modules" behavior, except with more boilerplate, and not actually removing any of the problems we have now with the implicit module tree crawl.
So I think it really makes the most sense to have convention be that you construct the namespace collection "in" one location, you import all the modules you need for your namespace, and explicitly from_module
them into your root Collection.
We might want to add a convenience method/kwarg to say "no I do want Fab 1 style import crawling behavior" (in which case we may as well just implement it Fab 1 style, no module-level Collection stuff) but I think it's best to leave it out for now and see if anybody complains. The inverse -- folks getting used to that being "the" way to do it, then running into all the issues we have now with Fab -- feels worse. Maybe.
Guess this is ye olde "make them go the explicit route off the bat because they'll need it eventually" random-script-files-vs-Web-frameworks argument really.
Also, the "I want something quick n easy" base case does still exist in the form of an unadulterated, no-collections-in-it tasks.py
, so it's not like true beginners have to write any explicit boilerplate besides @task
.
tl;dr remove any docs/tests mentioning that Collection.from_module
loads Collection instances, and power on.
from invoke.
Almost done now!
Realized that a module within a package has its full dotted path as __name__
, e.g. invocations.docs
, even when imported as from invocations import docs
, is still __name__
'd invocations.docs
.
- So we need to do something like grab the last dotted section, or say "you should always explicitly name any
from_module
results" (possibly by allowing the name to be given infrom_module
).- I can't think of any serious downsides of the former approach, though, and it's much easier for all involved.
- Cleanest might be to strip out
module.__package__
? Or would that still leave us with dots for sub-sub-modules? EDIT: hm sub-sub-modules don't even have anything in__package__
so scratch that.
from invoke.
Still almost there, things work at the Collection level and for --list
, but parsing is still somehow messing up such that namespaced tasks raise parse errors, poking/testing now.
from invoke.
Fixed, yay testing.
Only thing left (yes, there was another one. God bless dogfooding. Best testing ever.) is making default tasks show up in both --list
and parse contexts.
from invoke.
That one is actually not 100% obvious, I posted this gist to ask a few other folks their opinion, got some good answers already.
from invoke.
As of this comment on that gist (plus the followup) pretty sure I'm going to go with "don't show aliases/defaults as their own line, just parenthesized next to the 'real' item".
from invoke.
Got hilariously sidetracked as I found out the aliases feature was in fact entirely broken; boo on implementing only the lower levels of an API "in prep" for the full end-to-end.
Cannot for the life of me remember why I had Collection.add_task
accepting task alias and is-default values instead of deferring to the Task itself, unless it was so one could "rebind" a task under different aliases/default-ness (like we can with name). Seems pointless to me for now and meant that things were quite broken, so fixed all of that up and removed some tests in the process.
Hopefully back to even keel soon.
from invoke.
oh god it works!
from invoke.
Related Issues (20)
- Accept --no-echo to turn off run.echo
- Task decorator removes docstring HOT 1
- Run tasks relative to `tasks.py` HOT 2
- How to manually set short flags? HOT 1
- context.run(): Expose API to pass command and separate args instead of a single string HOT 2
- Specify a config file per Collection... possible?
- Collection mix-up when cross importing invoke tasks
- Running post tasks even if the main task fail
- `--help` after the command treats `--help` as positional argument HOT 2
- Is there support for making invoke.yaml context settings cli flags?
- EncodeWarning's when running on python >= 3.11
- @task(pre=[call(setup, 'qwe')]) fails with "NameError: name 'call' is not defined" HOT 1
- Config run should handle shell paths with spaces HOT 2
- Is it possible to only mock one command and run the rest with MockContext?
- autoprint generators correctly
- Generate help infomation of task args from function docstring.
- Importing Python modules from a scripts directory beside the tasks directory
- Recommended way to forward arguments to commands HOT 2
- Printing Promise objects from asynchronous Runner.run() raises Attribute Error
- Sudo showing password in clear
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invoke.