# Organizing parameters -- dataclasses and [dataconf](https://github.com/zifeo/dataconf)
{:.no_toc}
<navmarkdown="1"class="toc-class">
* TOC
{:toc}
</nav>
## The goal
In data science we have a lot of parameters in our simulations. Often the parameters are distributed over the whole source code. The combination of dataclass and dataconf allows it very easily to put the parameters in to a config file. dataconf supports many different config types. Among those are json and yaml.
Questions to [David Rotermund](mailto:davrot@uni-bremen.de)
```shell
pip install dataconf
```
## Defining the shape of the config
First we define the shape of our configuration data with data classes. We need to have one dataclass Config (or however you want to call it) which is the root of the config.
The root contains variables but also can contain sub-dataclasses which can also contain variables and sub-sub-dataclasses... and so on...
Here an example:
```python
from dataclasses import dataclass
@dataclass
class Date:
day: int
month: int
year: int
hour: int
minute: int
second: int
@dataclass
class MetaData:
channels: int
scale: float
name: str
@dataclass
class Config:
id: int
date: Date
meta_data: MetaData
events: list[int]
```
If you are not sure that all parameters are included in the config file then you can set the default values or default_factory with the field element in the dataclass. see [dataclass](https://davrot.github.io/pytutorial/python_basics/dataclass/) for details.
If you need more features then you may want to look into [hydra](https://hydra.cc/):
* Hierarchical configuration composable from multiple sources
* Configuration can be specified or overridden from the command line
* Dynamic command line tab completion
* **Run your application locally or launch it to run remotely**
* **Run multiple jobs with different arguments with a single command**
"Hydra is an open-source Python framework that simplifies the development of research and other complex applications. The key feature is the ability to dynamically create a hierarchical configuration by composition and override it through config files and the command line. The name Hydra comes from its ability to run multiple similar jobs - much like a Hydra with multiple heads."