Skip to content

Configuration defaults set per-module/etc #89

@bitprophet

Description

@bitprophet

Problem: distributing general tasks like in Invocations' docs module. can store default options for shit like 'sphinx source/build targets' in the module, and override at runtime, already. cannot obtain the docs module and attach it to my namespace with a different set of defaults, without doing stupid/fragile wrapping of the tasks.

Solution: get configuration working in the context that can be set in ways besides what the parser generates. feels like best way is to go through Collection since that's really the only link from a task to the context.

what happens now:

  • cli creates context (generated from some parser args affecting run's behavior which get turned into a top level 'run' subdict), obtains collection, hands both to executor
  • executor hands context to contextualized tasks
  • cli calls executor.execute() passing in the name of the task, the parser args given, etc

So we can implement updating the context w/ data from the collection in a few ways:

  • in the cli module, before creating the executor. not great, esp since this action should not require using the CLI itself - ought to be lib friendly
  • in executor, probably in __init__, maybe in execute
    • doing later allows more lazy tricks, but otoh we probably don't want to encourage modification of the context obj between tasks...
    • either way doing in executor is as low as we can go. probably fine.

In terms of how to set the info we'd need to expand the api of Collection somehow. not sure if constructor kwargs would work since those are used as shorthand for creating the namespace.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions