Skip to content

Instantly share code, notes, and snippets.

@jeamland
Last active July 7, 2017 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeamland/dbc46c2dd429b0ad49da5a8f4bf81855 to your computer and use it in GitHub Desktop.
Save jeamland/dbc46c2dd429b0ad49da5a8f4bf81855 to your computer and use it in GitHub Desktop.
> invoke --debug build_image --clean build --clean
invoke.program._parse: No default namespace provided, trying to load one from disk
invoke.loader.find: FilesystemLoader find starting at '/src/kth'
invoke.loader.find: Found module: '/src/kth/tasks.py'
invoke.parser.__init__: Adding <parser/Context 'build_image': {'clean': <Argument: clean (c) [bool]>}>
invoke.parser.__init__: Adding <parser/Context 'build': {'clean': <Argument: clean (c) [bool]>}>
invoke.program.parse_tasks: Parsing tasks against <Collection 'tasks': build, build_image>
invoke.parser.__init__: Initialized with context: <parser/Context: {'complete': <Argument: complete [bool]>, 'debug': <Argument: debug (d) [bool]>, 'write-pyc': <Argument: write-pyc [bool]>, 'echo': <Argument: echo (e) [bool]>, 'config': <Argument: config (f)>, 'help': <Argument: help (h) ?>, 'hide': <Argument: hide>, 'list': <Argument: list (l) [bool]>, 'pty': <Argument: pty (p) [bool]>, 'version': <Argument: version (V) [bool]>, 'warn-only': <Argument: warn-only (w) [bool]>, 'collection': <Argument: collection (c)>, 'no-dedupe': <Argument: no-dedupe [bool]>, 'root': <Argument: root (r)>}>
invoke.parser.__init__: Available contexts: {'build_image': <parser/Context 'build_image': {'clean': <Argument: clean (c) [bool]>}>, 'build': <parser/Context 'build': {'clean': <Argument: clean (c) [bool]>}>}
invoke.parser.complete_context: Wrapping up context None
invoke.parser.parse_argv: Starting argv: ['build_image', '--clean', 'build', '--clean']
invoke.parser.handle: Handling token: 'build_image'
invoke.parser.changing_state: ParseMachine: 'context' => 'context'
invoke.parser.complete_context: Wrapping up context None
invoke.parser.switch_to_context: Moving to context 'build_image'
invoke.parser.switch_to_context: Context args: {'clean': <Argument: clean (c) [bool]>}
invoke.parser.switch_to_context: Context flags: {'--clean': <Argument: clean (c) [bool]>}
invoke.parser.switch_to_context: Context inverse_flags: {}
invoke.parser.handle: Handling token: '--clean'
invoke.parser.handle: Saw flag '--clean'
invoke.parser.switch_to_flag: Moving to flag <Argument: clean (c) [bool]>
invoke.parser.switch_to_flag: Marking seen flag <Argument: clean (c) [bool]> as True
invoke.parser.handle: Handling token: 'build'
invoke.parser.changing_state: ParseMachine: 'context' => 'context'
invoke.parser.complete_context: Wrapping up context 'build_image'
invoke.parser.switch_to_context: Moving to context 'build'
invoke.parser.switch_to_context: Context args: {'clean': <Argument: clean (c) [bool]>}
invoke.parser.switch_to_context: Context flags: {'--clean': <Argument: clean (c) [bool]>}
invoke.parser.switch_to_context: Context inverse_flags: {}
invoke.parser.handle: Handling token: '--clean'
invoke.parser.handle: Saw flag '--clean'
invoke.parser.switch_to_flag: Moving to flag <Argument: clean (c) [bool]>
invoke.parser.switch_to_flag: Marking seen flag <Argument: clean (c) [bool]> as True
invoke.parser.changing_state: ParseMachine: 'context' => 'end'
invoke.parser.complete_context: Wrapping up context 'build'
invoke.program.parse_tasks: Resulting task contexts: [<parser/Context 'build_image': {'clean': <Argument: clean (c) [bool]>}>, <parser/Context 'build': {'clean': <Argument: clean (c) [bool]>}>]
invoke.config._load_file: Didn't see any /etc/invoke.yaml, skipping.
invoke.config._load_file: Didn't see any /etc/invoke.yml, skipping.
invoke.config._load_file: Didn't see any /etc/invoke.json, skipping.
invoke.config._load_file: Didn't see any /home/benno/.invoke.yaml, skipping.
invoke.config._load_file: Didn't see any /home/benno/.invoke.yml, skipping.
invoke.config._load_file: Didn't see any /home/benno/.invoke.json, skipping.
invoke.config._load_file: Didn't see any /src/kth/invoke.yaml, skipping.
invoke.config._load_file: Didn't see any /src/kth/invoke.yml, skipping.
invoke.config._load_file: Didn't see any /src/kth/invoke.json, skipping.
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.executor.execute: Examining top level tasks [<parser/Context 'build_image': {'clean': <Argument: clean (c) [bool]>}>, <parser/Context 'build': {'clean': <Argument: clean (c) [bool]>}>]
invoke.executor.execute: Tasks (now Calls) with kwargs: [<Call 'build_image', args: (), kwargs: {'clean': True}>, <Call 'build', args: (), kwargs: {'clean': True}>]
invoke.executor.expand_calls: Expanding task-call <Call 'build_image', args: (), kwargs: {'clean': True}>
invoke.executor.expand_calls: Expanding task-call <Call 'build', args: (), kwargs: {'clean': True}>
invoke.executor.expand_calls: Expanding task-call <Call 'build_image', args: (), kwargs: {}>
invoke.executor.dedupe: Deduplicating tasks...
invoke.executor.dedupe: <Call 'build_image', args: (), kwargs: {'clean': True}>: no duplicates found, ok
invoke.executor.dedupe: <Call 'build_image', args: (), kwargs: {}>: no duplicates found, ok
invoke.executor.dedupe: <Call 'build', args: (), kwargs: {'clean': True}>: no duplicates found, ok
invoke.executor.execute: Executing <Call 'build_image', args: (), kwargs: {'clean': True}>
invoke.config.load_collection: Loading collection configuration
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Running pre-merge for shell env loading...
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Done with pre-merge.
invoke.env.load: Scanning for env vars according to prefix: 'INVOKE_', mapping: {'RUN_WARN': ['run', 'warn'], 'RUN_HIDE': ['run', 'hide'], 'RUN_SHELL': ['run', 'shell'], 'RUN_PTY': ['run', 'pty'], 'RUN_FALLBACK': ['run', 'fallback'], 'RUN_REPLACE_ENV': ['run', 'replace_env'], 'RUN_ECHO': ['run', 'echo'], 'RUN_ENCODING': ['run', 'encoding'], 'RUN_OUT_STREAM': ['run', 'out_stream'], 'RUN_ERR_STREAM': ['run', 'err_stream'], 'RUN_IN_STREAM': ['run', 'in_stream'], 'RUN_WATCHERS': ['run', 'watchers'], 'RUN_ECHO_STDIN': ['run', 'echo_stdin'], 'RUNNERS_LOCAL': ['runners', 'local'], 'SUDO_PROMPT': ['sudo', 'prompt'], 'SUDO_PASSWORD': ['sudo', 'password'], 'SUDO_USER': ['sudo', 'user'], 'TASKS_DEDUPE': ['tasks', 'dedupe']}
invoke.env.load: Obtained env var config: {}
invoke.config.load_shell_env: Loaded shell environment, triggering final merge
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.executor.execute: Finished loading collection & shell env configs
Build image clean: True
invoke.executor.execute: Executing <Call 'build_image', args: (), kwargs: {}>
invoke.config.load_collection: Loading collection configuration
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Running pre-merge for shell env loading...
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Done with pre-merge.
invoke.env.load: Scanning for env vars according to prefix: 'INVOKE_', mapping: {'RUN_WARN': ['run', 'warn'], 'RUN_HIDE': ['run', 'hide'], 'RUN_SHELL': ['run', 'shell'], 'RUN_PTY': ['run', 'pty'], 'RUN_FALLBACK': ['run', 'fallback'], 'RUN_REPLACE_ENV': ['run', 'replace_env'], 'RUN_ECHO': ['run', 'echo'], 'RUN_ENCODING': ['run', 'encoding'], 'RUN_OUT_STREAM': ['run', 'out_stream'], 'RUN_ERR_STREAM': ['run', 'err_stream'], 'RUN_IN_STREAM': ['run', 'in_stream'], 'RUN_WATCHERS': ['run', 'watchers'], 'RUN_ECHO_STDIN': ['run', 'echo_stdin'], 'RUNNERS_LOCAL': ['runners', 'local'], 'SUDO_PROMPT': ['sudo', 'prompt'], 'SUDO_PASSWORD': ['sudo', 'password'], 'SUDO_USER': ['sudo', 'user'], 'TASKS_DEDUPE': ['tasks', 'dedupe']}
invoke.env.load: Obtained env var config: {}
invoke.config.load_shell_env: Loaded shell environment, triggering final merge
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.executor.execute: Finished loading collection & shell env configs
Build image clean: False
invoke.executor.execute: Executing <Call 'build', args: (), kwargs: {'clean': True}>
invoke.config.load_collection: Loading collection configuration
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Running pre-merge for shell env loading...
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.config.load_shell_env: Done with pre-merge.
invoke.env.load: Scanning for env vars according to prefix: 'INVOKE_', mapping: {'RUN_WARN': ['run', 'warn'], 'RUN_HIDE': ['run', 'hide'], 'RUN_SHELL': ['run', 'shell'], 'RUN_PTY': ['run', 'pty'], 'RUN_FALLBACK': ['run', 'fallback'], 'RUN_REPLACE_ENV': ['run', 'replace_env'], 'RUN_ECHO': ['run', 'echo'], 'RUN_ENCODING': ['run', 'encoding'], 'RUN_OUT_STREAM': ['run', 'out_stream'], 'RUN_ERR_STREAM': ['run', 'err_stream'], 'RUN_IN_STREAM': ['run', 'in_stream'], 'RUN_WATCHERS': ['run', 'watchers'], 'RUN_ECHO_STDIN': ['run', 'echo_stdin'], 'RUNNERS_LOCAL': ['runners', 'local'], 'SUDO_PROMPT': ['sudo', 'prompt'], 'SUDO_PASSWORD': ['sudo', 'password'], 'SUDO_USER': ['sudo', 'user'], 'TASKS_DEDUPE': ['tasks', 'dedupe']}
invoke.env.load: Obtained env var config: {}
invoke.config.load_shell_env: Loaded shell environment, triggering final merge
invoke.config.merge: Merging config sources in order onto new empty _config...
invoke.config.merge: Defaults: {'run': {'warn': False, 'hide': None, 'shell': '/bin/bash', 'pty': False, 'fallback': True, 'env': {}, 'replace_env': False, 'echo': False, 'encoding': None, 'out_stream': None, 'err_stream': None, 'in_stream': None, 'watchers': [], 'echo_stdin': None}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'prompt': '[sudo] password: ', 'password': None, 'user': None}, 'tasks': {'dedupe': True}}
invoke.config.merge: Collection-driven: {}
invoke.config._merge_file: System-wide config file (/etc/invoke.py): {}
invoke.config._merge_file: Per-user config file (/home/benno/.invoke.py): {}
invoke.config._merge_file: Per-project config file (/src/kth/invoke.py): {}
invoke.config.merge: Environment variable config: {}
invoke.config._merge_file: Runtime config file has not been loaded yet, skipping
invoke.config.merge: Overrides: {'run': {}, 'tasks': {}}
invoke.config.merge: Modifications: {}
invoke.config.merge: Deletions: {}
invoke.executor.execute: Finished loading collection & shell env configs
Build clean: True
from invoke import task
# Ideally I'd like build_image to have the clean flag and have it arrive from
# the command line. I'd settle for it coming from the build task. At the
# moment what I get is this:
#
# > invoke build
# Build image clean: False
# Build clean: False
# > invoke build --clean
# Build image clean: False
# Build clean: True
# > invoke build_image build --clean
# Build image clean: False
# Build image clean: False
# Build clean: True
# > invoke build_image --clean build --clean
# Build image clean: True
# Build image clean: False
# Build clean: True
@task
def build_image(ctx, clean=False):
print('Build image clean:', clean)
@task(pre=[build_image])
def build(ctx, clean=False):
print('Build clean:', clean)
@bitprophet
Copy link

bitprophet commented Jul 7, 2017

Believe I noted in an earlier Twitter thread, Invoke pre/post tasks are super limited right now in terms of their call signature & relation to main task :(

That final explicit invocation should have deduped, though, and ended up with just Build image clean: True + Build clean: True. So that might be a legit bug.

Curious what output looks like with --debug given or INVOKE_DEBUG=1 set in shell env, should have debug log lines about the deduping.

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