Skip to content

Commit 0a9a33a

Browse files
Merge pull request #415 from AndreWohnsland/dev
Fix addon using default instead local config
2 parents eb06c1b + f06b022 commit 0a9a33a

File tree

22 files changed

+109
-628
lines changed

22 files changed

+109
-628
lines changed

.github/workflows/code-check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ['3.9', '3.11']
16+
python-version: ["3.11", "3.13"]
1717
steps:
1818
- name: ⤵️ Check out code from GitHub
1919
uses: actions/checkout@v4
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
python-version: ['3.9', '3.11']
31+
python-version: ["3.11", "3.13"]
3232
steps:
3333
- name: ⤵️ Check out code from GitHub
3434
uses: actions/checkout@v4
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
strategy:
4949
matrix:
50-
python-version: ['3.9', '3.11']
50+
python-version: ["3.11", "3.13"]
5151
steps:
5252
- name: ⤵️ Check out code from GitHub
5353
uses: actions/checkout@v4
@@ -56,4 +56,4 @@ jobs:
5656
with:
5757
python-version: ${{ matrix.python-version }}
5858
- name: 🔍 Run PyTest
59-
run: uv run pytest
59+
run: uv run pytest

.github/workflows/test-release-run.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ['3.9', '3.11']
18+
python-version: ["3.11", "3.13"]
1919
steps:
2020
- name: ⤵️ Check out code from GitHub
2121
uses: actions/checkout@v4
@@ -29,8 +29,8 @@ jobs:
2929
./scripts/setup.sh cicd
3030
- name: Start API
3131
run: |
32-
uv run api.py &
33-
sleep 5
32+
uv sync
33+
uv run api.py & sleep 5
3434
- name: Test API
3535
run: |
3636
for i in {1..6}; do

dashboard/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim-bookworm
1+
FROM python:3.13-slim-trixie
22

33
WORKDIR /app
44

dashboard/frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim-bookworm
1+
FROM python:3.13-slim-trixie
22

33
WORKDIR /app
44

dashboard/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "dashboard"
33
version = "1.0.0"
44
description = "CocktailBerry Dashboard"
55
readme = "README.md"
6-
requires-python = ">=3.11"
6+
requires-python = ">=3.13"
77
dependencies = [
88
"dash>=3.0.4",
99
"fastapi>=0.115.5",

docs/addons.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -112,40 +112,44 @@ from src.programs.addons import AddonInterface # (1)!
112112
ADDON_NAME = "Your Displayed Name"
113113

114114
class Addon(AddonInterface): # (2)!
115-
def setup(self): # (3)!
115+
def define_configuration(self): # (3)!
116116
pass
117117

118-
def cleanup(self): # (4)!
118+
def setup(self): # (4)!
119119
pass
120120

121-
def before_cocktail(self, data: dict): # (5)!
121+
def cleanup(self): # (5)!
122122
pass
123123

124-
def after_cocktail(self, data: dict): # (6)!
124+
def before_cocktail(self, data: dict): # (6)!
125+
pass
126+
127+
def after_cocktail(self, data: dict): # (7)!
125128
pass
126129

127130
def cocktail_trigger(
128131
self,
129132
prepare: Callable[[Cocktail], tuple[bool, str]]
130-
): # (7)!
133+
): # (8)!
131134
pass
132135

133136
def build_gui(
134137
self,
135138
container,
136139
button_generator
137-
) -> bool: # (8)!
140+
) -> bool: # (9)!
138141
return False
139142
```
140143

141-
1. Using the `AddonInterface` will give you intellisense for the existing functions available.
144+
1. Using the `AddonInterface` will give you intellisense for the existing functions available.
142145
2. Your class needs to have the name Addon and should inherit from the AddonInterface.
143-
3. Initializes the addon, executed at program start.
144-
4. Method for cleanup, executed a program end just before the program closes.
145-
5. Executed right before the cocktail preparation. In case of a RuntimeError, the cocktail will not be prepared and the message will be shown to the user instead.
146-
6. Executed right after the cocktail preparation, before other services are connected or DB is updated.
147-
7. This function will be run in a thread on a continuous loop. You can use the `prepare` function to trigger a cocktail preparation. It will return a boolean if the cocktail was prepared successfully and a message string holding more information. There is currently no GUI indication that this cocktail preparation was triggered.
148-
8. Will be used if the user navigates to the addon window and selects your addon. The container is a PyQt5 Layout widget you can (but not must) use to define custom GUI elements and connect them to functions. If you just want to have buttons executing functions, you can use the button generator function. Return False, if not implemented.
146+
3. Define additional configuration values for your addon here, executed before setup.
147+
4. Initializes the addon, executed at program start.
148+
5. Method for cleanup, executed a program end just before the program closes.
149+
6. Executed right before the cocktail preparation. In case of a RuntimeError, the cocktail will not be prepared and the message will be shown to the user instead.
150+
7. Executed right after the cocktail preparation, before other services are connected or DB is updated.
151+
8. This function will be run in a thread on a continuous loop. You can use the `prepare` function to trigger a cocktail preparation. It will return a boolean if the cocktail was prepared successfully and a message string holding more information. There is currently no GUI indication that this cocktail preparation was triggered.
152+
9. Will be used if the user navigates to the addon window and selects your addon. The container is a PyQt5 Layout widget you can (but not must) use to define custom GUI elements and connect them to functions. If you just want to have buttons executing functions, you can use the button generator function. Return False, if not implemented.
149153

150154
Now that you know the skeleton, you can fill it with your program logic.
151155

@@ -157,6 +161,7 @@ But this approach is not robust against code changes (new versions of addon), an
157161
Therefore, the addon provider can use the CocktailBerry configuration.
158162
To do so, the user needs to inject the config name, type and validation function into the config.
159163
There is also the option to provided a description, as well as according translations.
164+
It is important that you use the `define_configuration()` function for this, as it is executed before the setup of the addon and loading in local set config values.
160165
You can find each direction in the subsections below.
161166

162167
#### Add Config Values
@@ -174,8 +179,11 @@ You can have a look at the other values as a reference.
174179
```python
175180
from src.config.config_manager import CONFIG as cfg # (1)!
176181

177-
def setup(self):
178-
cfg.add_config("ADDON_CONFIG", "DefaultValue") # (2)!
182+
def define_configuration(self):
183+
cfg.add_config(
184+
config_name="ADDON_CONFIG",
185+
default_value="DefaultValue"
186+
) # (2)!
179187
```
180188

181189
1. Needs to import the `CONFIG` object from CocktailBerry.
@@ -216,12 +224,12 @@ def _check_function(configname: str, configvalue: str): # (2)!
216224
f"The value {configvalue} for {configname} is not allowed."
217225
)
218226

219-
def setup(self):
227+
def define_configuration(self):
220228
cfg.add_config(
221-
"ADDON_CONFIG",
222-
"DefaultValue",
223-
[_check_function]
224-
) # (5)!
229+
config_name="ADDON_CONFIG",
230+
default_value="DefaultValue",
231+
validation_function=[_check_function] # (5)!
232+
)
225233
```
226234

227235
1. Please use the `ConfigError` class from CocktailBerry.
@@ -246,12 +254,12 @@ def _less_than_10(configname: str, configvalue: int): # (1)!
246254
f"The value for {configname} needs to be less than 10."
247255
)
248256

249-
def setup(self):
257+
def define_configuration(self):
250258
cfg.add_config( # (2)!
251-
"ADDON_LIST",
252-
[1, 2, 3],
253-
[], # (3)!
254-
[_less_than_10] # (4)!
259+
config_name="ADDON_LIST",
260+
default_value=[1, 2, 3],
261+
validation_function=[], # (3)!
262+
list_validation_function=[_less_than_10] # (4)!
255263
)
256264
```
257265

@@ -269,19 +277,18 @@ The GUI will then display a drop down, only showing the allowed values.
269277
Please take note, if you want types other than string, you need to convert them after you retrieve the value from the config.
270278
The dropdown element only support string values.
271279

272-
273280
```python
274-
def setup(self):
281+
def define_configuration(self):
275282
options = ["List", "of", "allowed", "values"] # (1)!
276283
cfg.add_selection_config(
277-
"ADDON_SELECTION",
278-
options,
279-
options[1], # (2)!
284+
config_name="ADDON_SELECTION",
285+
options=options,
286+
default_value=options[1], # (2)!
280287
)
281288

282289
cfg.add_selection_config(
283-
"ADDON_SELECTION_INT",
284-
["10", "25", "50"] # (3)!
290+
config_name="ADDON_SELECTION_INT",
291+
options=["10", "25", "50"] # (3)!
285292
)
286293
none_string_value = int(cfg.ADDON_SELECTION_INT) # (4)!
287294

@@ -305,7 +312,7 @@ But it is encouraged to do so to improve user experience.
305312
```python
306313
from src.dialog_handler import UI_LANGUAGE as uil # (1)!
307314

308-
def setup(self):
315+
def define_configuration(self):
309316
...
310317
desc = {
311318
"en": "English description",

microservice/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim-bookworm
1+
FROM python:3.13-slim-trixie
22

33
RUN mkdir /usr/src/app/
44
WORKDIR /usr/src/app/

microservice/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "microservice"
33
version = "1.0.0"
44
description = "Microservice for CocktailBerry"
55
readme = "README.md"
6-
requires-python = ">=3.11"
6+
requires-python = ">=3.13"
77
dependencies = [
88
"fastapi[standard]>=0.115.5",
99
"python-dotenv>=1.0.1",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "2.8.0"
44
description = "A Python and Qt based App for a Cocktail Machine on a Raspberry Pi. Easily serve Cocktails with Raspberry Pi and Python"
55
authors = [{ name= "Andre Wohnsland" , email = "cocktailmakeraw@gmail.com" }]
66
readme = "readme.md"
7-
requires-python = ">= 3.9"
7+
requires-python = ">= 3.11"
88

99
dependencies = [
1010
"gitpython>=3.1.43",

scripts/all_in_one.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ fi
3636
echo "~~ linking python to python3 if not already done ~~"
3737
sudo apt install python-is-python3
3838

39-
# steps for python >= 3.9
40-
echo "~~ Check that Python version is at least 3.9 ~~"
39+
# steps for python >= 3.11
40+
echo "~~ Check that Python version is at least 3.11 ~~"
4141
version=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
4242
parsedVersion="${version//./}"
4343
echo "Detected version: $version"
44-
if [[ "$parsedVersion" -lt "390" ]]; then
45-
echo "Python must be at least 3.9. Please upgrade your Python or the system to use CocktailBerry."
44+
if [[ "$parsedVersion" -lt "3110" ]]; then
45+
echo "Python must be at least 3.11. Please upgrade your Python or the system to use CocktailBerry."
4646
echo "You can check your local Python version with 'python -V'"
4747
echo "If you have an older system, python3 -V may use the python 3, you should set up python that the python command uses python 3"
4848
echo "For a tutorial, you can look at https://alluaravind1313.medium.com/make-python3-as-default-in-ubuntu-machine-572431b69094"

0 commit comments

Comments
 (0)