# `nf-core configs` create development workflow
## General Structure
```mermaid
graph TD;
A(__main__.py)-->B(configs/__init__.py);
B-->C(configs/create/__init__.py);
C-->Q1(configs/create/question1.py)
C-->Q2(configs/create/question2.py)
C-->Q3(configs/create/question3.py)
```
- `__main__.py`: Don't modify
- `configs/__init__.py`: Don't modify
- `configs/create/__init__.py`: Main question execution _order_ defined here (via 'screens')
- `configs/create/questionX.py`: Actual question layout and definitions go here
## Workflow
1. Make a new `.py` file under `configs/create/`
2. Refer to this file as a 'screen' (i.e., a page on the question flow), within `configs_create/__init__.py
- Screens must be referenced in the `SCREENS` directionary, and in the `on_button_press` function
2. Write the textual functions to the new `.py` file
- Import various textual widgets and UI elements
- Make general class for the screen
- Add a `compose` function within the class to define the questions
- Use the `TextInput` for very easy questions, use `TextInputWithHelp` (both defined in `utils.py`) for longer question to include more guidance
- Add `on_button_pressed` function to make interface interactive
4. Add new config elements to the utils `CreateConfig` base model class
5. Add validation of config elements to the utils CreateConfigs base model class with the corresponding classmethods
6. Add other 'general' functions to `utils.py`
7. Test with `nf-core configs create`
General notes:
- General guidance: copy from the `pipelines/create/` TUI!
- If you need to import output of one question to another _within_ the same screen, use the `query_one()` function (see `basicdetails.py` and `on_input_changed`)
- If you want to have a simuletaenous `textual` debug console
One time
```
pip install -r requirements-dev.txt # one time
```
Then run in one terminal (to get back end printing)
```
textual console ## To have just user `prints()` being displayed include: -x SYSTEM -x EVENT -x DEBUG -x INFO
```
And in a second, to simulate running the app
```
textual run --dev -c nf-core configs create
```
This will open a separate terminal alongside the textual app (as executed by `nf-core pipelines create`), so you can click stuff in the main terminal but see what textual is doing in the backend behind
## Open Issues
Open questions:
- Do we put long-descriptions in text boxes above, or with a `show_help` button for all types of options
- The latter will require creating custom widgets for all question widgets?
- Why do all the TextInputWithHelp fields have a scrollbar?!
Answers:
- How to retrieve answers from previous questions?
- use the `query_one` function
- Can you dynamically build e.g. descriptions based on previous questions
- See the `on_input_changed` function in Basicdetails
- May need to make own 'widgets' (e.g. PipelineFeature), e.g. when wanting to customise the input interface: e.g. having helptext button next to a text box
- How should we write store answers?
- Define a pyDantic model (`CreateConfig()` class defined in `utils.py` in pipelines) - which is a bit like a over-powered dictionary
- Store information
- Validate information
- Load this into `__init__.py` with `TEMPLATE_CONFIG = CreateConfig()` (ex. from pipelines create)
- Write to this e.g. `self.parent.TEMPLATE_CONFIG.__dict__.update({"skip_features": skip, "is_nfcore": False})` (ex. from pipelines create)
- Refer to the contents within screen question files with `self.parent.TEMPLATE_CONFIG.outdir` (ex. from pipelines create)
- How to add input validation?
- See pydantic model above