Metadata-Version: 2.1
Name: heatbit_models
Version: 3.2.20
Summary: Common attrs (dataclass) models.
Author-email: Sergey Silaev <sergeys@heatbit.com>, Alex Kroll <alex.kroiants@heatbit.com>, Sergey Panteleev <sergeyp@heatbit.com>
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: attrs==23.1.0
Requires-Dist: cattrs==23.1.2

# Common dataclass (define) models

This library contains data class models recommended for use in connected
services. Our data class models are based on the `attrs` package.

## How to add new models

The first and most important part is all changes must be committed through the
merge requests because this is a good practice, and we run linting (pre-commit
hooks) in the pipeline.

The process of creating new packages starts automatically but only when merging
into the master branch and when changing one of the following files:

  - src/*.py
  - requirements.txt
  - pyproject.toml

So, if you update the `README.md` file, the automatic process of creating a new
package will not start.

## Setup dev enviroment
To install dev dependancies use the command:

```shell
make install
```

You may need to manually run `pre-commit` checks, to do this, use the command:

use the command:
```shell
make pre-commit
```
or original command:
```shell
pre-commit run --all-files
```

The Output should be like this:
```shell
pre-commit run --all-files
check for added large files..............................................Passed
check yaml...............................................................Passed
check toml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
detect private key.......................................................Passed
fix requirements.txt.....................................................Passed
check blanket noqa.......................................................Passed
ruff.....................................................................Passed
black....................................................................Passed
bandit...................................................................Passed
pyright..................................................................Passed
```

## Do changes
Do your work (add your models or something), you can check existing models
[here](/src/heatbit/models/models.py).

When work is done, update the `__init__.py` to add new models there (if needed)
and update version in the `pyproject.toml` then create a merge request to the
master branch:

```toml
[project]
name = "heatbit_models"
version = "x.y.z" <-- here
description = "Common dataclass models."
readme = "README.md"
```

## How to test it?

Before pushing new changes and creating merge request, you can build the
package manually to test it. To create a package, you can use the command:

```shell
make build
```

To install it in your environment, use the command:

```shell
pip install dist/heatbit_models-1.0.0-py3-none-any.whl
```

And check your models:

```shell
$ python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Autoloaded ['os', 'sys', 'asyncio']
>>> from heatbit import models
>>> heater_status = models.HeaterStatus()
>>> heater_status.to_json()
'{"heater_value": 0, "fan_rpm_value": 0, "fan_speed_value": 0}'
>>> heater_status.from_json(heater_status.to_json())
HeaterStatus(heater_value=0, fan_rpm_value=0, fan_speed_value=0)
```

To clean files after the build you can use the command:

```shell
make clean
``````

For more information about the commands, you can check `Makefile`.
