Triage (CLI) configuration and pluggability
- Dominant language
- Jupyter Notebook
- Stars
- 201
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
*Note*: I realize that this issue should be divided in several subissues. Nevertheless I am creating it because I wanted to have the original @jesteria post in one place accessible to all)
(All the following is from the @jesteria's slack post):
***My project***
```
/
└── experiment.py
```
**CLI**
`$ triage [-s|--setup PATH] ...`
* CLI looks for and optionally loads Python module experiment in CWD
i.e. argument --setup defaults to `os.path.join(os.curdir, 'experiment.py')` -- ...IFF this file exists
* If setup desired, but at different path, can specify `--setup`, or envvar `TRIAGE_SETUP`
**Setup module**
Probably should just be a general entrypoint, allowed to execute arbitrary code, (rather than expected to merely define settings, like Django's settings.py).
* User gets (optionally) a Pythonic entrypoint, e.g. for setup of SQLAlchemy listeners (yay!)
* Triage gets (optionally) functional specification of its configuration
E.g., `experiment.py:`
```{python}
from sqlalchemy.event import listens_for
from sqlalchemy.pool import Pool
from triage import config
@listens_for(Pool, "connect")
def my_on_connect(dbapi_con, connection_record):
print("New DBAPI connection:", dbapi_con)
config.update(
# no way I'm going to set this here -- triage.config respects envvars!
# database_url=...,
...
)
# I want an easy, bulk way of updating keys, without overwriting entire dictionaries (as __setitem__ and update would do)
# (Note, we could probably achieve the same with `update`, so this interface really isn't necessary, depending on how people like it.)
config.set(
temporal_config__feature_start_time='1905-01-01',
...
)
if os.getenv('PUDDING') == 'plentiful':
config['eat'] = 'it-all'
```
**Triage config**
* provides dict interface
* but backed by reasonable defaults: user setttings > envvar settings > library defaults
* Perhaps CLI imports triage.config, after loading experiment.py, and uses config to instantiate lower- level triage classes
We get:
* Pythonic pluggability in CLI
* the centralization of configuration
* a place to insert envvars
* lower-level classes unaffected by these concerns (of envvars and configuration, etc.)
Contributor guide
Research direction
Start with the CLI entry point `triage` and the referenced `experiment.py` setup module, then inspect how `triage.config` is currently defined and used. The issue is an umbrella for configuration, environment-variable precedence, setup-module loading, and pluggability; it is done only after these concerns are split into concrete, agreed subissues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100