Skip to content

Configuration files #3367

Closed
Closed

Description

@mrocklin

Currently the dask/distributed repository maintains configuration information in ~/.dask/... and in particular the file ~/.dask/config.yaml. This configuration has grown organically over time and may not be ideal. If we're going to make a change then we might make a few changes at once:

  1. Move to ~/.config/dask/... which seems to be standard
  2. Move configuration parsing logic from dask/distributed to dask/dask
  3. Perhaps re-organize and clean up our current configuration files

It would be good to collect feedback about current standards before undertaking this work. Presumably there is a lot we can learn from others.

cc @ogrisel

Activity

  1. martindurant commented on Apr 2, 2018

    @martindurant
    Member

    You might consider https://github.com/ActiveState/appdirs to place config files , so as to not worry about how things are done on different platforms; then would need a top-level function and/or text during startup to display this path to the user.

  2. ogrisel commented on Apr 3, 2018

    @ogrisel
    Contributor

    Actually, configuration should rather go to ~/.config/dask according to https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html ~/.local/share/dask is more user data.

  3. jakirkham commented on Apr 5, 2018

    @jakirkham
    Member

    Jupyter has generally spent a lot of time with configuration files (and their layout). Maybe @minrk could offer some good advice here (if you have time Min).

  4. minrk commented on Apr 5, 2018

    @minrk
    Contributor

    I'm not sure what dask should do, but a few things we learned from building the Jupyter config layout after learning from IPython:

    • clearly separating config from data/runtime files is good and can avoid permission issues. Try to never put runtime-generated files in the config directory.
    • loading system-wide and per-env config is useful, especially when building docker images (we load from /etc/jupyter and {sys.prefix}/etc/jupyter in addition to ~/.jupyter)
    • there's a tricky tradeoff between being good platform citizens (~/Library on macOS, XDG on Linux, etc.) and being consistent (e.g. just use ~/.dask or ~/.config/dask), especially for directories that users will manually interact with.

    Following platform standards for this can be nice, but it also makes documentation of paths more complicated and following configuration documentation more confusing for users. If you do something like this, make sure you provide a simple path discovery entrypoint (we have jupyter --paths, jupyter --config-dir, etc.). There is disagreement among mac users about whether tools should pretend that macs follow XDG specs like linux and use ~/.config (not a mac standard) vs using the mac's standard ~/Library paths vs top-level ~/.dask. After briefly following XDG in IPython on Linux, we switched back to platform-insensitive ~/.ipython because we found the confusion caused by this directory having variable locations caused a lot more pain than it was worth.

    Based on our experience in IPython/Jupyter, I would use a platform-insensitive path (~/.dask or ~/.config/dask) for a config directory that users are expected to interact with manually. Programmatically interacted-with paths (runtime files, side effects of installation/other entrypoints etc.) can follow platform standards more easily and appdirs seems like a handy implementation of that. In particular, respecting cache and runtime directory environment variables (if you have such files) can be useful on managed systems, which set these to scratch disks, etc.

  5. mrocklin commented on Apr 24, 2018

    @mrocklin
    MemberAuthor

    How do people feel about Dask depending on yaml?

  6. mrocklin commented on Apr 24, 2018

    @mrocklin
    MemberAuthor

    or at least dask.distributed?

  7. martindurant commented on Apr 24, 2018

    @martindurant
    Member

    How do people feel about Dask depending on yaml

    I think its reasonable.

  8. jakirkham commented on Apr 24, 2018

    @jakirkham
    Member

    So dask.distributed has a soft dependency on yaml currently. The suggestion is hardening it? Yeah that could be ok.

    Requiring yaml for just dask might be off putting for people. My impression thus far is we are not comfortable requiring toolz there. yaml is a much bigger ask than a pure Python, 2/3 compatible, no extra deps package like toolz.

    Taking a step back (given this issue is a 1.0 blocker), I think it is worth evaluating generally whether we are still comfortable with yaml. There are some pros like users are already familiar with it, human readable, etc. There are also some cons heavy dependency, requires C library, complex spec, some security issues (safe_load), maintenance of the flagship library for Python PyYAML has been weak (though improving some in recent months). It's probably also worth generally reviewing what the alternatives are (JSON, TOML, AXON, etc.). Not that we even have to switch. Just this is a good time to take stock, reexamine what we hope to get out of the config format, and see what options best fit our needs.

  9. mrocklin commented on Apr 24, 2018

    @mrocklin
    MemberAuthor
  10. jakirkham commented on Apr 24, 2018

    @jakirkham
    Member

    Do we have a (formal) spec for what we are looking for in this config? We've discussed a bit about location here. We also discussed a bit in person about what sorts of things we might like to see in it down the road. It's just not clear to me yet how this forms the spec. IOW what things do we expect to find in the config long term, what things plan to use it, and what are the bare minimum requirements needed to represent it?

  11. mrocklin commented on Apr 25, 2018

    @mrocklin
    MemberAuthor
  12. mrocklin commented on Apr 25, 2018

    @mrocklin
    MemberAuthor

    So in working through this in #3432 I've run across a few questions

    Where do we specify defaults?

    Currently we provide a commented-out config file in the user's space if possible:

    # Set logging level
    # logging: info

    And we include default values in the codebase itself

    logging_level = config.get('logging', default='info')

    We do this because we often want to change the default values over time, but don't want to muck with the user's files in case they have already modified the config file.

    However this becomes somewhat cumbersome and results in a lot of repetition over time, especially when we use the same config value in many places in the codebase or when those values tend to shift over time (I recently went through and changed all of our default timeouts for example).

    I'm curious if we should instead include an uncommented config file in the codebase where we maintain defaults, comment-and-write this to the user's directory if it's not there, and copy it to a location of default configs uncommented that we feel comfortable overwriting whenever we please (perhaps {sys.prefix}/etc/dask/defaults).

    Other suggestions would be welcome.

    When do we write an empty config file to user space?

    Currently we try to write config files to the user's home directory on first import of the project if they don't already exist. This mostly works, but can get a bit odd if you import dask (which gets the configuration), then import dask_foo (which creates a new config file) and find that those values aren't in the configuration.

    I wonder if instead we should do this at installation time. If so, how hard is this to do?

    Alternatively we could follow other projects and do this from the command line with some sort of dask config init tool.

  13. mrocklin commented on Apr 26, 2018

    @mrocklin
    MemberAuthor

    We could also use .py files for configuration. Jupyter does this.

  14. mrocklin commented on Apr 29, 2018

    @mrocklin
    MemberAuthor

    My current plan if no one speaks up is the following:

    1. Use yaml
    2. Depend on yaml in dask.distributed, but not core dask
    3. Maintain uncommented-out yaml files in source directories that are maintained as baseline configurations
    4. By convention on first import of a project we comment out the configuration file and put it in ~/.config/dask/
    5. By convention on import of a project we read in its uncommented-out version from the source directory and add it as a baseline to the configuration

    I'll start implementing this tomorrow if there is no further conversation.

  15. jakirkham commented on Apr 30, 2018

    @jakirkham
    Member

    My concern with using yaml is basically that we won't feel comfortable using it Dask proper (without Distributed) and it will result in more of the status quo. Namely a disparity between Dask and Dask + Distributed. If we pick something simple and easy to use for a configuration file, we will feel more comfortable using that configuration file in Dask.

  16. mrocklin commented on Apr 30, 2018

    @mrocklin
    MemberAuthor

    I'm not sure I understand. I'm proposing that we use YAML everywhere, but that we write dask/dask so that it can work even if it can't read the config files.

    For dask/distributed we do not take care to make the project resilient to not being able to read the configuration files. The dask/distributed project has a bunch more configuration than dask/dask, so it's more of a pain to keep default values within the code itself.

  17. mrocklin commented on Apr 30, 2018

    @mrocklin
    MemberAuthor

    Looking at dask/distributed#1948 might be informative of what these changes mean for dask/distributed.

    For dask/dask there is no pragmatic difference, other than that there is now some code in dask/config.py to handle configuration for all of the downstream projects.

  18. dhirschfeld commented on May 2, 2018

    @dhirschfeld

    Since conda depends on YAML it basically comes with Python as far a I (and every other Anaconda user) are concerned. That being the case, I'm obviously fine with the dep for either of distributed or dask.

    For non-anaconda users, is a dependency on a YAML library that much of a concern? The deployment situation with pip/Python is so much smoother/easier these days* that I think it's much less of a concern than it used to be.

    * Notwithstanding xkcd digs 😛

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions