Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have pyani use a user-controlled config file #146

Open
widdowquinn opened this issue Oct 2, 2019 · 4 comments
Open

Have pyani use a user-controlled config file #146

widdowquinn opened this issue Oct 2, 2019 · 4 comments
Assignees
Labels
enhancement something we'd like pyani to do that it doesn't already interface issues related to how the user tells pyani to do something
Milestone

Comments

@widdowquinn
Copy link
Owner

Summary:

The current config arrangement is hacky and awful. It would be better to have a user-controlled config file that specifies colour palettes, application locations and so on. This could be defined in environment variables and/or a config.py or config.json file.

An extension of this could be used for pipeline control of the pyani chain.

@widdowquinn widdowquinn self-assigned this Oct 2, 2019
@widdowquinn widdowquinn added the enhancement something we'd like pyani to do that it doesn't already label Oct 2, 2019
@widdowquinn widdowquinn added this to the 0.3.0 milestone May 28, 2020
@widdowquinn widdowquinn added the interface issues related to how the user tells pyani to do something label May 29, 2020
@baileythegreen
Copy link
Contributor

baileythegreen commented Sep 5, 2021

Proposed format: .toml for readability.

Options to include:

  • custom paths for executables†
  • colour scheme used for plots†
  • input and output directories
  • modifiable parameters for the algorithms†
  • algorithm itself?

† should have a default value on which to fall back

@widdowquinn
Copy link
Owner Author

Default values could continue to be defined as they are now, in a top-level config.py (or even TOML) file, e.g.:

import os

from dotenv import load_dotenv

BASEDIR = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(BASEDIR, ".env"))


class Config(object):
    # Database configuration
    TEST_DBPATH = os.path.join(BASEDIR, "testdb.sqlite")
    DBPATH = os.environ.get("SRE_DBPATH") or TEST_DBPATH

    # Flask app configuration
    SREDB_HOST = "127.0.0.1"
    SREDB_PORT = "5000"
    FLASK_SECRET_KEY = os.environ.get("FLASK_SECRET_KEY") or os.urandom(24)
    SQLALCHEMY_DATABASE_URI = os.environ.get(
        "SREDB_DBURL"
    ) or "sqlite:///" + os.path.join(BASEDIR, DBPATH)
    SQLALCHEMY_TRACK_MODIFICATIONS = False

values are then imported as a Config object:

from config import Config

which can be used to populated, for example, the argparse default values and/or anything that's not present in the user-defined TOML.

@baileythegreen
Copy link
Contributor

I was assuming the default values would be in pyani_config.py. Anything similar thing would be fine, but defaults definitely don't need to be in a file the user would generally modify.

@widdowquinn
Copy link
Owner Author

I was assuming the default values would be in pyani_config.py.

Yes - it seems a sensible place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement something we'd like pyani to do that it doesn't already interface issues related to how the user tells pyani to do something
Projects
None yet
Development

No branches or pull requests

2 participants