Coder Social home page Coder Social logo

martvanrijthoven / dicfg Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 2.88 MB

Dicfg is a configuration system that supports dependency injection via object interpolation in config files.

Home Page: https://martvanrijthoven.github.io/dicfg/

License: MIT License

Python 100.00%
config configuration dependency-injection interpolation json-configuration yaml-configuration

dicfg's People

Contributors

martvanrijthoven avatar pre-commit-ci[bot] avatar robinlomans avatar

Watchers

 avatar

Forkers

robinlomans

dicfg's Issues

ConfigReader.read() fails on reading cli_config

The read() method of ConfigReader attempts to read the cli arguments and merge them with the user_config. There are two issues with this:

  1. I find this unexpected behaviour and would argue that it makes sense to make this functionality optional, e.g. by adding an optional flag parameter to the read method, specifying whether to add cli arguments or not. A potential situation in which I can see this causing issues is if I run my main script with certain cli arguments that are meant for other parts of the script and that can potentially conflict with config parameters in my user_config. For example, if I were to specify an X number of cpus as a cli arg, but I want Y cpus for the batchiterator (configured in the iterator_config file).

  2. The more important issue is that the _read_cli method causes an error in my case:

    File "/usr/local/lib/python3.9/site-packages/wholeslidedata/iterators/batchiterator.py", line 150, in create_batch_iterator
      config = config_reader.read(user_config=user_config, presets=presets)
    File "/usr/local/lib/python3.9/site-packages/dicfg/reader.py", line 102, in read
      cli_config = self._read_cli(sys.argv[1:])
    File "/usr/local/lib/python3.9/site-packages/dicfg/reader.py", line 138, in _read_cli
      dicts.append(_create_dict_from_keys(keys, value))
    File "/usr/local/lib/python3.9/site-packages/dicfg/reader.py", line 160, in _create_dict_from_keys
      value = ast.literal_eval(value)
    File "/usr/local/lib/python3.9/ast.py", line 62, in literal_eval
      node_or_string = parse(node_or_string, mode='eval')
    File "/usr/local/lib/python3.9/ast.py", line 50, in parse
      return compile(source, filename, mode, flags,
    File "<unknown>", line 1
      <a_redacted_path>
      ^
  SyntaxError: invalid syntax

ast.literal_eval raises a SyntaxError because the value it tries to read is a string containing some path, e.g. /data/pathology/users/robin/some_path, which it cannot parse. It would need to have an extra set of quotation marks around it to be parsed properly by literal_eval,.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.